Support
Wiki Documentation
Support Forum
Mobile
- andRoc Android
- Rocweb Browser
- WIO-Control ESP32
- Rocview Tablet
DIY
User
Wiki writer
Special
Legal
Support
Wiki Documentation
Support Forum
Mobile
DIY
User
Wiki writer
Special
Legal
L'unica cosa nuova dello scripting è il fatto che ora è documentato; lo scripting Rocrail è sempre stato disponibile dall'inizio del progetto.
Sono necessari solo pochi passi per eseguire uno script personale. Le pagine seguenti forniscono le informazioni necessarie:
E' anche possibile attivare lo script manualmente dalla linea comando o tramite un'altre applicazione.
Un esempio in Phyton per dare alimentazione:
#!/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()
Basta solo copiare e incollare l'esempio in un editor di testi e salvarlo in un file con estensione ".py".
(Linux: aggiungere il bit di esecuzione con "chmod +x myscript.py
".)
Gli errori della chiusura della connessione sono normali e possono essere ignorati.
20110515.150347.205 r9999I cconmngr OClntCon 0354 client connect count: 18 20110515.150347.206 r9999I cmdrB730 OClntCon 0209 cmdReader started for:127.0.0.1. 20110515.150347.206 r9999I infwB730 OClntCon 0104 infoWriter started for:127.0.0.1. 20110515.150348.206 r9999c cmdrB730 OVirtual 0324 Power ON 20110515.150348.207 r9999I cmdrB730 OControl 0826 State event from=vcs-1 20110515.150348.207 r9999I cmdrB730 OModel 1704 informing 1 listeners of a system event... (Ignore the errors:) 20110515.150348.209 r8030E infwB730 OSocket 0626 send() failed [32] [Broken pipe] 20110515.150348.209 r9999E infwB730 OSocket 0630 Connection broken! 20110515.150348.217 r9999E cmdrB730 OSocket 0685 Socket 0x00000000 error 88 20110515.150348.217 r9999I cmdrB730 OClntCon 0322 Server ended. 20110515.150348.220 r9999I infwB730 OClntCon 0172 InfoService ended.