Firstly it should be pointed out this is a very new thing to me, so its likely I'm doing something silly and you'll be able to correct me in 2 seconds, great! Please just bear with me and assume I'm an idiot!
Starting with the bit that works as background information:
I have a raspberry pi set up which is successfully detecting hall sensor feedback. This works fine, so its just the bit of code of what to do when a train is detected I'm having problems with.
For the sake of testing I've removed the below from the working sensor code, so I'm able to run it separately on demand, so its not a sensor fault. I have also added a new sensor and left its name alone for now, as I at one point thought my naming could be at fault.
Using the starting point of https://wiki.rocrail.net/doku.php?id=ro ... ripting-en I have successfully got a code that starts track power, what I then did was tried to modify that to change sensor status instead. I have ended up with the following code:
Code: Select all
#!/usr/bin/python from socket import * # Subroutine for adding the XML-Header and send it to the server def sendMsg( s, xmlType, xmlMsg ): s.send("<xmlh><xml size=\"%d\" name=\"%s\"/></xmlh>%s" %(len(xmlMsg), xmlType, xmlMsg)) # Create the server connection s = socket(AF_INET, SOCK_STREAM) s.connect(('localhost', 8051)) # Compose the power on command and send it rrMsg = "<fb id='fb1' state=\"true\"/>" sendMsg( s, "fb", rrMsg ) # Close server connection s.close()
Am I missing something?
Any help much appreciated, and apologies is its a very stupid mistake
Thanks in advance,