[ale] Autodetecting bps

Chris Fowler ChrisF at computone.com
Mon May 7 11:16:02 EDT 2001





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







More information about the Ale mailing list