ctrl+C breaks in `iotile-gateway` (and possibly others) if you accidentally double book the bled112 dongle
- Dominant language
- Python
- Stars
- 14
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
I was running `iotile-gateway` configured with bled112 as an adapter from one terminal.
In another terminal, I attempted to invoke `virtual_device bled112 virtual_device.py` . Since it, by default, tries to use the first bled112 dongle on the system (I have two and can avoid this by specifying the usbdev). A HardwareError ultimately gets raised, but the unexpected part is this seems to render exiting cleanly impossible (I had to ctrl+x and then kill -9 the pid). It would be nice if we could not have the ctrl+c handler break.
```
Traceback (most recent call last):
File "/Users/mrunchey/gitrepos/coretools/transport_plugins/bled112/iotile_transport_bled112/async_packet.py", line 75, in ReaderThread
chunk = bytearray(filelike.read(remaining_length - len(remaining)))
File "/Users/mrunchey/ap_dev/lib/python3.6/site-packages/serial/serialposix.py", line 509, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
^CC-2019-01-30 11:25:33,702-main :23 In quit signal handler.
C-2019-01-30 11:25:33,702-main :26 Calling stop on gateway loop
C-2019-01-30 11:25:33,703-gateway :165 Stopping gateway
I-2019-01-30 11:25:33,703-gateway :166 Stopping gateway agents
C-2019-01-30 11:25:33,703-gateway :174 Stopping device adapters
E-2019-01-30 11:25:33,704-bled112_cmd:156 Error stopping scan for devices, error=2
E-2019-01-30 11:25:33,704-gateway :179 Error stopping device adapters
Traceback (most recent call last):
File "/Users/mrunchey/ap_dev/lib/python3.6/site-packages/iotilegateway/gateway.py", line 177, in _stop_loop
self.device_manager.stop()
File "/Users/mrunchey/ap_dev/lib/python3.6/site-packages/iotilegateway/device.py", line 71, in stop
adapter.stop_sync()
File "/Users/mrunchey/gitrepos/coretools/transport_plugins/bled112/iotile_transport_bled112/bled112.py", line 140, in stop_sync
self.stop_scan()
File "/Users/mrunchey/gitrepos/coretools/transport_plugins/bled112/iotile_transport_bled112/bled112.py", line 156, in stop_scan
self._command_task.sync_command(['_stop_scan'])
File "/Users/mrunchey/gitrepos/coretools/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py", line 745, in sync_command
raise HardwareError("Error executing synchronous command", command=cmd, return_value=retval)
iotile.core.exceptions.HardwareError: HardwareError: Error executing synchronous command
Additional Information:
command: ['_stop_scan']
return_value: {'reason': 'Could not stop scan for ble devices'}
C-2019-01-30 11:25:33,711-gateway :194 Stopping event loop and shutting down
C-2019-01-30 11:25:33,712-gateway :141 Done stopping loop
^[[A^CC-2019-01-30 11:25:38,275-main :23 In quit signal handler.
C-2019-01-30 11:25:38,275-main :26 Calling stop on gateway loop
^CC-2019-01-30 11:25:39,284-main :23 In quit signal handler.
C-2019-01-30 11:25:39,284-main :26 Calling stop on gateway loop
^CC-2019-01-30 11:25:40,311-main :23 In quit signal handler.
C-2019-01-30 11:25:40,311-main :26 Calling stop on gateway loop
^X^Z
[1]+ Stopped iotile-gateway --config=simple_gateway.conf
```
Contributor guide
Assessment
This issue has not been assessed yet.