Re: Events on Serial port
- From: Ralf Fassel <ralfixx@xxxxxx>
- Date: Thu, 03 Jul 2008 20:53:34 +0200
* Derek <derek.philip@xxxxxxx>
| I could combine the two I suppose, poll until I get DSr = 1 , then
| send the UartToI2C chip a command to send data, using a file event
| to read it in. I have to wait around a little though as the data
| may not all come at once checking the queue may be better than what
| I'm doing now
This is roughly what I would have suggested.
set fd [open ... ]
fconfigure $fd -encoding binary -blocking 0 ...
fileevent $fd readable [list read_data $fd]
proc read_data {fd} {
if {[eof $fd]} {
close $fd
return
}
set bytes [read $fd]
if [[string length $bytes] > 0} {
# Add $bytes to previous contents, check whether all data are
# there, if so, set flag for processing in/before the
# DSR-checker, or go processing directly.
}
}
# Now poll DSR and send the trigger if high, the fileevent does the rest.
# Sending the trigger could reset the response buffer to empty
R'
.
- Follow-Ups:
- Re: Events on Serial port
- From: Derek
- Re: Events on Serial port
- From: Cameron Laird
- Re: Events on Serial port
- From: Derek
- Re: Events on Serial port
- References:
- Events on Serial port
- From: Derek
- Re: Events on Serial port
- From: Rolf Schroedter
- Re: Events on Serial port
- From: Derek
- Events on Serial port
- Prev by Date: Re: Events on Serial port
- Next by Date: Re: Tcl/Tk-8.5.3 breaks my code here
- Previous by thread: Re: Events on Serial port
- Next by thread: Re: Events on Serial port
- Index(es):
Relevant Pages
|