I have a Pyhon 3 application using a Maxbotix Ultrasonic Rangefinder (HR-USB-EZ1).
Once in a great while I'll get the following error in my debug log and the script crashes.
Very infrequently I get trashy data and have added some cleanup code. I'm still getting the above error.
I've avoided adding debug code that records the data as it would generate a lot of text for an error that seems to happen once every 4-5 days.
From what I know I shouldn't get the error I'm getting, but apparently I'm missing something.
clipped code:
I keep looking at this and I just don't see it. Anyone have some ideas?
Once in a great while I'll get the following error in my debug log and the script crashes.
Error:ValueError: invalid literal for int() with base 10: ''
The rangefinder returns data as a 'R + 4 numbers +'+ space + carriageReturn, eg 'R1234' <CR>. Very infrequently I get trashy data and have added some cleanup code. I'm still getting the above error.
I've avoided adding debug code that records the data as it would generate a lot of text for an error that seems to happen once every 4-5 days.
From what I know I shouldn't get the error I'm getting, but apparently I'm missing something.
clipped code:
valid="1234567890" some stuff (flushing rangefinder, read RF data, etc) data2=self.RF.readline() # read the rangefinder Rnge2 = str(data2)[str(data2).index('R')+1:str(data2).index('R')+5] #strips down to 4 numbers Rnge2 = Rnge2.replace("'","") #removes any single quotes while True: if not set(Rnge2).issubset(valid): #check for invalid chars - S/B only numerics Rnge = '9000' break if Rnge2 == '' : #issubset won't catch this Rnge = '9000' break if int(Rnge2) > 1000 : #I get the error here Rnge = '9000'I was thinking of modifying
i[b]f Rnge2 =='':to
if Rnge2 == '' or Rnge2==' ':but the issubset statement should filter out spaces.
I keep looking at this and I just don't see it. Anyone have some ideas?