[Serial port] Ignore BREAK condition on read
Closed / Invalidea53aa804d4ef48bddf9e20869231d7017331b74Created 10 years agoUpdated 41 days ago
Descriptionplain2016-06-16 08:56:37
Is it possible to ignore "BREAK" condition when reading a serial port channel ? I'm using a RS-485 line and disabling my HALF-CTRL pin causes a BREAK condition but I would like to be able to read my buffer channel anyway. Below, a capture of a Tkcon console of what I'm talking about ******************************************** ******************************************** (xxxxxx) 197 % fconfigure $rh -queue 30 0 (xxxxxx) 197 % fconfigure $rh -queue 33 0 (xxxxxx) 197 % fconfigure $rh -lasterror (xxxxxx) 198 % read $rh error reading "file3de1490": I/O error (xxxxxx) 199 % fconfigure $rh -lasterror BREAK ********************************************* ********************************************* Thanks for your support!
ggros Ticket [ea53aa804d]: 3 changes
[History diff]2016-06-16 10:13:14
serhiy.storchakawiki2026-10-14 18:48:19
On Windows a serial error such as BREAK is reported by one [read] as an I/O error, with the details in fconfigure $chan -lasterror, and then cleared; the data in the queue is not discarded. So you can catch the error and read again:
if {[catch {read $rh} data] && "BREAK" in [fconfigure $rh -lasterror]} {
set data [read $rh]
}
serhiy.storchaka Ticket [ea53aa804d]: 3 changes
[History diff]2026-10-22 17:19:26
Log in (anonymous is fine) to add a comment.