The Local Area Network library sends RCP commands over TCP/IP connections.
The Loco or Decoder must provide a WiFi server socket to which this library can connect.
The commands are sent as XML strings using the Rocrail Client Protocol without the XML-Header.
The Loco or Decoder may also send events back in the same format.
This library makes it possible to use any kind of computer to act as a decoder.
Unique ID which should be set on the Interface Tab of the WiFi Loco/Decoder.
The default TCP/IP port used to connect to the WiFi Loco/Decoder.
Number of connection retries before give up.
If set to zero the retries will continue endlessly.
Number of seconds between the connection retries.
The off delay timer in ms for reported RFID's by the WiFi Loco/Decoder.
The LAN library becomes at startup the decoder list to initialise connections.
This option is mandatory for Switch, Output and/or Signal objects.
The TCP/IP address, or hostname, must be set in the Code field.
The TCP/IP address, or hostname, must be set in the Code field.
The Decoder ID must be set.
The Code format may contain a port number in the usual format:
192.168.100.127:4712
If no port is set the default Port, which has been set in the LAN-Setup, will be used.
#!/usr/bin/python import time from socket import * myHost = '' myPort = 4711 s = socket(AF_INET, SOCK_STREAM) # create a TCP socket s.bind((myHost, myPort)) # bind it to the server s.listen(5) # allow 5 simultaneously # pending connections while 1: # wait for next client to connect connection, address = s.accept() while 1: data = connection.recv(1024) # receive up to 1K byte if data: print data connection.send('<fb id="102.567.22.46" state="true" fbtype="5"/>\n') # send RFID sensor event which was just read time.sleep(5) connection.close() # close socket