No announcement yet.

IP and Serial Plugin

  • Filter
  • Time
  • Show
Clear All
new posts

    IP and Serial Plugin

    This is a new plugin that supersedes my earlier TCP Trigger (

    The plugin can send and receive messages, or commands over TCP, UDP or serial. Like the previous plugin, you can configure events that trigger on receipt of strings. You can also send predefined command strings or the status/value of a homeseer device to tcp, udp or serial targets.

    At the heart of the plugin is the concept of a connection.
    Click image for larger version

Name:	ip1.jpg
Views:	1
Size:	104.4 KB
ID:	1204861

    A connection can be of type TCP, UDP, Serial or HTTP (HTTP is still experimental at the moment). TCP and UDP connections can be defined as either Hosts or Clients. A Host connection will wait for a remote device to connect to it and a client connection will go ahead and establish a session to a remote device. In the case of a TCP or serial connection, once a session is established, that connection can be used to both receive and send data.

    The address field is used with TCP and UCP connections to define either a client connection's target ip address, or in the case of a host connection, a range of remote addresses that the connection will accept incoming requests from. For serial connections this is the number of the COM port.

    You can also define a connection as a proxy. This allows you to have all data arriving on one connection be sent to another connection, possibly as a different type. As an example, I have a tcp host connection that receives data from iRule running on an iPad and forwards/proxies it to a Samsung TV over a serial connection.

    Commands can be predefined and used in Events as Actions.
    Click image for larger version

Name:	ip2.jpg
Views:	1
Size:	164.2 KB
ID:	1204862

    Serial parameters are setup here:
    Click image for larger version

Name:	ip3.jpg
Views:	1
Size:	75.2 KB
ID:	1204863

    My main driver for creating this plugin is integration with iRule but I've tried to keep things generic so that it can work with as many other things as possible. For iRule use, I particularly wanted to support what iRule calls "Feedbacks." I wanted to able to see in real time the status of my Homeseer devices in the iRule app on my iPad. Using the plugin I can have a slider in iRule that controls the brightness of a light for instance. The slider also gets updated if the light is controlled directly, or from another source.

    I think the best way to figure out the plugin is to give it a try. Inevitably there will be a few bugs and wrinkles. Please post your findings, comments and questions and I will try my best to help.


    8/23/2012 - AM
    New update includes support for persistent/non-persistent tcp clients and "pass-thru" scripts.

    8/23/2012 - PM
    Second update of the day. Fixes bug reported by jayman13 reading the ini file at startup and adds a "Threshold" option to the serial configuration.

    8/24/2012 - AM
    Change to allow larger [Commands] section in ini file. Modified TCP close function for non-persistent connections.

    8/24/2012 - PM
    Non-persistent TCP clients no longer instantiate a new receiver class.

    Fix for plugin initialization when [Commands] is empty.

    Added additional check for TcpClient is connected before sending data. Moved non-persistent TCP client stop routine further down the code.

    Triggers match using encoding types, not just plain text
    Persistent TCP Clients will restart if connection drops, initial attempt immediate, subsequent attempt
    determined by Watchdog timer, configurable, defaults to 10 seconds
    Scripting Access:
    Send(Command, Connection)
    Send("stuff", Encoding, Connection)
    Persistent TcpClient connect/disconnect events

    Fixed bug when reading commands containing an '=' symbol from the ini file.
    Last edited by drule; December 11, 2012, 06:09 AM.

    HS3 version of IP/Serial Plugin now posted

    With drule's go-ahead I have posted the HS3 version of his IP/Serial plugin

    The plugin can be found here and the discussion thread here