Skip to main content

Topics

This section allows you to view all Topics made by this member. Note that you can only see Topics made in areas you currently have access to.

Topics - Brink

1
USB Infrared Toy / [Solved]Can't properly close() device conn from transmit
I'm trying to debug my setup and I cannot find a way to properly close the serial connection to the device after entering the transmit mode (0x03). Even worse my device is completely lost and needs unplugging and re-plugging every time I try to close it.

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':
                    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.
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.

Cheers,

Erik

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01232272568session_write_close ( )...(null):0
20.01272404160ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01272404936Database_MySQL->query( ).../DatabaseHandler.php:119
40.05722543672Database_MySQL->error( ).../Db-mysql.class.php:273