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!

Problem opening/recognizing/using serial port

Status
Not open for further replies.

jschna1

Technical User
Jul 17, 2007
3
US
So I need to communicate with a serial port using tcl/tk 8.3 but am having a problem: when I try to send data down it, nothing happens. Also, when I try to use fconfigure to set the mode of the serial connection, I get an error that -mode is not a valid argument, as if the program does not recognize it as a serial port. I am using a machine that runs on Red Hat Linux.

This is the code I'm using:

-------------------------------
set port [open /dev/ttyS4 w+]
#I also tried options w and r+ with no better results

fconfigure $port -mode "9600,n,8,1"
#didn't work so I remove it to try writing to the port as is...

puts $port "pos=1\n" #output command to port
-------------------------------

That command should set the device in position one, but the device does not respond at all. Also, in this way when I try to read from the port:

set myData [read $port 1] ## Just read 1 char.

The program just freezes. Is there anything I'm doing wrong?
 
The difference in theirs is they use RDWR instead of the w+/r+/etc. I tried it to make sure I hadn't before and alas, the same problems. Doesn't send data and freezes when trying to read it.
 
Are you sure the problem is in Tcl? That is, is the port actually active?

_________________
Bob Rashkin
 
Yes the port is active; using minicom I can communicate with it just fine.
 
I'm afraid I can't really help. I've done a little serial port comm but only on Windows/DOS. There may be a problem with the LINUX Tcl, but I don't know what it might be. That is, I can't see that you're doing anything wrong. You might try posing your question on the ActiveState listserv:

ActiveTcl@listserv.ActiveState.com

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top