serial ports don't seem to work
Closed / Fixed218465ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:00:47
OriginalBugID: 625 Bug
Version: 8.0p2
SubmitDate: '1998-05-25'
LastModified: '1999-03-12'
Severity: MED
Status: Released
Submitter: hershey
ChangedBy: stanton
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-03-12'
FixedInVersion: 8.1b2
ClosedDate: '2000-10-25'
> I've seen a few queries about problems using Windows NT
> serial/comN ports, but no definitive answers on what
> is going on. I have boiled my problem down to two
> short Tcl scripts that "should" exchange integer data over
> two com ports connected with a Null modem cable.
> These don't cooperate.
>
> This state evolved from trying to control a modem from
> Tcl over a serial port. We then found that
> "copy con comX" would allow manual entry of control
> sequences that worked, but "type cntrlStringsInFile.txt > comX"
> does not work - may take the phone off hook with certain
> settings at best.
>
> It appears that the NT serial ports' drivers don't deal well with
> the hand-shaking of RS-232E.
>
> I'll provide the scripts to anyone interested and report any
> definitive results.
>
I posted a query a while back about the serial ports. I'll pass along
what I learned to get serial out of Tcl under windows.I've been using
Tck/Tk 8.1 with serial I/O working at 115.2K for NT and Windows 95 on
portables and desktops.
I was told serial IO wasn't functioning in versions prior to Tcl/Tk 8.0.
To paraphrase some of my code.
#Open the serial port as
if {[catch {open "COM1:" "RDWR"} sid]} then {
tk_dialog .dialog "Serial IO Error" "Unable to open serial port COM1:"
error 0 OK
unset sid
return ""
}
# configure for speed and binary data transfer
fconfigure $sid -mode {115200 n 8 1} -translation binary
# I don't think this was supposed to work, but since it kind of does
# I used it for asynchronous reads.
fileevent $sid readable {
if {![catch {read $sid} val} {
binary scan $val H* data
# fileevent is called even though there is no data, so check for
# valid string
if {[string length $data] > 0} {
#do something with your data
#
}
}
#otherwise for synchronous sends and receives try
puts -nonewline $sid [binary format H* $dataout]
# flush the buffer so you know it sent
flush $sid
if {![catch {read $sid 1} val]} {
binary scan $val H* datain
}
With 8.0, you have fconfigure for setting baudrate, comport, and binary
mode. I'd like to see filevent work (better). I am also curious on how
to send a break from Tcl. I have found interference from internal dial
up modem cards when there shouldn't be. I might start by making sure
there is no hardware or software handshaking performed in the control
panel.
03/12/1999 11:09 - stanton - in 8.1, file events on serial I/O should be working
welch Closed ticket [218465ffff].
[History diff]2000-10-26 08:22:17
dgp Ticket [218465ffff]: 3 changes
[History diff]2001-04-03 06:39:59
Log in (anonymous is fine) to add a comment.