Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having some troubles reading the serial port, I'm traying to communicate two machines (one with winxp and the other with slackware) when I set up the communication at 1200, 7, even parity and one(1) stop bits it works fine sending. The setup in linux is this
Code:
stty 1200 cs7 -parodd -cstopb < /dev/ttyS0
echo "testing" > /dev/ttyS0
I receive in a HyperTerminal (winXP) set up as 1200b, 7bits, parity even and one stop bit. testing
But when I try to read data using
Code:
cat /dev/ttyS0
And send data using an app in vbasic set up with the same parameters, it doesn't read anything, I figure out that as End of transmission is sending char 20 instead of char 13 and as requirement I can't change the way it transmits.
Does anybody knows how to read serial port using shell bash without waiting for the carriage return?
Seems logic, let me see if I understood, "head" would be the variable to print?
Mario
Sorry it's been so long...
Did you already figure this out?
head is not the variable. head is a UNIX command that usually prints the first few lines of a file (i.e., the head of the file). As this is intended for textfiles and looks for newlines, you use the -c flag, which, AFAIK, will print a number of characters (or bytes) at a time, disregarding EOF, EOL, EOT, or whatever. For any normal file, it is useless to print the first character repeatedly, but a serial device is (I think) like a FIFO, so it should work. So the entire (bourne shell) sequence
Code:
while head -c 1 /dev/ttyS0
do
: # a dummy command that always returns true
done
does what you think "cat /dev/ttyS0" would do... that is, print the serial output (to stdout) as it comes in.
If you want to read it in a script, you could do a number of things (i.e., use parentheses/braces around the entire thing and use redirection or backtick quotes, or make the command a simple executable file on whose output you could use redirection or backticks).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.