ClearOne Writing StreamNet User Manual
Page 48
![background image](/manuals/598163/48/background.png)
Writing StreamNet Device Drivers
C-2
All specifications subject to change without notification. All rights reserved. Copyright © 2007 NetStreams
Main +1 512.977-9393 / fax +1 512.977.9398 / Toll Free Technical Support +1 866-353-3496
3600 W. Parmer Lane, Suite 100; Austin, TX 78727 /
www.netstreams.com.
The example also uses two timer driven functions, pollResponse and queryStatus. The
first function, pollResponse, reads data from the serial port every second looking for
messages from the device. Depending on what the response is, the driver may turn the
indicatorState variable on or off (1 or 0 respectively). The second function queryStatus
will send a query to the device every 10 seconds to ensure that the driver stays in sync
with the device. These functions are created by calling the createTimer function.
--
-- The service itself is set up with a subNode for
each of the switchable
-- power supplies (switchable outlets and high power
outlets) and a subNode
-- for all power. Each zone responds to a #BUTTON
PRESS by sending out
-- the requested command and then issuing an
?OUTLETSTAT to find out which
-- outlets are on.
-- To allow the GUI to display an appropriate label
on the button, each
-- subNode also reports status in the common form:
--
--
--
-- We have to create our functions first then we can
use them below
-- function createButton( Name, Label, xmitString )
--
-- create a button node
--
function
createButton( Name, Label, xmitString )
-- create a subNode for each button
local
node = createSubNode(Name)
--
-- the serial to xmit string that dealer setup writes
for us
--
has escape sequences so that special characters
like newlines
--
and nulls can be embedded in the string to
send. Each escape