Re: Events on Serial port



* 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'
.



Relevant Pages

  • Re: Events on Serial port
    ... | send the UartToI2C chip a command to send data, using a file event ... # Now poll DSR and send the trigger if high, the fileevent does the rest. ...
    (comp.lang.tcl)
  • Re: Events on Serial port
    ... | send the UartToI2C chip a command to send data, using a file event ... # Now poll DSR and send the trigger if high, the fileevent does the rest. ...
    (comp.lang.tcl)
  • Re: How to modify fileevent
    ... Bruce Hartweg wrote: ... > will trigger you're fileevent, then you just need to check for ... otherwise your file event ...
    (comp.lang.tcl)
  • Re: Events on Serial port
    ... | send the UartToI2C chip a command to send data, using a file event ...   proc read_data { ... # Now poll DSR and send the trigger if high, ...
    (comp.lang.tcl)
  • Re: Autoincremental field in VFP7
    ... I made a gross mistake and pointed you to CREATE TRIGGER ON INSERT .command. ... ALTER TABLE x ALTER COLUMN keyfield Int AUTOINC [NEXTVALUE NextValue[STEP ... You triugger would not fail if you used this command ...
    (microsoft.public.fox.helpwanted)