{"action":"created","issue":{"url":"https://api.github.com/repos/pyserial/pyserial/issues/331","repository_url":"https://api.github.com/repos/pyserial/pyserial","labels_url":"https://api.github.com/repos/pyserial/pyserial/issues/331/labels{/name}","comments_url":"https://api.github.com/repos/pyserial/pyserial/issues/331/comments","events_url":"https://api.github.com/repos/pyserial/pyserial/issues/331/events","html_url":"https://github.com/pyserial/pyserial/issues/331","id":310198940,"number":331,"title":"Ungraceful handling of disconnected USB serial adapter","user":{"login":"liudr","id":4213617,"avatar_url":"https://avatars3.githubusercontent.com/u/4213617?v=4","gravatar_id":"","url":"https://api.github.com/users/liudr","html_url":"https://github.com/liudr","followers_url":"https://api.github.com/users/liudr/followers","following_url":"https://api.github.com/users/liudr/following{/other_user}","gists_url":"https://api.github.com/users/liudr/gists{/gist_id}","starred_url":"https://api.github.com/users/liudr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liudr/subscriptions","organizations_url":"https://api.github.com/users/liudr/orgs","repos_url":"https://api.github.com/users/liudr/repos","events_url":"https://api.github.com/users/liudr/events{/privacy}","received_events_url":"https://api.github.com/users/liudr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-31T00:46:08Z","updated_at":"2018-04-01T20:26:48Z","closed_at":null,"author_association":"NONE","body":"I have a recent distro of raspbian running on RPI0W. I have a USB hub and a serial adapter (FT232 based). I have the stock python 3.4 and an older pyserial 3.1.1.\r\nIf I disconnect the USB serial adapter while the serial port is open in python, I get an exception:\r\n\r\nserial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)\r\n\r\nIt seems ok to just have the script quit with the exception, reattach USB serial adapter, and restart the script. Nothing really goes wrong.\r\n\r\nBut, if I have a similar setup on a windows PC, it results in port not functioning until I shut down and restart my computer. I would see the port after reattaching the USB adapter but I can't get anything through the port. I can have exception handling to close the port when it detects the port is disconnected but that won't solve the problem. I think pyserial has some ungraceful handling of disconnected USB serial adapter that maybe a more recent linux kernel can cope with (closing processes, releasing locks on port etc.) but window can't handle this. I imagine that the port was locked by the process that raised the exception and isn't unlocked or unlockable once it exception is raised. I can do the disconnection/reconnection with a decent terminal program like MobaXterm and upon reattaching the USB serial adapter it would just work, not with python. You can exit python, disable/enable the port in device manager, uninstall/reinstall the device in there. Nothing works until you shut down and restart.\r\n\r\nThis happened to another person with a similar windows PC setup. I am wondering if anyone has seen this on their windows/Linux PC with the remote hope that there is a solution."},"comment":{"url":"https://api.github.com/repos/pyserial/pyserial/issues/comments/377814297","html_url":"https://github.com/pyserial/pyserial/issues/331#issuecomment-377814297","issue_url":"https://api.github.com/repos/pyserial/pyserial/issues/331","id":377814297,"user":{"login":"liudr","id":4213617,"avatar_url":"https://avatars3.githubusercontent.com/u/4213617?v=4","gravatar_id":"","url":"https://api.github.com/users/liudr","html_url":"https://github.com/liudr","followers_url":"https://api.github.com/users/liudr/followers","following_url":"https://api.github.com/users/liudr/following{/other_user}","gists_url":"https://api.github.com/users/liudr/gists{/gist_id}","starred_url":"https://api.github.com/users/liudr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liudr/subscriptions","organizations_url":"https://api.github.com/users/liudr/orgs","repos_url":"https://api.github.com/users/liudr/repos","events_url":"https://api.github.com/users/liudr/events{/privacy}","received_events_url":"https://api.github.com/users/liudr/received_events","type":"User","site_admin":false},"created_at":"2018-04-01T20:26:48Z","updated_at":"2018-04-01T20:26:48Z","author_association":"NONE","body":"I just checked on a Linux Mint 18.1 system. Works fine."}}
{"actor":{"display_login":"liudr"}}