RocRail scripting, primi passi (e problemi :) )
Inviato: martedì 29 agosto 2017, 7:24
Salve,
ho provato a seguire le prime istruzioni per lanciare uno script che dia alimentazione ai binari, ovvero l'esempio riportato qui http://wiki.rocrail.net/doku.php?id...scripting-en
#!/usr/bin/python
# Rocrail XML script example: Power ON.
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 = "<sys cmd=\"go\"/>"
sendMsg( s, "sys", rrMsg )
# Close server connection
s.close()
ma lo script non ha effetto. Il problema sembra essere il messaggio di comando "<sys cmd=\"go\"/>" perché se ad esso sostituisco un altro comando come la modalità automatica, ovvero <auto cmd=\"on\"/>, lo script funziona.
Il log del server riporta:
20170829.000737.372 r9999I cmdrB720 OClntCon 0254 cmdReader started for:127.0.0.1.
20170829.000737.372 r9999I infwB720 OClntCon 0108 infoWriter started for:127.0.0.1.
20170829.000738.373 r9999c fbreader OMCS2 0272 System GO
20170829.000738.374 r9999I cmdrB720 OModel 2465 informing 3 listeners of a system event name=sys val=go...
20170829.000738.385 r9999I cmdrB720 OSocket 0676 Other side has closed connection.
20170829.000738.385 r9999I cmdrB720 OClntCon 0391 Server ended.
20170829.000738.392 r9999I infwB720 OClntCon 0176 InfoService ended.
Dove sbaglio ?
grazie e saluti
ho provato a seguire le prime istruzioni per lanciare uno script che dia alimentazione ai binari, ovvero l'esempio riportato qui http://wiki.rocrail.net/doku.php?id...scripting-en
#!/usr/bin/python
# Rocrail XML script example: Power ON.
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 = "<sys cmd=\"go\"/>"
sendMsg( s, "sys", rrMsg )
# Close server connection
s.close()
ma lo script non ha effetto. Il problema sembra essere il messaggio di comando "<sys cmd=\"go\"/>" perché se ad esso sostituisco un altro comando come la modalità automatica, ovvero <auto cmd=\"on\"/>, lo script funziona.
Il log del server riporta:
20170829.000737.372 r9999I cmdrB720 OClntCon 0254 cmdReader started for:127.0.0.1.
20170829.000737.372 r9999I infwB720 OClntCon 0108 infoWriter started for:127.0.0.1.
20170829.000738.373 r9999c fbreader OMCS2 0272 System GO
20170829.000738.374 r9999I cmdrB720 OModel 2465 informing 3 listeners of a system event name=sys val=go...
20170829.000738.385 r9999I cmdrB720 OSocket 0676 Other side has closed connection.
20170829.000738.385 r9999I cmdrB720 OClntCon 0391 Server ended.
20170829.000738.392 r9999I infwB720 OClntCon 0176 InfoService ended.
Dove sbaglio ?
grazie e saluti