Loading ...
Sorry, an error occurred while loading the content.

45953Re: [mh] Simple Serial_Item example?

Expand Messages
  • Steve Switzer
    Oct 30, 2013
    • 0 Attachment
      Jim,
      This should get you started:

      #1: Create a serial port. Add to mh.private.ini:
      serialname_port=COMX
      serialname_baudrate=9600

      #2: Create a Serial_Item in user code:
      $myitem = new Serial_Item('aaaa', 'state1', 'serialname');
      $myitem -> add('bbbb', 'state2');
      $myitem -> add('cccc', 'state3');
      $myitem -> add('dddd', 'state4');

      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:
      if($New_Minute) {
      #Every minute, send 'dddd' to the serial port
      $myitem->set('state4');
      }

      if($state = state_now $myitem) {
      #This triggers on any state change, with the state in $state variable
      print_log('myitem is now: '.$state);
      }
      if('state3' = state_now $myitem) {
      #This triggers only when the state is 'state3'
      print_log('myitem was noticed at 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.

      Hope that helps!!

      Best regards,
      Steve Switzer

      ---
      Get world-class business I.T. services and a phone system with awesome features that won't challenge your budget!
      http://www.SwitzerBusinessSolutions.com

      On 10/30/2013 08:44 AM, JimMH wrote:
      > I am looking for a simple serial_item example to add for a new serial device
      > with just a few messages. The the weeder boards have similar commands and
      > responses but I am not sure how this differs from just using a serial item
      > directly - it seems there is some extra stuff set up for the weeder boards.
      > I have found snippets of code but not sure how it all fits together. I
      > don't know much perl and mostly just hack up example code.
      >
      >
      >
      > --
      > View this message in context: http://misterhouse.10964.n7.nabble.com/Simple-Serial-Item-example-tp18600.html
      > Sent from the Misterhouse - User mailing list archive at Nabble.com.
      >
      > ------------------------------------------------------------------------------
      > Android is increasing in popularity, but the open development platform that
      > developers love is also attractive to malware creators. Download this white
      > paper to learn more about secure code signing practices that can help keep
      > Android apps secure.
      > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
      > ________________________________________________________
      > To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365
      >


      ------------------------------------------------------------------------------
      Android is increasing in popularity, but the open development platform that
      developers love is also attractive to malware creators. Download this white
      paper to learn more about secure code signing practices that can help keep
      Android apps secure.
      http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
      ________________________________________________________
      To unsubscribe from this list, go to: http://sourceforge.net/mail/?group_id=1365
    • Show all 3 messages in this topic