Reading from serial port in the simplest way

serial port

I have a TrueRNG USB-based hardware RNG, and I am trying to read its output on Mac OS X 10.9.2. I need just one-way communication.

The device says that it appears as a "CDC Virtual Serial Port", and indeed I see it as /dev/tty.usbmodem1411.

I've never been able to cat /dev/tty.usbmodem1411; when I do, I get no output at all. I can, however, use minicom or picocom to read from it. With picocom, it works even with --noinit --noreset options, suggesting that I should be able to cat that device.

So, my issues/questions:

  1. Why can I not cat that device?
  2. Though it works with minicom and picocom, it works just on the first session: if I close either of these programs, then reopen them, then they read about 300 bytes and block forever. If I close and reopen again, they can't read anything. When I unplug and replug the USB device, though, it's again readable forever on the first attempt. Why would this be, and does it have to do with this quote from TrueRNG documentation? "By clearing the DTR flag on the virtual serial port, the stream of data will stop. The stream of data will resume when DTR is set."
  3. I want to view the random data in hex. So I try this command: picocom /dev/tty.usbmodem1411 | xxd -p. The output, however, doesn't seem to respect the newline character; just the carriage return. It moves to the next line without rewinding to the beginning of the line. I'd prefer it to be continuous.

Here's some diagnostics:

% stty -a -f /dev/tty.usbmodem1411
speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl
        -echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin
        -nokerninfo -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
        -ignbrk -brkint -inpck -ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
        min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
        stop = ^S; susp = ^Z; time = 0; werase = ^W;

Best Answer

Apparently I needed to use /dev/cu.usbmodem1234 instead of dev/tty.usbmodem1234. Thanks for the solution to the company that manufactures this device.

Related Question