$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\ 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




new('data_stream', 'state_name', 'serial_port')

Stops using the serial port for this item. That allows other programs to share the port (e.g. let mh use the modem for caller ID, but turn that function off when using the modem to call out).


Sets/resets the DTR line


Sets/resets the RCS line. For example:

   set_dtr $port 1;
   set_rcs $port 0;


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' parm is not important, as data from the cm11, homebase, and Weeder ports is processed in the same way.

For the generic ports (serial1, serial2, ...), incoming data is processed only by user specified 'said' methods.


Returns the last state that was received or sent


Returns the state that was received or sent in the current pass. Note that the a 'set' will trigger a state_now one the next pass.


Returns a list array of the last max_state_log_entries (mh.ini parm) time_date stamped states.


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.


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;

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.


Re-starts the serial port after a stop command or after starting with the port already in use.


True if the port is not active


True if the port is not in used by another program


Point to the icon member you want the web interface to use. See the 'Customizing the web interface' section of this document for details.


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/ for more Serial_Item examples.


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.