1
USB Infrared Toy / [Solved]Can't properly close() device conn from transmit
In the following scenario my device is completely inaccessible until I unplug and replug it:
- open serial connection to IR toy
- enter transmit mode (sending 's' followed by 0x03)
- close serial connection <- takes around 10-15 seconds?!
- open serial connection <- throws errors on win7 64-bit and ubuntu 32-bit
I get the following error messages when I try to re-open the device:
win7 error:
Quote
...omitted...
File "C:Python27libsite-packagesserialserialwin32.py", line 177, in _reconfigurePort
raise ValueError("Cannot configure port, some setting was wrong. Original message: %s" % ctypes.WinError())
ValueError: Cannot configure port, some setting was wrong. Original message: [Error 31] A device attached to the system is not functioning.
Linux:
Quote
File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 175, in open
raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port /dev/ttyACM1: [Errno 5] Input/output error: '/dev/ttyACM1'
Searching the forums all I found was this thread but it does not seem to apply to me as I can record fine.
My setup is as follows:
- IRToy v2
- Tried firmware V222 and V220
- win7 64-bit & ubunt-32 (both native)
Any ideas? Or maybe I should ask the following as I have a feeling that this might be causing the problem:
- What is the correct way of exiting transmit mode?
I tried following the "Example transmit sequence" described HERE. But it hangs on reading the transmit byte count. I attached the sample python code for reproducibility.
Searching a bit further I made a SVN checkout (revision 1952) of the code. In here I found the following snippet in Firmware-main/main.c:
Code: [Select]
case 's':Just assuming the comment on irsService() is true I tried a few combinations of sending 0x00 at arbitrary times in the transmit sequence before closing the connection but without luck. I had a very short look in IRs.c to see how the transmit mode works but quickly decided this might be going to far and somebody else might have ran into this problem before.
OutByte = getc_cdc(); // now ok to remove byte from the USB buffer
mode = IR_S;
irsService(); // Fully self contained, does not return until exited via 0x00 command.
Cheers,
Erik