example_interface.pm |
Here is an example of reading/writing using this object:
$test_example1 = new example_interface('string_on', ON);
$test_example1 ->add ('string_off', OFF);
print "Example 1 data received: $state\n" if $state = state_now $test_example1;
set $test_example1 OFF if new_second 5;
Here is another example
$interface = new example_interface;
$interface ->add('out123', 'request_status');
$interface ->add('in123', 'door_open');
set $interface 'request_staus' if $New_Second;
speak 'Door just opened' if 'door_open' eq state_now $interface;
You could also query the incoming serial data directly:
if (my $data = said $interface) {
print_log "Data from interface: $data";
}
Methods (sub) 'startup' or 'serial_startup' are automatically called by mh on startup.
Serial_Item
example_interface_module = example_interface
example_interface_port = COM9
UNK
NONE
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.
example_interface.pm |