On Fri, Apr 26, 2002 at 09:48:22PM -0700, Bill Moseley wrote: | I'm trying to get a program that reads serial data working. I'm looking | for some debugging tips. ... | BYTE readByte(int fi) | { | char buf[2]; | printf("About to read a byte\n"); | read (fi, buf, 1); | printf("Read %02x\n", buf[0]); | return buf[0]; | } | | It hangs after saying "About to read a byte" in this function. So the | read() is blocking.
read() will block if there is no data to read. | So, ah, well, any suggestions?? Are you actually sending data through the port at the time the read() blocks? | Is there an easy way to dump the chars from /dev/ttyS0? $ cat /dev/ttyS0 You may need to use stty or setserial first to tell the serial port how to communicate with the other device. Things like baud rate, parity, handshaking, etc, need to match on both sides of the serial port. Do you have the specs for your device? I've found with serial mice that gpm must be run first (presumably to set up the serial port) before cat-ing /dev/ttyS0 will yield any data. HTH, -D -- I tell you the truth, everyone who sins is a slave to sin. Now a slave has no permanent place in the family, but a son belongs to it forever. So if the Son sets you free, you will be free indeed. John 8:34-36 GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
pgpeL9MH20aYY.pgp
Description: PGP signature