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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receiving a ‘BREAK’ in tcl 8.5.1 causes COM port to quit working (xp)

Status
Not open for further replies.

rustycar54

Programmer
Jan 11, 2010
3
US

I'm working on a program which makes heavy use of a serial port. In this case, a *real* serial port not a usb-to-serial adapter.

It is currently a windows-only program (unfortunately :)), running on Windows XP. The TCL version is 8.5.1.0 - it may or may not be an 'official' TCL, not sure. The script is 'compiled together' (made into an executable) so that the user doesn't run the tcl directly - they run the executable which runs the script.

Everything works perfectly until the device on the other end sends a BREAK (or, just disconnect the serial port as that also gives a BREAK condition).

Once that happens, data is still received fine, but sending data to the port via 'puts' results in no data going to the serial port. In fact, when I do send a character using puts, if I ask fconfigure for the last error, it always says BREAK. Of course, that 'BREAK' condition may simply be the last error, and the current state is 'no error'...

If you try closing the port and re-opening it while running in the same TCL script, the open fails (permission denied).

Until I exit the 'program', the serial port is not available in any way anywhere. Once I exit the tcl script/program, other programs can open the COM port - and if you re-run the script/program you can open the port again. But you must EXIT the program in order to actually free up the port. This ONLY happens with TCL programs/scripts - for example TeraTerm does not exhibit the same issue (so its probably not hardware).

In any case, HOW in the world does someone clear the 'break' condition on a serial port in TCL so that one can send characters to the device again?

(I tried

Thanks!

Rusty
 
If you look here:
they seem to be saying that non-blocking I/O needs to be configured. I never did any serial I/O, myself, so I can't really help.

_________________
Bob Rashkin
 
Well, I do have blocking off. Here's how I set the port:

fconfigure $state(com_port_handle) -mode 115200,n,8,1 \
-blocking 0 \
-buffering none \
-translation binary
fconfigure $state(com_port_handle) -handshake xonxoff
fileevent $state(com_port_handle) readable [namespace code service_com_port]

I'll go spend more time searching over there on wiki.tcl.tk ...

Thanks!

Rusty

p.s. - sorry for ending my first post with '(I tried' !
 
I've discovered the issue - if you have xonxoff enabled on the port when the break comes in, then the output path gets frozen so that you cannot send any characters.

For now the solution is to turn off xonxoff mode. I found this issue even with 'moni', so its not just my code ;-)

Rusty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top