-
Notifications
You must be signed in to change notification settings - Fork 130
Items Serial_Item
ggodart edited this page Jan 6, 2021
·
2 revisions
See original
$garage_movement = new Serial_Item('XI2');
speak "Someone is in the garage" if state_now $garage_movement;
$tnc_output = new Serial_Item ('CONV', 'converse', 'serial1');
$tnc_output -> add ('?WX?', 'wxquery');
set $tnc_output 'converse';
set $tnc_output "EMAIL :userid\@computers.com Test E-Mail - $CurrentTemp deg.{0";
my $serial_data = said $tnc_output;
$v_tnc_close = new Voice_Cmd("close the tnc serial port");
stop $tnc_output if said $v_tnc_close;
start $tnc_output if $New_Minute and is_stopped $tnc_output
and is_available $tnc_output;
$serial_tom10port = new Serial_Item(undef, undef, 'serial_tom10');
$serial_tom10port -> set_casesensitive; # TOM10 needs lowercase commands
Used to read or write serial port data
# serial#_datatype=raw For raw comms
serial1_datatype=raw
Method | Description |
---|---|
new('data_stream', 'state_name', 'serial_port') |
|
stop |
Stops using the serial port for this item. That allows other programs to share the port (e.g. let MisterHouse use the modem for caller ID, but turn that function off when using the modem to call out). |
set_dtr |
Sets/resets the DTR line |
set_rcs |
Sets/resets the RCS line. For example:set_dtr $port 1;'<br/> set_rcs $port 0;` |
Method | Description |
---|---|
add('data_stream', 'state_name') |
If 'serial_port' is not specified, then: -For outgoing X10 data, the first valid port from this list is used; cm11, cm17, homevision, homebase, Weeder, serial1, serial2, ... -For other outgoing data, the first valid port from this list is used; Weeder, serial1, serial2, ...For incoming data, the 'serial_port' parameter is not important, as data from the cm11, homebase, and Weeder ports is processed in the same way.<br>For the generic ports (serial1, serial2, ...), incoming data is processed only by user specified 'said' methods. |
state |
Returns the last state that was received or sent |
state_now |
Returns the state that was received or sent in the current pass. Note that the a set will trigger a state_now on the next pass. |
state_log |
Returns a list array of the last max_state_log_entries (mh.ini parameter) time_date stamped states. |
set |
Sets the item to the specified state. If the specified state has not been defined with 'new' or 'add', the state data is sent. Otherwise the data_stream associated with that state is sent. |
set_data |
Use this to put data back into the serial read buffer. Typically used when you have processed only some of the serial data, and you want to put the rest back because it is incomplete. Here is an example: if (my $data = said $wx200_port) { my $remainder = &read_wx200($data, \%weather); set_data $wx200_port $remainder if $remainder; >br/> }
|
said |
Returns a data record received by the port. Characters are spooled into one record until a \n (newline) is received. Only then does 'said $item' become valid, and it is reset as soon as the said method is executed.Note: If you want to process binary serial data, specify serial#_datatype=raw in the mh.ini file. This will cause said to return any data read immediately, rather than buffering up data until a newline is read. |
start |
Re-starts the serial port after a stop command or after starting with the port already in use. |
is_stopped |
True if the port is not active |
is_available |
True if the port is not in used by another program |
set_icon |
Point to the icon member you want the web interface to use. See the 'Customizing the web interface' section of this document for details. |
set_info |
Adds additional information. This will show up as a popup window on the web interface, when the mouse hovers over the command text. Will show up as a popup window on the web interface, when the mouse hovers over the command text. |
See mh/code/examples/serial_port_examples.pl
for more Serial_Item
examples.