You are not logged in.
So...I am using a serial device connected to a Keyspan Serial-to-USB adapter and plugged in to my computer's USB port. The device is constantly sending 115200 baud data over UART, with no parity, 8 data bits, 1 stop bit, no flow control, and no handshaking. I can read the data just fine on my Windows machine (once I install the Keyspan driver). On Arch64, I notice that when I plug it in, /dev/ttyUSB0 shows up so I believe that means the kernel is recognising the device and already has drivers to handle it. I would like to simply see the output of the device through my terminal emulator so I have written the following script....
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb
while true; do
read LINE < /dev/ttyUSB0
echo $LINE
done
When I run this script as root, however, I get no output. I have also tried appending "-icanon min 1 time 1" to the stty arguments list but also to no avail. Can anyone help? Thanks!!
Last edited by tony5429 (2009-10-30 20:59:30)
Offline
hmmm - 'read' might be abit choosy for the end-of-line character ...
Why not try:
cat </dev/ttyUSB0
... though you _may_ screw up your terminal if there are escape-sequences coming through ...
Offline
I have tried to make that work too before ... but I did put it on hold (wasn't successful) but it would be great to know how to do it ... it would be very handy because it would allow me to get some printscreens from oscilloscopes with a serial port.
At the time I did try to fiddle with stty, setserial, and either minicom or gtkterm (can't remember which one) but no luck there.
I remember stty and setserial had way too many options when compared with the simple setup windows and the oscilloscopes have ...
R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K
Offline
Thanks, all for the responses!
perbh: I wasn't sure exactly how to implement your suggestion. If the cat line doesn't use the variable, "$LINE", how can "echo $LINE" work? I am probably missing something simple...
Well, I have had a little success. The following script creates blank lines whenever data comes in through the usb device. Basically the device sends FFT data whenever it hears a sound which is greater than a certain threshold, so when I snap my fingers near it I see the FFT data show up in Terminal on Windows. Now, with the script below, if I snap my fingers my Linux machine outputs a bunch of blank lines so basically I just see my linux terminal emulator scrolling whenever I snap my fingers Does anyone have any ideas how to get the actual data on Linux? Thanks again!
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb
while true; do
read -n 8 LINE < /dev/ttyUSB0
echo $LINE
done
Offline
There must be a description somewhere of the data ... it could be plain binary (in which case read/cat might not show up much, unless you use 'cat -v' (ie 'print' non-printing characters). It the data arrives as a string - it most probably is terminated by CR and LF. However - untill we know what the data is like, its difficult to say which is the most correct way.
I have had quite a lot of success with 'minicom' in the past ...
So - give us a brief description of the data and we'll see what we can do ...
Offline
Awesome; so I should try... "cat -v < /dev/ttyUSB0" and remove the "echo $LINE" line? Well, I'll try that out and get back to you.
As for the data, it is just straight ASCII. The device itself is an Intel 8051 microcontroller development kit and I'm just converting the RS232 serial port output on the board to USB so I can read the data on my laptop.
Offline
You might want to set raw mode so you can read one byte at a time - otherwise the string may not be 'released' until it encounters a LF ...
Offline
Hrm... how do I set it to raw mode?
Offline
man setserial or man stty
Offline
Ah; is the "-icanon min 1 time 1" argument what I want?
Offline
Why not use minicom?
Offline
Hrm.... I tried the following but nothing showed up...
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb -icanon min 1 time 1
while true; do
cat -v < /dev/ttyUSB0
done
With the following, I'm getting the same blank lines popping up whenever I snap.
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb -icanon min 1 time 1
while true; do
read -n 8 LINE < /dev/ttyUSB0
echo $LINE
done
Any other ideas? Thanks again for your help!
Offline
I tried minicom and have to admit I felt the interface and configuration was somewhat difficult to work with (I know...I should appreciate the lightweight feel of it...)
Offline
When in 'cooked' mode (which is the default), you wont see anything until it finds a LF in the stream
Instead of "-icanon" above, use "-cooked"
But - as you have been told 2 or 3 times by now - try out 'minicom' first!
If that works - ie at least you can 'see' some activity, then you can go on to something more adventurous
[edit]
Was busy checking 'man stty' and didnt see your last post ...
Basically, in 'minicom' what you need is "ctrl/a - o"
You just have to forget about all the modem-specific detail
Other than that - doing a little bit of c-programming on a serial port is a no-brainer ...
But personally - I alway use minicom/stty/cat first to make sure something is actually happening,
then I go and tailormake it for _my_ personal use.
Last edited by perbh (2009-10-30 14:28:23)
Offline
"-cooked" didn't change anything for the cat-based script nor for the read-based script. I'll give minicom a shot using your suggestion; thanks!
Offline
Sweet! It works! Thank you very much!
Offline
If solved can you mark the thread as solved?
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
Done.
Offline