help with serial i/o from a device?
Dave Stevens
geek at uniserve.com
Wed Sep 5 21:34:22 UTC 2018
I've got a Plantower PMS5003 particle counter that reports
over a serial (RS-232) cable. Inline to my USB port is a uart, acting
as a level shifter. Node.js has a module that allows me to read
successfully from the device (or, strictly speaking, from the USB port).
It is, however, a bit large and clumsy, a lot of overhead to just copy
serial data (at a low rate, about 200 bits per second, into a file. I'd
like to use as small a computer as I can and am currently looking at a
Pi Zero W.
At first it seemed to me that I should just be able to copy incoming
data into the file like
cp /dev/ttyUSB0 filename.
But that doesn't work, I get sporadic ascii gibberish on screen and no
output data in the file.
Then I wrote a little Pascal program called copy that exactly copied
characters from input to output, like
sudo cat /dev/ttyUSB0 > copy > outputfile.bin
and that works fine.
Does anyone see why the original doesn't work? If I understood that I
might be able to use fewer resources and use a simpler device.
Dave
--
In modern fantasy (literary or governmental), killing people is the
usual solution to the so-called war between good and evil. My books are
not conceived in terms of such a war, and offer no simple answers to
simplistic questions.
----- Ursula Le Guin
More information about the ubuntu-users
mailing list