Re: [PBML] Re: Com Port & Keyboard Access
- You need to use the select system call. This allows you to be
informed by the system when data is available on any number of file
descriptors. I don't know about the support on Windows (assuming
COM1 indicates a PC platform) and I've actually only used the select
call directly from C code, but it does work well.
Start looking with: perldoc -f select
You want the "select RBITS,WBITS,EBITS,TIMEOUT" one and not the
Rob Biedenharn http://agileconsultingllc.com
On Oct 12, 2006, at 9:44 AM, dvx28 wrote:
> Sorry, the formatting seems to have been stripped out...
> open com port
> loop forever
> ....try to get data from com port
> ........if there is data, process it...
> ....try to get a key from the keyboard
> ........if there is a keypress, break out of the loop...
> end loop
> close com
> --- In firstname.lastname@example.org, "dvx28" <dvx28@...> wrote:
>> I'm looking to write a utility that will read an RS-232 Serial port
>> (i.e. COM1), do some processing on the data and print it to the
>> console. Hitting any key on the keyboard will gracefully exit the
>> It looks like, and I could be wrong, that the "built in" stuff in
>> can simply read a line or get a character - but are these calls
>> blocking? If so, how would I be able to do what I need?
>> open com port
>> loop forever
>> try to get data from com port
>> if there is data, process it...
>> try to get a key from the keyboard
>> if there is a keypress, break out of the loop...
>> end loop
>> close com
>> Perhaps a CPAN library? I'm not terribly sure on this. Thanks.