1
votes

I am trying to read a RS232 Serial Port with a Mag Stripe reader in Ubuntu. I have a USB one working fine (ID-Tech). But I am trying to get a Neuron reader to work as well. I am unfamiliar Serial Port communication in general, but with node-serial i wrote a simple app that sits and waits for a device:

node tester.js /dev/ttyS0 

Than spits out the output from the card reader. Works great with the USB ID-Tech reader, but when I have the Serial Port device plugged in I get nothing. I'm also a bit unsure on how to tell which Serial Port it's using. Is there a better tool to "probe" the serial ports in Ubuntu and figure out which one is in use by the Mag Reader?

UPDATE

Researching around it seems the tools to use are:

sudo cat /dev/ttyS0

The problem I'm having is which port is the device attached to, doing the above on ttyS0,1,2,3 does nothing and should dump out some output from the device. However I'm not sure if this needs to be run first:

sudo inputattach -dump /dev/ttyS0

This just hangs at the cursor and I figured to try and keyboard type for the card reader, but same issue just hangs. The output from dmesg | grep ttyS shows ports enabled:

[    1.906700] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    1.927250] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[    1.947758] serial8250: ttyS2 at I/O 0x3e8 (irq = 4) is a 16550A
[    1.968273] serial8250: ttyS3 at I/O 0x2e8 (irq = 3) is a 16550A
[    1.990199] 00:04: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    2.010770] 00:05: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
[    2.031335] 00:06: ttyS2 at I/O 0x3e8 (irq = 5) is a 16550A
[    2.051952] 00:07: ttyS3 at I/O 0x2e8 (irq = 11) is a 16550A
1
Do you have something that will actually verify electrical activity on the serial port, like a dongle with LED's, or another device that you know actually functions properly with a serial connection? Testing would be a simple matter of sending some bytes to the port and watching the lights blink.Robert Harvey
Thanks, so in linux I'm assuming I just write to the serial-port and expect some feedback on the device?Michael
Yes, assuming that you can do so in a way that is visible. Something like raising and lowering the RTS or CTS line (it's been awhile) every half-second.Robert Harvey
So checked out the device (mag reader) doesn't look like it has any lights or anything that I can notice anything happening. I tried minicom with all the settings from the readers docs, but can't seem to get anything to happen when I swipe a card still.Michael

1 Answers

0
votes

With your device plugged in, you can run this node code and check the info of every ports. You will likely recognize something and that's the port your looking for.

var serialport = require("serialport");

serialport.list(function (err, ports) {
    ports.forEach(function(port) {

        console.log("pnpId: " + port.pnpId);
        console.log("manufacturer: " + port.manufacturer);
        console.log("comName: " + port.comName);
        console.log("serialNumber: " + port.serialNumber);
        console.log("vendorId: " + port.vendorId);
        console.log("productId: " + port.productId);
    });
});

then you connect using:

var myPort = new SerialPort("/dev/ttyACM0", { // replace ttyACM0 with the right port on your computer
    baudrate: 115200,
    parser: serialport.parsers.readline("\r\n")
});

Hope it helps!