Device::SerialPort perl

Linux for blind general discussion blinux-list at redhat.com
Tue Oct 31 19:43:29 UTC 2017


I am asking the Blinux list this question but it really belongs
on the perl beginners list which has died for some reason at my
location and isn't yet working again.

	I want to use an rs-232 port in several perl programs so
I used cpanp and installed the Device::SerialPort module and
tried running sample code to read lines of text from ports like
/dev/ttyS0 or /dev/ttyUSB1.

	I needed to use the lookfor function which will capture a
string of data until it encounters the pattern one has placed in
a parameter called are_match.  At that point, you have a string
within a variable that can be used in your program. The buffer is
cleared and ready for the next data ending in a matching pattern.

	I can't get it to work to save my soul and have been
looking for working examples of code.

	Has anybody gotten this to work and do you know of an
example of code that I can start from which should work?

	There is a test parameter called $port->input that echos
data which are being sent to the serial port and I have gotten
that to work but lookfor is not finding these days at my house.

	The perldoc for Device::SerialPort indicates that lookfor
will default to a newline or carriage return if you don't put
other patterns in so with nothing added, it should spit out a
line if it ends in newline or Return.

	Hopefully, I'll be back on the perl list soon, but no
telling when.

	I know my test code is defining the port right because
the test strings are perfect copies of the input data so that's
not what is wrong.  The lookfor function just rolls along and
never matches anything.

Thank you.

Martin McCormick




More information about the Blinux-list mailing list