Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Reading keyboard without waiting for [return]

Posted by enquirer (enquirer), 20 September 2004
How do you get the program to check an input for being available without waiting for an input - I have used the command you used for the keypad input:

set rsport [open /dev/ttyUSB0 w+]
fconfigure $rsport -blocking 1 -buffering none
set bytin [read $rsport 1]

but it waits for an input before continuing so if there is no input, the  'exit' button can't be used and the program locks. (ctl-C to exit is not  acceptable! especially if it is a wish program) also I am not waiting for a  CR before processing the data.

Posted by admin (Graham Ellis), 20 September 2004
There's an issue here with information getting through the operating system.  In most circumstances, you'll NOT wish to read the keyboard until a new line is entered;  if the user enters 2-3-backspace-4-return you'll only want to get 2-4 into your Tcl program, so that's the way it works.   The operating system figures out that one the user presses [c/r], that's the equivalent of confirming to an "ru sure" and proceeds.

The easiest solution is to use Expect - an extension to Tcl and Tcl/Tk which does get the raw data in.  However, I know this might not be the ideal solution for this particular poster so I'll have a look at other ideas too and follow up further.

Edit - additional follow up:

Certainly if your change -buffering 1 to - buffering 0 it'll be a step in the right direction; see my other post just made about similar control on the RS232 ports.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho