I have write a small library for serial communication under Win
The RX routine for reading incoming data is installed with fileevent command:
fileevent $cfg(port) readable com:ort_rxisr
My com::rx_isr procedure do this
variable cfg
append cfg(rxbuffer) [read $cfg(port)]
$cfg(usercallback) $cfg(rxbuffer)
All is ok for small messages (few bytes) but If I receive a frame of 128bytes the procedure fail.
The problem is this:
the first call to rx_isr read all availables chars and start decoding message
but while decode is in progress another call to rx_isr replace previous script and the rx procedure terminate in error.
How I can trigger a call to usercallback procedure but blocking successive calls while first call is in progress. And obiouvsly after first call terminate if new data is available recall another time usercallback.
My solution (with my little experience in TCL) is install a polling to serial channel with after command and checking if data is available. But is a stupid solution and don't require fileevent command.
How I can genereate a custom event and link a script to this event
The RX routine for reading incoming data is installed with fileevent command:
fileevent $cfg(port) readable com:ort_rxisr
My com::rx_isr procedure do this
variable cfg
append cfg(rxbuffer) [read $cfg(port)]
$cfg(usercallback) $cfg(rxbuffer)
All is ok for small messages (few bytes) but If I receive a frame of 128bytes the procedure fail.
The problem is this:
the first call to rx_isr read all availables chars and start decoding message
but while decode is in progress another call to rx_isr replace previous script and the rx procedure terminate in error.
How I can trigger a call to usercallback procedure but blocking successive calls while first call is in progress. And obiouvsly after first call terminate if new data is available recall another time usercallback.
My solution (with my little experience in TCL) is install a polling to serial channel with after command and checking if data is available. But is a stupid solution and don't require fileevent command.
How I can genereate a custom event and link a script to this event