Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antfs-cli fails with timeout #95

Closed
robho opened this issue Nov 15, 2023 · 4 comments · Fixed by #97
Closed

antfs-cli fails with timeout #95

robho opened this issue Nov 15, 2023 · 4 comments · Fixed by #97

Comments

@robho
Copy link
Contributor

robho commented Nov 15, 2023

I've been trying to download logs from my Garmin Forerunner watch and have found that it fails with recent openant versions.

I applied #93 and #94 and then it worked up until 6eb8e19. After this commit it says:

Request basic information...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/antfs_cli-0.4-py3.9.egg/antfs_cli/program.py", line 382, in main
    g = AntFSCLI(config_dir, args)
  File "/usr/local/lib/python3.9/dist-packages/antfs_cli-0.4-py3.9.egg/antfs_cli/program.py", line 140, in __init__
    Application.__init__(self)
  File "/usr/local/lib/python3.9/dist-packages/ant/fs/manager.py", line 141, in __init__
    raise e
  File "/usr/local/lib/python3.9/dist-packages/ant/fs/manager.py", line 115, in __init__
    m = self._node.request_message(Message.ID.RESPONSE_CAPABILITIES)
  File "/usr/local/lib/python3.9/dist-packages/ant/easy/node.py", line 116, in request_message
    return self.wait_for_special(messageId)
  File "/usr/local/lib/python3.9/dist-packages/ant/easy/node.py", line 144, in wait_for_special
    return wait_for_special(event_id, self._responses, self._responses_cond)
  File "/usr/local/lib/python3.9/dist-packages/ant/easy/filter.py", line 111, in wait_for_special
    return wait_for_message(match, process, queue, condition)
  File "/usr/local/lib/python3.9/dist-packages/ant/easy/filter.py", line 62, in wait_for_message
    raise AntException("Timed out while waiting for message")
ant.easy.exception.AntException: Timed out while waiting for message
Interrupted: Timed out while waiting for message

I'll take a closer look at this breaking commit, but if you have any pointers to what to try, that would be good.

This is also reported in Tigge/antfs-cli#194.

@robho
Copy link
Contributor Author

robho commented Nov 16, 2023

As I wrote above the problem started with 6eb8e19.

I can restore functionality with either of these changes:

--- a/openant/easy/node.py
+++ b/openant/easy/node.py
@@ -124,11 +124,11 @@ class Node:
         elif event == Message.ID.RESPONSE_ANT_VERSION:
             self.ant_version = bytes(data).decode("ascii")
             _logger.debug(f"ant_version {self.ant_version}")
-        else:
-            self._responses_cond.acquire()
-            self._responses.append((channel, event, data))
-            self._responses_cond.notify()
-            self._responses_cond.release()
+
+        self._responses_cond.acquire()
+        self._responses.append((channel, event, data))
+        self._responses_cond.notify()
+        self._responses_cond.release()
 
     def _worker_event(self, channel, event, data):
         _logger.debug(f"_worker_event {channel}, {event}, {data}")

or:

--- a/openant/fs/manager.py
+++ b/openant/fs/manager.py
@@ -112,8 +112,8 @@ class Application:
 
             print("Request basic information...")
 
-            m = self._node.request_message(Message.ID.RESPONSE_CAPABILITIES)
-            print("  Capabilities: ", m[2])
+            # m = self._node.request_message(Message.ID.RESPONSE_CAPABILITIES)
+            # print("  Capabilities: ", m[2])
 
             # m = self._node.request_message(Message.ID.RESPONSE_ANT_VERSION)
             # print "  ANT version:  ", struct.unpack("<10sx", m[2])[0]

The problem seems to be that the capabilities response requested by fs/manager gets ignored/discarded. Can you create a proper fix from this information? I don't know what the expected behaviour is.

@tuna-f1sh
Copy link
Collaborator

What USB ANT+ stick are you using? A try/catch can be put around the request for capabilities but it's odd that it isn't being responded to.

@robho
Copy link
Contributor Author

robho commented Nov 17, 2023

It's not a hardware problem.

The scenario is:

  1. fs/manager requests CAPABILITIES and waits for a response (calls Node.request_message())
  2. A response arrives to Node._worker_response() but the response is not added to Node._responses (this is the problem and it's new behaviour starting with 6eb8e19. See 6eb8e19#diff-10a81464831c734c4ccadcc3c0ea9aeae3816c32e676baf8c305688ae3b4f60dR113)
  3. The call to Node.request_message() times out because it's never notified of the received response

The same problem seems to exist for SERIAL_NUMBER and ANT_VERSION requests. Ie it's not possible to send these messages and receive a response.

@tuna-f1sh
Copy link
Collaborator

tuna-f1sh commented Nov 18, 2023

Ah I see the issue when you explain it like that; I've not used the antfs stuff myself and didn't have time to look into it when you opened this. Thanks for the PR to just fix it since this stuff isn't used and if is needed, can be grabbed from https://github.com/Tigge/openant/blob/master/openant/easy/node.py#L151 etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants