Problem with write to serial port 
Author Message
 Problem with write to serial port

Hello,

i have the following problem:

env: SuSE Linux 8.2 with TCL/TK8.4.4

I have a server listening on a socket using the fileevent. After client
connection the server opens several serial ports with "r+" . The channels
are configure with "-blocking false" and "-buffering line". Now i registered
for each channel/com port a fileevent readable. In the callback function all
characters received from the com port are send via socket to the client.
This works without any problems.

But i get a problem in the other direction. If the server should write(!!!)
to a serial port it is not working. No character is going out. The
puts/flush commands return without an error but the serial device hasn`t
received any character.

I tried to analyze the problem.

1. The problem occures only if the fileevents for the serial ports exist,
means in the following case writing to the serial line works:

set handle [open /dev/ttyS0 r+]
fconfigure $handle -blocking false -buffering line -mode ....
read $handle
puts $handle "foo"

2. but it does not work in this case:

set handle [open /dev/ttyS0 r+]
fconfigure $handle -blocking false -buffering line -mode ....
fileevent $handle readable [list  readLines $handle]
puts $handle "foo"
flush $handle

3. if i reconfigure the channel in blocking mode before writing it works
also with the registered fileevent

set handle [open /dev/ttyS0 r+]
fconfigure $handle -blocking false -buffering line -mode ....
fileevent $handle readable [list  readLines $handle]
fconfigure $handle -blocking true
puts $handle "foo"
flush $handle
fconfigure $handle -blocking false

I have no idea why this reconfiguration to blocking mode is needed. If i
check the situation with "strace -p PID" i can see "writes (handle-id,
"xxxx", nbr of bytes) in the trace in case 2 and in case 3. So i assume that
the Linux kernel is buffering here ?! Could somebody explain this ?

Kind regards,
Torsten



Sun, 14 May 2006 07:42:19 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Serial Port Write Problem

2. writing in binary to a serial port

3. Serial Port Writing with CDD 3 DOS

4. How do I read/write serial port?

5. Writing bytes out of Serial Port

6. During serial port communication (writing/transmission) is...

7. Serial Port Write

8. writing/reading from serial port

9. Serial port, flushes after write

10. Reading and writing individual bits on the serial port

11. Reading/writing to serial port w/ VISA in Labview

12. Serial PORT WRITE

 

 
Powered by phpBB® Forum Software