Version 2 of serial ports on Windows

Updated 2002-01-30 15:56:03

Serial Ports on Windows

I created this page in case some people may have some questions or answers about using a serial port on Windows.

I just tried to communicate with com1 on a Windows 2000 machine. For some reason I could not recieve any data using the following commands in Wish.

   % proc rd_chid {chid} {
   set msg [gets $chid]
   puts $msg
   }
   % set com [open com1: r+]
   % fconfigure -mode 9600,n,8,1 -blocking 0 -translation auto -buffering line
   % fileevent $com readable [list rd_chid $com]

However, I was able to recieve data by putting those last 3 lines into its' own procedure...

   % proc rd_chid {chid} {
   set msg [gets $chid]
   puts $msg
   }
   % proc open_com {} {
   global com
   set com [open com1: r+]
   fconfigure -mode 9600,n,8,1 -blocking 0 -translation auto -buffering line
   fileevent $com readable [list rd_chid $com]
   }
   % open_com
   # lots of data comes streaming :)
   % close $com

jg


In the belief that Tcl will benefit greatly from improved serial-port programmability, I recommend that the Universal Serial Port Python [L1 ] extension will interest many readers. I think it offers much from which we can learn.


I understand that Rolf Schroedter has written a small extension called "tkWinCom" that adds much functionality to the serial port abilities of Tcl for Windows...search Google Groups in the newsgroup "comp.lang.tcl" for more info.

Larry Gagnon