Thread: magnetic card reader prog.

  1. #1
    Unregistered
    Guest

    Post magnetic card reader prog.

    I need to write a program that will read
    magnetic cards and display the card code
    on the screen in binary format (1's and 0's).
    The signal from the card reader is connected
    to the parallel port and can be read in
    from address 0x379.

    This is program that I have written but I'm
    not sure if it works or not. If it does not work
    I will not have time to fix it so it must
    work the first time. If something is wrong with
    the program can someone please tell me.


    #include <stdio.h>
    #include <conio.h>

    void main()
    {
    char cls,rcp,prevCls=0,prevRead=0;
    int in;

    do
    { in = inp(0x379);

    cls = (in & 0x80);
    rcp = (in & 0x20);

    if (!rcp && cls && prevRead)
    printf("%d",(in >> 4) & 1);
    else
    if (!cls && prevCls)
    printf("\n\n");
    prevRead = rcp;
    prevCls = cls;

    } while (!kbhit());
    return 0;
    }

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > void main()
    > return 0;
    The first one makes the second one useless I hope you know.
    The world is waiting. I must leave you now.

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    If you have a function of type void(), the return type is void.. There is nothing to return. If you made main as just main(), that would make much more sense..

    And why are you so restricted on your time limit?
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is program that I have written but I'm
    not sure if it works or not. If it does not work
    I will not have time to fix it so it must
    work the first time. If something is wrong with
    the program can someone please tell me.
    That's pretty funny. You want to write a program that will read from a parallel port (ie: stream) and read the 0s and 1s and give you whatever it is you're looking for on the first compile. HAHAHA. Forgive me while I bust a gut. HAHAHAHA

    Seriously.

    HAHAHHA.

    No, I'm really serious this time...

    The signal from the card reader is connected
    to the parallel port and can be read in
    from address 0x379.
    What OS is this supposed to run on? Depending on your OS, you cannot just directly access the hardware. Furthermore, You can't just (to my knowledge) grab some random address treat it like a character pointer or something.

    You should have to be using functions like read or fread to read from the stream. Keep in mind, you parallel port is not just some memory address (again, to my knoweldge) that simply hold all pending input in some character array / buffer some place that you can simply access.

    You have to open the stream for reading and read from it using the correct functions. As far as I know, and I'm not claming to know everything about hardware, you can't just simply pull some wild address out of a hat and treat it as a buffer.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    85

    Talking

    I am really curious what your program's defined problem and what platform(Windows, Unix) your program will run on? Does it involve with IO address mapping or something else? As you might know that writing a program to interfacing with HW(nuts and bolts) need to be well define its hw architecture and requirements. Here is the website that I think might helpfull to
    your project. http://ee.cleversoul.com/lcd_project.html
    Good luck!
    DV007

    /*===================================*
    * Say what you mean. Mean what you say. *
    *===================================*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise Unwanted Output
    By pobri19 in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2008, 04:07 AM
  2. Vector out of range program crash.
    By Shamino in forum C++ Programming
    Replies: 11
    Last Post: 01-18-2008, 05:37 PM
  3. Segmentation Fault - aaaaaaaah!
    By yogibear in forum C Programming
    Replies: 6
    Last Post: 10-01-2007, 03:21 AM
  4. Blackjack
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-20-2007, 08:07 PM
  5. How can I access a struct (from a header file)?
    By loxslay in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2006, 01:25 PM