Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serial communication fileevent problem

Status
Not open for further replies.

accacca

Technical User
Apr 18, 2011
3
0
0
IT
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::port_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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top