Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I have this piece of code to read from a serial port

sysread(COM,$buf,1); unpack("C*",$buf);

but it seems to never time out if there is nothing to read. Is there a non-blocking system equivalent (that's to say, not using the SerialPort module) to the above code - one where I can control the timeout value?

Replies are listed 'Best First'.
Re: non-blocking reading
by grep (Monsignor) on Feb 06, 2002 at 05:57 UTC
Use select function or adjust flag bits of mode parameter to sysopen - Re: non-blocking reading
by metadoktor (Hermit) on Feb 06, 2002 at 05:48 UTC
    You may be able to make use of select, or if that doesn't work for you then you may have to issue a special sysopen call with certain bits set in the mode parameter but alas I cannot remember what they are at the moment.

    UPDATE: I found this node which explains what the mode should be for the sysopen.

    metadoktor

    "The doktor is in."