tags:

views:

103

answers:

1

I'm working on a program which makes heavy use of a serial port.

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.

Everything works perfectly until the device on the other end sends a BREAK (or, just disconnect the serial port :-).

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, asking fconfigure for the last error, it always says BREAK. Now, I don't know if that's just leftovers from the previous error or not.

In any case, HOW in the world does someone clear the 'break' condition on a serial port in TCL?

Thanks!

Rusty

Update: here's how we open the serial port:

    set state(com_port_handle) [open $name r+]


    #      Configure the COM port.

    fconfigure $state(com_port_handle) -mode 115200,n,8,1 \
                                       -blocking 0 \
                                       -buffering none \
                                       -translation binary
    fconfigure $state(com_port_handle) -handshake none

When we want to force a break from our side, we do:

    fconfigure $state(com_port_handle) -ttycontrol {break 1}
    after 100
    fconfigure $state(com_port_handle) -ttycontrol {break 0}
A: 

After reading through this summary of software flow control, it looks like sending the Xon character might wake the link back up (if it indeed was paused by an Xoff).

Also, you might want to take a look at these articles on the TCLer's wiki regarding serial ports. This is the code I normally use as a skeleton for anything involving a serial port.

bta