CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2010
    Posts
    7

    Exclamation getting binary output from a magnetic writer

    I have a msr505c magnetic reader/writer, and
    I am trying to read a non standard format magnetic card.
    I would need to see the data in binary form to analyze.

    there is a crappy demo program for windows, but it would output in hex for raw read

    i have found some source files here for linux: http://code.google.com/p/libmsr/
    for the msr505c
    and here i found the interesting part
    i used this snippet code below to get a string in 0 and 1 from track data
    but the binary output is wrong, i know how the data format should look like, i also know the start sentinel. etc...

    looking at the dumpbits function i see there is a loop that was commented out, so i tried that loop, but still it did not work

    int
    dumpbits (uint8_t * buf, int len)
    {
    int bytes, i;
    for (bytes = 0; bytes < len; bytes++) {
    /* for (i = 0; i < 8; i++) { */
    for (i = 7; i > -1; i--) {
    if (buf[bytes] & (1 << i))
    printf("1");
    else
    printf("0");
    }
    }
    printf ("\n");
    return (0);
    }

    for (i = 0; i < MSR_MAX_TRACKS; i++)
    tracks.msr_tracks[i].msr_tk_len = MSR_MAX_TRACK_LEN;


    printf("Ready to do a raw read. Please slide a card.\n");
    msr_raw_read (fd, &tracks);

    for (i = 0; i < MSR_MAX_TRACKS; i++) {
    dumpbits (tracks.msr_tracks[i].msr_tk_data,
    tracks.msr_tracks[i].msr_tk_len);
    printf("\n");


    looking here http://libmsr.googlecode.com/files/M...s%20Manual.pdf

    they show the raw data bit orientation on page 15

    could some help me out on getting true binary output
    is the code wrong?

    you can find all of the source here http://code.google.com/p/libmsr/sour...wse/#svn/trunk

  2. #2
    Join Date
    Jan 2010
    Posts
    7

    Cool Re: getting binary output from a magnetic writer

    can anyone help?

  3. #3
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    Hi, I just wanted to say that I own a MSR505C as well and I'm also having issues with the demo software, although my problem is that I'm unable to write to a specific card -- I simply get an error regardless of what I try to write to it.

    As such I want to write my own software for it that will hopefully be able to write to this card and that will work in GNU/Linux; I haven't gotten around to do that yet though but reading will be my first step and I'd like to be able to do raw reading as well, so if I can get it working I'll let you know. :-)

  4. #4
    Join Date
    Jan 2010
    Posts
    7

    Re: getting binary output from a magnetic writer

    did you try libmsr?
    are you trying to write an iso formatted card?

  5. #5
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    Quote Originally Posted by joker5bb View Post
    did you try libmsr?
    are you trying to write an iso formatted card?
    I tried libmsr but I actually can't get it to work at all -- my MSR505C doesn't show up as a physical USB device; may I ask what kernel module/option and what device (under /dev ) you used in conjunction with libmsr?

    Yes, my card is an ISO card, but I would still like to be able to read and write raw arbitrary binary data.

  6. #6
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    After compiling the usbserial module and creating the appropriate special character files with mknod I get the following when I connect the device:

    usb 2-2: Manufacturer: Prolific Technology Inc.
    usb 2-2: uevent
    usb 2-2: usb_probe_device
    usb 2-2: configuration #1 chosen from 1 choice
    usb 2-2: adding 2-2:1.0 (config #1, interface 0)
    usb 2-2:1.0: uevent
    usbserial_generic 2-2:1.0: usb_probe_interface
    usbserial_generic 2-2:1.0: usb_probe_interface - got id
    drivers/usb/core/inode.c: creating file '003'
    hub 1-0:1.0: state 7 ports 6 chg 0000 evt 0004

  7. #7
    Join Date
    Jan 2010
    Posts
    7

    Re: getting binary output from a magnetic writer

    it should be
    /dev/ttyUSB0
    Last edited by joker5bb; February 21st, 2010 at 06:24 PM. Reason: mistake

  8. #8
    Join Date
    Jan 2010
    Posts
    7

    Re: getting binary output from a magnetic writer

    i get this output when i run the msr demo program from libmsr

    joker@joker-laptop:/dev$ msr /dev/ttyUSB0
    Communications test passed.
    Device Model: MSR-206-3
    Putting the writer to Lo-Co mode...
    It appears that the reader did not switch to Lo-Co mode.Attempting sensor test -- please slide a card...
    It appears that the sensor did not sense a magnetic card.
    Running ram test...
    It appears that the RAM test failed
    Preparing reader for reading...
    Ready to read an ISO formatted card. Please slide a card.
    msr: get start delimiter failed: Resource temporarily unavailable

    ram test always fails?
    does happen to you? try it

  9. #9
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    Quote Originally Posted by joker5bb View Post
    i get this output when i run the msr demo program from libmsr

    joker@joker-laptop:/dev$ msr /dev/ttyUSB0
    Communications test passed.
    Device Model: MSR-206-3
    Putting the writer to Lo-Co mode...
    It appears that the reader did not switch to Lo-Co mode.Attempting sensor test -- please slide a card...
    It appears that the sensor did not sense a magnetic card.
    Running ram test...
    It appears that the RAM test failed
    Preparing reader for reading...
    Ready to read an ISO formatted card. Please slide a card.
    msr: get start delimiter failed: Resource temporarily unavailable

    ram test always fails?
    does happen to you? try it
    This is strange,
    I created all the ttyUSB* devices (from 0 to 255) as specified in the Linux kernel documentation -- despite that, I cannot access the device:

    I tried ttyUSB0 and I also tried all of the devices with as follows:
    Code:
    for i in $(seq 0 255); do ./msr /dev/ttyUSB${i}; done
    However, all of them give the error:

    Code:
    msr: Serial open of /dev/ttyUSB253 failed: No such device
    With the two last giving me:

    Code:
    msr: Serial open of /dev/ttyUSB254 failed: No such device or address
    msr: Serial open of /dev/ttyUSB255 failed: No such device or address

  10. #10
    Join Date
    Jan 2010
    Posts
    7

    Re: getting binary output from a magnetic writer

    all i did was just plug it in, i did not compile anything extra
    what is your kernel version

  11. #11
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    Quote Originally Posted by joker5bb View Post
    all i did was just plug it in, i did not compile anything extra
    what is your kernel version
    Strange, I'll try a different physical computer, my kernel version is 2.6.30, custom compiled by myself.

    I found four devices that show up under /dev by simply comparing what devices are there prior to connecting the device and what devices (if any) that show up upon connecting it.

    I tried to give these devices as arguments to the msr program, although I still get:

    Code:
    x86_1# ./msr /dev/usbdev2.3_ep00 
    msr: Serial open of /dev/usbdev2.3_ep00 failed: No such device or address
    x86_1# ./msr /dev/usbdev2.3_ep02 
    msr: Serial open of /dev/usbdev2.3_ep02 failed: No such device or address
    x86_1# ./msr /dev/usbdev2.3_ep81
    msr: Serial open of /dev/usbdev2.3_ep81 failed: No such device or address
    x86_1# ./msr /dev/usbdev2.3_ep83
    msr: Serial open of /dev/usbdev2.3_ep83 failed: No such device or address

  12. #12
    Join Date
    Jan 2010
    Posts
    20

    Re: getting binary output from a magnetic writer

    Quote Originally Posted by joker5bb View Post
    i get this output when i run the msr demo program from libmsr

    joker@joker-laptop:/dev$ msr /dev/ttyUSB0
    Communications test passed.
    Device Model: MSR-206-3
    Putting the writer to Lo-Co mode...
    It appears that the reader did not switch to Lo-Co mode.Attempting sensor test -- please slide a card...
    It appears that the sensor did not sense a magnetic card.
    Running ram test...
    It appears that the RAM test failed
    Preparing reader for reading...
    Ready to read an ISO formatted card. Please slide a card.
    msr: get start delimiter failed: Resource temporarily unavailable

    ram test always fails?
    does happen to you? try it
    I finally got the hardware itself working now, mapped to /dev/ttyUSB0.

    I doubt your MSR is defective -- I get the exact same error as you do, RAM test fails, then I get the "Resource temporarily unavailable".

    It does put the device into "read mode" though -- the read LED gets lit when I do this.

    Time to start looking at the code. :-)

  13. #13
    Join Date
    Jan 2010
    Posts
    7

    Re: getting binary output from a magnetic writer

    is there a diffrence between

    /*
    * Print a buffer as reasonably formatted raw bits.
    */
    void dump_buffer(const unsigned char *buffer)
    {
    int i;

    for (i=0; i<MAX_CARD_LEN; i++)
    {
    print_bits(*(buffer +i));
    printw(" ");

    if ((i + 1) % BYTES_PER_LINE == 0)
    {
    printw("\n");
    }
    else if ((i + 1) % 4 == 0)
    {
    printw(" ");
    }
    }
    }

    /*
    * Print a byte as a string of eight bits.
    */
    void print_bits(unsigned char c)
    {
    int i;
    for (i = 0; i<8; i++)
    {
    printw("%c", (c&0x80)?'1':'0');
    c <<= 1;
    }
    }

    /*
    * Print the header.
    */

    and

    int
    dumpbits (uint8_t * buf, int len)
    {
    int bytes, i;
    for (bytes = 0; bytes < len; bytes++) {
    /* for (i = 0; i < 8; i++) { */
    for (i = 7; i > -1; i--) {
    if (buf[bytes] & (1 << i))
    printf("1");
    else
    printf("0");
    }
    }
    printf ("\n");
    return (0);
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured