Since version 0.0.1.26, IO Ports support has been introduced. Support for serial port is introduced in 0.0.1.28.
The configuration of io ports is located in the services section. Each IO port has an identifier that can be used in conditions and actions to send and receive data over it.
Here's an example of ioports configuration:
<ioports> <ioport id="irtrans" host="192.168.0.18" port="21000" rxport="21001" /> <ioport id="test-tcpcli" type="tcp" host="127.0.0.1" port="1030" /> <ioport id="test-serial" type="serial" dev="/dev/ttyS0" speed="9600" framing="8E1" /> </ioports>
The supported parameters are:
The other parameters are type-dependent.
For port type udp:
For port type tcp:
For port type serial:
For the moment, the TCP io port can only connect as a client to external TCP servers. It's not possible for linknx to be the server allowing TCP clients to connect to it.
The message delimitation is also not implemented, so the received data is transferred to conditions chunk-by-chunk as it is received. This can make a difference in case of big messages if they are fragmented in smaller parts. In future release, the massage delimitation (based on delimiter characters or timeouts) will be added.
The following attributes can be used for ioport-conditions.
These are the attributes for action type="ioport-tx".
Here's an example of rule that receives a message corresponding to an IR code from IRtrans infrared receiver/transmitter and send a sequence of ir commands to another device (use the red teletext button to power-on dvd player and play a dvd):
<rule id="start-dvd"> <condition type="ioport-rx" expected="samsung,red" ioport="irtrans" trigger="true"/> <actionlist> <action type="ioport-tx" ioport="irtrans" data="snd dvd,power" /> <action type="ioport-tx" ioport="irtrans" data="snd dvd,menu" delay="5"/> <action type="ioport-tx" ioport="irtrans" data="snd dvd,enter" delay="7"/> </actionlist> </rule>
There is currently a limitation on ioport-rx conditions. Any message received and starting with the value of parameter expected will trigger the condition. So in this case if the irtrans could send a message like "samsung,redisplay", it would also trigger the rule.
Wiki: Action's_syntax
Wiki: Lua_Scripting
Wiki: Services_section