I was writing a python script to collect data remotely from plc through URL and store those data into my drive in CSV format. I have used the urllib3 module to collect data from the remote device. The problem is whenever I am trying to decode those raw data which is coming from the remote device through URL using this code int(b.decode(("utf-8").spilt('RVI')[1].spilt('*')[0], 16)
the compiler shows a syntax error, but I didn't find anything wrong in this code. I am new to Python as well as Raspberry Pi, please help me to sort out the error.
My full code is
import os
import time
from time import sleep
import datetime
import urllib3
def readVoltage():
http = urllib3.PoolManager()
responce = http.request('GET', 'http://northam.ddns.net:9080?HOSTLINK/RVIY*')
responce1 = http.request('GET', 'http://northam.ddns.net:9080/HOSTLINK/RVIA*')
responce2 = http.request('GET', 'http://northam.ddns.net:9080/HOSTLINK/RVIB*')
a, b, c = responce.data, responce1.data, responce2.data
m = int(a.decode(("utf-8").spilt('RVI')[1].spilt('*')[0], 16)
n = int(b.decode(("utf-8").spilt('RVI')[1].spilt('*')[0], 16)
o = int(c.decode(("utf-8").spilt('RVI')[1].spilt('*')[0], 16)
return m, n, o
def write(volt1, volt2, volt3):
file.write(datetime.now().strftime("%Y-%m-%d %H:%M:%S")+","+str(volt1)+","+str(volt2)+","+str(volt3)+"\n")
return
file = open("/home/oztron/Documents/datalog.csv", "a")
if os.stat("/home/oztron/Documents/datalog.csv").st_size == 0:
file.write("Time, volt1, volt2, volt3\n")
while True:
p, q, r = readVoltage()
write(p, q, r)
file.flush()
time.sleep(2)
The error is
File "test.py", line 15
n = int(b.decode(("utf-8").spilt('RVI')[1].spilt('*')[0], 16)
^
SyntaxError: invalid syntax