[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Autodetecting bps
- Subject: [ale] Autodetecting bps
- From: ChrisF at computone.com (Chris Fowler)
- Date: Mon, 7 May 2001 11:16:02 -0400
Interesting problem I'm working on right now.?? I'm trying to write simple code that attempts to autodetect the serial speed of
anyhting attached to it.?? I'm attempting to do this by writing an 'a' out the port and tryting to see if an 'a' returns.
Simple code that is shortened
----------------------------
open("/dev/ttyS0, O_NOCTTY, O_RDWR)
set termios
for (speed = 50; speed != 921600; speed *= 2)
{
?????????????? set symbolic speed
?????????????? write 'a'
?????????????? read 'a'
?????????????? if 'a' = 'a'
?????????????? ?? ?????????? return MATCH
??????????????
}
It seems that I'm blocking at th read after the write.?? Is there a better way I can do this?
Thanks,
Chris