{"action":"created","issue":{"url":"https://api.github.com/repos/google/python-adb/issues/136","repository_url":"https://api.github.com/repos/google/python-adb","labels_url":"https://api.github.com/repos/google/python-adb/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/google/python-adb/issues/136/comments","events_url":"https://api.github.com/repos/google/python-adb/issues/136/events","html_url":"https://github.com/google/python-adb/issues/136","id":379969754,"node_id":"MDU6SXNzdWUzNzk5Njk3NTQ=","number":136,"title":"[Bug] Protocol: AttributeError: 'NoneType' object has no attribute 'ReadUntilClose' still occurring on NVidia Shield","user":{"login":"caffeinatedMike","id":22151742,"node_id":"MDQ6VXNlcjIyMTUxNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/22151742?v=4","gravatar_id":"","url":"https://api.github.com/users/caffeinatedMike","html_url":"https://github.com/caffeinatedMike","followers_url":"https://api.github.com/users/caffeinatedMike/followers","following_url":"https://api.github.com/users/caffeinatedMike/following{/other_user}","gists_url":"https://api.github.com/users/caffeinatedMike/gists{/gist_id}","starred_url":"https://api.github.com/users/caffeinatedMike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caffeinatedMike/subscriptions","organizations_url":"https://api.github.com/users/caffeinatedMike/orgs","repos_url":"https://api.github.com/users/caffeinatedMike/repos","events_url":"https://api.github.com/users/caffeinatedMike/events{/privacy}","received_events_url":"https://api.github.com/users/caffeinatedMike/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-12T22:01:40Z","updated_at":"2018-11-13T15:00:22Z","closed_at":null,"author_association":"NONE","body":"I think this _might_ be related to #59. It seems the error only occurs on \"Official\" Android TV OS devices because I have not been able to reproduce the error on my android box that runs an Android Tablet OS. Anyway, the traceback is as follows\r\n```\r\nMon Nov 12 2018 13:23:15 GMT-0500 (Eastern Standard Time)\r\n\r\nUpdate for media_player.shieldtv fails\r\nTraceback (most recent call last):\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 221, in async_update_ha_state\r\n    await self.async_device_update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 347, in async_device_update\r\n    await self.async_update()\r\n  File \"/home/homeassistant/.homeassistant/custom_components/media_player/androidtv.py\", line 255, in async_update\r\n    await self._androidtv.update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 361, in update\r\n    screen_on = await self._screen_on\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 407, in _screen_on\r\n    screen_on = await self._dump_has('power', 'Display Power', 'state=ON')\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 461, in _dump_has\r\n    dump_result = await self._dump(service, grep=grep)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 448, in _dump\r\n    result = await self._adb.shell('dumpsys {0} | grep \"{1}\"'.format(service, grep))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 298, in shell\r\n    return await fut\r\n  File \"/usr/local/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_commands.py\", line 383, in Shell\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 493, in Command\r\n    result = ''.join(cls.StreamingCommand(usb, service, command, timeout_ms))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 529, in StreamingCommand\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 440, in Open\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 308, in Read\r\n    'Unknown command: %x' % cmd, cmd, (arg0, arg1))\r\nadb.adb_protocol.InvalidCommandError: ('Unknown command: 70736944', 1886611780, (544825708, 1702326096))\r\n\r\n\r\nMon Nov 12 2018 13:23:02 GMT-0500 (Eastern Standard Time)\r\n\r\nUpdate for media_player.shieldtv fails\r\nTraceback (most recent call last):\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 221, in async_update_ha_state\r\n    await self.async_device_update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 347, in async_device_update\r\n    await self.async_update()\r\n  File \"/home/homeassistant/.homeassistant/custom_components/media_player/androidtv.py\", line 255, in async_update\r\n    await self._androidtv.update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 361, in update\r\n    screen_on = await self._screen_on\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 407, in _screen_on\r\n    screen_on = await self._dump_has('power', 'Display Power', 'state=ON')\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 461, in _dump_has\r\n    dump_result = await self._dump(service, grep=grep)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 448, in _dump\r\n    result = await self._adb.shell('dumpsys {0} | grep \"{1}\"'.format(service, grep))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 298, in shell\r\n    return await fut\r\n  File \"/usr/local/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_commands.py\", line 383, in Shell\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 493, in Command\r\n    result = ''.join(cls.StreamingCommand(usb, service, command, timeout_ms))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 529, in StreamingCommand\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 440, in Open\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 312, in Read\r\n    if time.time() - start > total_timeout_ms:\r\nTypeError: '>' not supported between instances of 'float' and 'NoneType'\r\n\r\n\r\nMon Nov 12 2018 13:22:49 GMT-0500 (Eastern Standard Time)\r\n\r\nUpdate for media_player.shieldtv fails\r\nTraceback (most recent call last):\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 221, in async_update_ha_state\r\n    await self.async_device_update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 347, in async_device_update\r\n    await self.async_update()\r\n  File \"/home/homeassistant/.homeassistant/custom_components/media_player/androidtv.py\", line 255, in async_update\r\n    await self._androidtv.update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 366, in update\r\n    wake_lock = await self._wake_lock\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 419, in _wake_lock\r\n    wake_lock = await self._dump_has('power', 'Locks', 'size=0')\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 461, in _dump_has\r\n    dump_result = await self._dump(service, grep=grep)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 448, in _dump\r\n    result = await self._adb.shell('dumpsys {0} | grep \"{1}\"'.format(service, grep))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 298, in shell\r\n    return await fut\r\n  File \"/usr/local/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_commands.py\", line 383, in Shell\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 493, in Command\r\n    result = ''.join(cls.StreamingCommand(usb, service, command, timeout_ms))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 531, in StreamingCommand\r\n    for data in connection.ReadUntilClose():\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 169, in ReadUntilClose\r\n    cmd, data = self.ReadUntil(b'CLSE', b'WRTE')\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 160, in ReadUntil\r\n    self.remote_id, remote_id))\r\nadb.adb_protocol.InvalidResponseError: Incorrect remote id, expected 27640 got 27639\r\n\r\nUpdate for media_player.shieldtv fails\r\nTraceback (most recent call last):\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 221, in async_update_ha_state\r\n    await self.async_device_update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py\", line 347, in async_device_update\r\n    await self.async_update()\r\n  File \"/home/homeassistant/.homeassistant/custom_components/media_player/androidtv.py\", line 255, in async_update\r\n    await self._androidtv.update()\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 361, in update\r\n    screen_on = await self._screen_on\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 407, in _screen_on\r\n    screen_on = await self._dump_has('power', 'Display Power', 'state=ON')\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 461, in _dump_has\r\n    dump_result = await self._dump(service, grep=grep)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 448, in _dump\r\n    result = await self._adb.shell('dumpsys {0} | grep \"{1}\"'.format(service, grep))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/androidtv/__init__.py\", line 298, in shell\r\n    return await fut\r\n  File \"/usr/local/lib/python3.6/concurrent/futures/thread.py\", line 56, in run\r\n    result = self.fn(*self.args, **self.kwargs)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_commands.py\", line 383, in Shell\r\n    timeout_ms=timeout_ms)\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 493, in Command\r\n    result = ''.join(cls.StreamingCommand(usb, service, command, timeout_ms))\r\n  File \"/srv/homeassistant/lib/python3.6/site-packages/adb/adb_protocol.py\", line 531, in StreamingCommand\r\n    for data in connection.ReadUntilClose():\r\nAttributeError: 'NoneType' object has no attribute 'ReadUntilClose'\r\n```\r\nI've taken the liberty of modifying the `adb_protocol.py` file to add in a ton of logging to see what's going on. You can find the modified file's code [here](https://pastebin.com/raw/uV9m9uWA) and a partial log showing where the error begins to occur [here](https://pastebin.com/v9HNG7Sf)\r\n\r\nFrom what I could gather after jumping down the rabbit hole bouncing from function to function after a few hours I have the following theory:\r\n - The errors are connected (in case that wasn't obvious). First erroring on line 308 of `adb_protocol.py`, then line 312 because we're receiving a command that isn't expected (we get `b'WRTE'` while it's looking for either `b'CLSE'` or `b'OKAY'`\r\n - The 3rd error (although not obvious at first glance) is still a product of the previous two errors. It seems tied to arg0 in the Read function. In my logging output you can see that arg0 in the Read function is clearly correct though (arg0: 27640).\r\n\r\nWhat's wrong with the `adb_protocol.py` file? Does anyone know of a fix?"},"comment":{"url":"https://api.github.com/repos/google/python-adb/issues/comments/438296549","html_url":"https://github.com/google/python-adb/issues/136#issuecomment-438296549","issue_url":"https://api.github.com/repos/google/python-adb/issues/136","id":438296549,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODI5NjU0OQ==","user":{"login":"caffeinatedMike","id":22151742,"node_id":"MDQ6VXNlcjIyMTUxNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/22151742?v=4","gravatar_id":"","url":"https://api.github.com/users/caffeinatedMike","html_url":"https://github.com/caffeinatedMike","followers_url":"https://api.github.com/users/caffeinatedMike/followers","following_url":"https://api.github.com/users/caffeinatedMike/following{/other_user}","gists_url":"https://api.github.com/users/caffeinatedMike/gists{/gist_id}","starred_url":"https://api.github.com/users/caffeinatedMike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caffeinatedMike/subscriptions","organizations_url":"https://api.github.com/users/caffeinatedMike/orgs","repos_url":"https://api.github.com/users/caffeinatedMike/repos","events_url":"https://api.github.com/users/caffeinatedMike/events{/privacy}","received_events_url":"https://api.github.com/users/caffeinatedMike/received_events","type":"User","site_admin":false},"created_at":"2018-11-13T15:00:22Z","updated_at":"2018-11-13T15:00:22Z","author_association":"NONE","body":"@fahhem sorry to intrude, but I'm hoping you can have a look into this error soon when you have the time. I know this repo has become pretty desolate, but this appears to be a pretty significant bug. I've tried to figure it out on my own, but have failed after debugging for a few hours. Hopefully, seeing as you're more aware of the inner-workings of the project you'll know exactly what to look for with my extensive debugging logs.\r\n\r\nI know this probably doesn't help much, but I organized the first two errors in a horizontal fashion to easily follow the variable values from function-to-function left-to-right in the attached excel file.\r\n[Error Sequence.xlsx](https://github.com/google/python-adb/files/2576756/Error.Sequence.xlsx)\r\n"}}
{"actor":{"display_login":"caffeinatedMike"}}