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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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:

Code:
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 www.opentalk.org.uk 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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho