event driven serial port handlers
Dirk Koopman
djk at tobit.co.uk
Wed May 9 12:46:13 BST 2012
I am on the horns of a small dilemma. I am writing a small driver for a
serially connected weather station that *has* to be event driven
(whether that be by boring IO::Select or some other framework). It
happens that sometimes the devices communicates in ascii and at other
times in binary. Like many devices of its kind, it is pretty unreliable
about being connected or alive or indeed generally knowing what state
its knickers are in, necessitating much prodding to wakeup/reset/just
talk to me you b****r.
I am trying to avoid just writing a standalone C program to handle it.
If I do it in perl (the rest of the system will be in perl), there is no
option, IMO, but to have a state machine. That means ultimately
processing characters created out of buffers of data returned by the
random buffers of data returned from non-blocking sysread()s.
My question is: is this going to be grossly inefficient bearing in mind
that I want to do this in a process that also serves the data in some
HTML5ish that allows me and others go "oo-ah" at the lovely webby guages
and graphs?
Dirk
PS Please assume that I have had a really good look at CPAN w.r.t the
various weather station modules there, especially the three that purport
to "handle" the one I have. None of them will handle the sorts of
outages that happen in the real world (around here at any rate).
More information about the london.pm
mailing list