knrdl/optotron

Response exception on alternating function calls

Closed this issue · 2 comments

When trying different functions in sequence, occasionally the response will be detected as invalid even though it seems to be correct.
Here I alternate get_lamp_hours() with set_input_soure()

I added print('raw: ' + txt), to see the actual response.

optotron

As a quick fix, calling flushInput() before writing to the serial seems to prevent this. So something might be sticking around in the buffer.

knrdl commented

Hi, first of all thanks for your feedback ... but I cannot reproduce the problem:

>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi'); optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')
>>> optotron.get_lamp_hours()
1247
>>> optotron.get_lamp_hours()
1247
>>> optotron.get_lamp_hours()
1247
>>> optotron.get_lamp_hours()
1247
>>> optotron.get_lamp_hours()
1247
>>> optotron.get_lamp_hours()
1247
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')
>>> optotron.set_input_source('hdmi')

Anyway flushing buffers sounds like a good thing to do for me :)
If your solution works, please open a PR!

Looks like the issue was caused by the cheap usb to serial adapter I used.

I no longer have access to the projector, so I won't make a pull request because I can't do any further testing.