-
Notifications
You must be signed in to change notification settings - Fork 131
Serial device access
Lieven Hollevoet edited this page Sep 22, 2014
·
1 revision
One of the things Misterhouse is good at doing is accessing devices connected to a serial port on the Misterhouse server. This is due to the module **Device::SerialPort** (Linux) or **Win32::SerialPort** (Windows)functions.
Most of the serial communicaton in Misterhouse is built upon Serial_Item. Here is how to set up a very basic Serial_Item (provided on the Misterhouse list by Steve Switzer)
- 1: Create a serial port. Add to mh.private.ini:
- 2: Create a Serial_Item in user code:
NOTE: In this example, when 'bbbb' is received on the serial port, $myitem is set to 'state2'. Additionally, if you set $myitem to 'state2', it'll send 'bbbb' to the serial port.
- 3: Either set states or trigger on item set:
- Every minute, send 'dddd' to the serial port
if($state = state_now $myitem) {
- This triggers on any state change, with the state in $state variable
- This triggers only when the state is 'state3'
You can also use state_changed instead of state_now, then if the item is set to state3 twice in a row, it'll only trigger once.
- user code