Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f1b8046d66e7fce4b48b36e91adbfafc36cc52a1
Ticket: 218465ffffffffffffffffffffffffffffffffff
serial ports don't seem to work
User & Date: nobody on 2000-10-26 01:00:47
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    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
    
    
    
  4. foundin changed to: "obsolete: 8.0p2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "62. (unused)"
  10. title changed to: "serial ports don't seem to work"
  11. type changed to: "Bug"