Serial Port Woes
Len Morgan
len-morgan at crcom.net
Tue Jan 12 10:40:38 EST 2010
I'm having a lot of trouble consistently reading a serial port. I'm
trying to talk to a microcontroller using ModBus ASCII and the basic
idea is to send a request for data (about 12 bytes) and then wait for an
answer (about 300 bytes). There is between a 1/4 and 1/2 second delay
from when I send the command and the controller STARTS sending it back.
I also can't get it to work at all if I open it for update (either text
or binary). I have to open the com port, send the command, then close
the port and reopen it for read to get anything at all.
I've tried "until linefeed", "until empty", "until eof", "for 1 line",
etc. and none of them seem to work reliably. I KNOW that a response
ends with a CRLF pair and there is only ever 1 "line" in a response so
if I could just wait until I got the LF and it happened in say 3 seconds
or less, I'd be happy.
Any suggestions??
len morgan
More information about the use-livecode
mailing list