Hey,
I recently update my robot Polyscope from 3.x to 5.x and now my python secondary monitor parser (which is based on an old example i got from this website) raising an exception every few packets:
raise ParsingException("Error, length of data smaller (%s) than declared (%s)" % (len(data), psize))
i tried to figure out what have has changed in the protocol but the changes i made didnt solve the problem.
this is the parse function:
def parse_status(self, data):
allData = {}
while data:
psize, ptype, pdata, data = self.analyze_header(data)
if ptype == 16:
allData["SecondaryClientData"] = self._get_data(pdata, "!iB", ("size", "type"))
data = (pdata + data)[5:] # This is the total size so we resend data to parser
elif ptype == 0:
allData["RobotModeData"] = self._get_data(pdata, "!iBQ???????Bd", (
"size", "type", "timestamp", "isRobotConnected", "isRealRobotEnabled", "isPowerOnRobot", "isEmergencyStopped", "isSecurityStopped", "isProgramRunning", "isProgramPaused", "robotMode",
"speedFraction"))
elif ptype == 1, 4, 5, 6, 3, 2, 9, 10, 8, 7, 20:
...
return allData
the header analyser:
def analyze_header(self, data):
"""
read first 5 bytes and return complete packet
"""
if len(data) < 5:
raise ParsingException("Packet size %s smaller than header size (5 bytes)" % len(data))
else:
psize, ptype = struct.unpack("!iB", data[0:5])
if psize < 5:
raise ParsingException("Error, declared length of data smaller than its own header(5): ", psize)
elif psize > len(data):
raise ParsingException("Error, length of data smaller (%s) than declared (%s)" % (len(data), psize))
return psize, ptype, data[:psize], data[psize:]
If anyone can tell what have changed so i would prevent this exception.
thanks!