Coder Social home page Coder Social logo

openant's People

Contributors

bim9262 avatar bluesquall avatar dafyddcrosby avatar dependabot[bot] avatar drkingpo avatar echelon9 avatar firefly-cpp avatar gentlegiantsoftware avatar helgekrueger avatar iceseyes avatar jonnylamb avatar mart-e avatar mgr01 avatar nexialogica avatar persamina avatar pirower avatar purpl3f0x avatar pwithnall avatar robho avatar saladpanda avatar tiagocoutinho avatar tigge avatar toilal avatar troggy avatar tuna-f1sh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openant's Issues

usb.core timeout on raspberry pi with python3

I am seeing the following time out on a Raspberry Pi with python3, but not with python2:

pi@jrl-dev-pi:~/code/openant/examples $ python3 heart_rate_monitor.py
Driver available: [<class 'ant.base.driver.USB2Driver'>, <class 'ant.base.driver.USB3Driver'>]

  • Using: <class 'ant.base.driver.USB2Driver'>
    <class 'usb.core.USBError'>, (110, 'Operation timed out')

Device remains in use after manager is stopped

I get usb.core.USBError: [Errno 16] Resource busy when creating another ant.fs.manager.Application instance using the same device:

With this test script I get the following traceback.
https://gist.github.com/jonnylamb/a794c732bff1e1883d1a

Traceback (most recent call last):
  File "/tmp/garmin.py", line 34, in <module>
    b = GarminTest()
  File "/home/jonny/src/openant/ant/fs/manager.py", line 104, in __init__
    self._node = Node()
  File "/home/jonny/src/openant/ant/easy/node.py", line 56, in __init__
    self.ant = Ant()
  File "/home/jonny/src/openant/ant/base/ant.py", line 68, in __init__
    self._driver.open()
  File "/home/jonny/src/openant/ant/base/driver.py", line 185, in open
    dev.set_configuration()
  File "/home/jonny/src/pyusb/usb/core.py", line 559, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
  File "/home/jonny/src/pyusb/usb/core.py", line 92, in managed_set_configuration
    self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
  File "/home/jonny/src/pyusb/usb/backend/libusb1.py", line 724, in set_configuration
    _check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
  File "/home/jonny/src/pyusb/usb/backend/libusb1.py", line 554, in _check
    raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy

UploadDataCommand._parse_args() return is truncated

pylint warning identifies a potential problem with UploadDataCommand._parse_args()

    @classmethod
    def _parse_args(cls, data):
        return struct.unpack("<BBHI", data[0:8])
        + (data[8:-8],) + struct.unpack("<6xH", data[-8:])
        ^ # W:306, 8: Expression "(+(data[8:-8], )) + (struct.unpack('<6xH', data[-8:]))" is assigned to nothing (expression-not-assigned)

i.e. because the plus symbol is not on the prior line, this function only returns the data up to struct.unpack("<BBHI", data[0:8]) and nothing further.

Connecting to a specific device

Hi. I'm trying to make your heart rate example always connect to a specific device. I know that I'm supposed to be able to do this by setting the device number. I've added some code to the hr.py example to get the device number of my device.

Added code:
m = node.request_message(Message.ID.RESPONSE_CHANNEL_ID)
print("channel id:" + repr(m))

Output:
channel id:(0, 81, array('B', [28, 152, 120, 17]))

The ant documentation says that this channel response should return:
[ channel number, device number, device type id, transmission type]

However, when I change channel.set_id(0, 120, 0) to channel.set_id(152, 120, 0), I am unable to connect to my device. What am I missing here?

ANT-FS Device Scanner

Hi,
currenty I try to program an ant-fs device scanner which lists me all available ANT-FS devices in the surrounding area. Important for me is the serial number (the full serial number which is sent in the authentication layer, not the 2 Byte number from link layer) and the friendly name of the devices. The pairing should be excluded. Just a passive scan would be enough.
Are there any thoughts how achieving this as soon as possible with this tool?
I tried here an there but did not get an proper solution.
Can you help me?

Thank You!

Support for Garmin fenix 6?

Is the fenix 6 be supported? I always get DriverNotFound.

The usb vendor and device seems to be different from the one in the source code. This is my dmesg:

[172678.882924] usb 2-1.2: new high-speed USB device number 13 using xhci_hcd
[172678.983191] usb 2-1.2: New USB device found, idVendor=091e, idProduct=0003, bcdDevice= 0.01
[172678.983196] usb 2-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0

Speed Cadence Sensor Troubles

I'm attempting to read data from heartrate, powermeter, and speed/cadence sensor but to no avail. I've adapted the code in multi_dev_fe_power_meter.py to accept these 3 sensor types but I keep getting a 21: CHANNEL_IN_WRONG_STATE error. I've gotten the heartrate and powermeter to function separately and sometimes together but the speed/cadence sensor doesn't work even on its own (I've tried the bike_speed_cadence.py example code for testing and I get the same error as above). Any ideas? Not sure where to start. All Garmin sensors used and developing on an Raspberry Pi 3B with a Cospoo ANT+ USB stick.

newbie, wish I wasn't

Hi all,

I'd love to be able to connect multiple HR's to the same USB Master, I know this is achievable with channels but every time I change the ID I get no data as a response to the HR I'm wearing. The idea is that I tag a HR to a person and track a few people at the same time.

I'm assuming I'm reading it right and need to 'pair' the receiver to the HRM, but I 'm getting nowhere fast, I'm hoping that someone can help me out with an example of a pairing and reading of a particular HRM based upon serial number. Anyone?

antfs-cli fails with timeout

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.

TX question: does openant supposed to be used in TX way? I mean broadcast out data, just like a normal sensor.

Hello Tigge,

Thanks for making this library, it's great, definitely you made a lot of things easier.

But for now, I have a different situation, what I want to do is the TX side, that is to say, make a master channel "broadcasting sensor" instead of a slave channel receiving from other ant+ devices.
For example: I have some kind of a temperature sensor plugged in the board, and I can get the readings, what I want is to implement the Ant+ Temperature Sensor profile, to make it a standard Ant+ Temp sensor, so other watches of whatever could read it.

I have explored the examples, the receiving side is no problem, without further digging, I'm just wondering if this lib is designed to be worked in a way that do "Master channel TX" than "Slave channel RX"?

I'm quite familiar with ant+ protocols itself, but that's on the Garmin's connect IQ platform and SimulAnt, CIQ has a quite simple Ant API, all I need to do is set the channel type to TX, set the network key, period and frequency, then just set the broadcast data using sendBroadcast() things like that, the timing things are automatically handled.

I noticed in the channel.py, there are methods like "send_acknowledged_data()" and "send_burst_transfer()", but things like the "send broadcast" is not implemented there.
So I'm wondering if I were to send some broadcast, a call to driver's write() will be good, just like the implementation in "send_acknowledged_data()", or it's something else?
Does openant supposed to be used in this way?

Thanks!

USBError: [Errno 32] Pipe error

Hi

I don't manage to get openant / antfs-cli to work. Any hint welcome. I also unloaded the usb_serial_simple as suggested by some google finds, no success.

# antfs-cli --debug
Driver available: [<class ant.base.driver.SerialDriver at 0x7f2ba96081a0>, <class ant.base.driver.USB2Driver at 0x7f2ba9608c20>, <class ant.base.driver.USB3Driver at 0x7f2ba9608c90>]
 - Using: ant.base.driver.USB2Driver
USB Find device, vendor 0xfcf, product 0x1008
USB Config values:
 Config 1
  Interface 0, Alt 0
   Endpoint 129
   Endpoint 1
No kernel driver active
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/antfs_cli/program.py", line 355, in main
    g = AntFSCLI(config_dir, args)
  File "build/bdist.linux-x86_64/egg/antfs_cli/program.py", line 132, in __init__
    Application.__init__(self)
  File "/usr/local/lib/python2.7/dist-packages/ant/fs/manager.py", line 104, in __init__
    self._node = Node()
  File "/usr/local/lib/python2.7/dist-packages/ant/easy/node.py", line 56, in __init__
    self.ant = Ant()
  File "/usr/local/lib/python2.7/dist-packages/ant/base/ant.py", line 68, in __init__
    self._driver.open()
  File "/usr/local/lib/python2.7/dist-packages/ant/base/driver.py", line 195, in open
    alternate_setting = usb.control.get_interface(dev, interface_number)
  File "build/bdist.linux-x86_64/egg/usb/control.py", line 244, in get_interface
    data_or_wLength = 1)[0]
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 1043, in ctrl_transfer
    self.__get_timeout(timeout))
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 883, in ctrl_transfer
    timeout))
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 32] Pipe error

-Benoit-

Continuous Scan Mode - Issue

2 things here:

in Line 180 of ant.py we missed a underline
Instead of: and message.data[1] == 0x01

we should have: and message._data[1] == 0x01

:) that one of the simple things.

The other is.
I tested now a bit more with Open Scan mode and and it screws up regulary with Assertion Error.
I troubleshooted it down and realized that datas in Buffer screwed up.
The reason for screwing up are in '"# Send messages in queue, on indicated time slot", starting from line 200 in ant.py.
Finally in OpenRX Mode will be no (and never) a response to any Message, as Open Rx will only silend listen.

If I mask all the lines out (200-219) it works perfeclty.
So we need somthing like:
Line 201: if message._id == Message.ID.BROADCAST_DATA and OpenRxMode != True:

Right now I'm unsure how to integrate this.
Is there any simple idea? Sure there is! :) I'm not finding it right now.

Thanks for watching over this

Is TX support working?

Hello,

I am new to ANT and Python development, but I have already set up heart rate monitor and cadence sensor working in a Python/PyQt app. Works fine - many thanks to all founders of all this nice stuff :-)

Now I would like to adapt the Garmin Edge remote control to my app:
https://www.thisisant.com/directory/edge-remote-control/
I asked already in ant forum: https://www.thisisant.com/forum/viewthread/7454/ but I am still blocked.

So far, what I understood is that we now have to switch from Slave to Master, so I followed the nice example speed_and_distance.py which simulate a kind of "Treadmill".

I thought that when starting the script that in any case the method self.on_event_tx (self.channel.on_broadcast_tx_data = self.on_event_tx) will be triggered by each EVENT_TX.
But this happens not. The on_event_tx method will never be called and so the broadcast buffer will never be filled with Treadmill data. I set some 'prints' in the Ant basic code and I see that the receiving events are always 1, which means a kind of timeout.

In parallel I set up a slave (a second small laptop with ANT+ USB Stick) for receiving the treadmill data. I guess that pairing is successful because the on_data method (channel.on_broadcast_data = on_data) will be triggered twice on the slave, but all data bytes are zero.

Maybe somebody can test this behavior.

Any help is appreciated.

kkarsten62

End device names

Hi,
In my project everything works nice. I am just curious if I can list/show name of end device that I am connected to.
For now I am connecting to first available device.
Can someone help?

DownloadRequestResponse doesn't handle errors

The ANT-FS standard specifies:

"Total number of bytes remaining in the data block. If no data is available for the specified data block (i.e. response is NOT = 0), the total remaining data length shall be set to 0, and the burst transfer is completed following the response (i.e. the footer packet is not included)."

Right now openant can't handle a missing footer which causes errors when a file can't be downloaded for some reason.

Permissions for nonroot - usb.core

Thanks for the awesome work on this project.

I had a quick question about permissions for the usb.core package. The examples work when I used sudo, but I cannot figure out where to update the permissions to add other users/usergroups.

Thanks!

$ python3 heart_rate_monitor.py
Driver available: [<class 'ant.base.driver.SerialDriver'>, <class 'ant.base.driver.USB2Driver'>, <class 'ant.base.driver.USB3Driver'>]

  • Using: <class 'ant.base.driver.USB3Driver'>
    Traceback (most recent call last):
    File "heart_rate_monitor.py", line 69, in
    main()
    File "heart_rate_monitor.py", line 49, in main
    node = Node()
    File "/usr/local/lib/python3.8/dist-packages/ant/easy/node.py", line 56, in init
    self.ant = Ant()
    File "/usr/local/lib/python3.8/dist-packages/ant/base/ant.py", line 68, in init
    self._driver.open()
    File "/usr/local/lib/python3.8/dist-packages/ant/base/driver.py", line 175, in open
    if dev.is_kernel_driver_active(0):
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/core.py", line 1061, in is_kernel_driver_active
    self._ctx.managed_open()
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/core.py", line 102, in wrapper
    return f(self, *args, **kwargs)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/core.py", line 120, in managed_open
    self.handle = self.backend.open_device(self.dev)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 786, in open_device
    return _DeviceHandle(dev)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 643, in init
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
    File "/home/ubuntu/.local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
    usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

Could not grab port (tty/ttyUSB0): 'Cannot add port 'tty/ttyUSB0'

Having trouble getting my Garmin 405CX to pair. At first I thought it was the timeout issue that some people had seen a few years back with antfs-cli, but looking at syslog it seems there is an issue with the antenna being setup correctly. See section below. Currently running on Mint
lsb_release -a
Distributor ID: LinuxMint
Description: Linux Mint 19.1 Tessa
Release: 19.1
Codename: tessa

Last time I had success with this was about 6 years ago on an Ubuntu release... trying to bring the 405CX out of retirement. Any help would be appreciated. Thanks

Mar 21 13:42:11 musasabi kernel: [ 2360.470252] usb 1-1.1: new full-speed USB device number 9 using ehci-pci
Mar 21 13:42:11 musasabi kernel: [ 2360.583210] usb 1-1.1: New USB device found, idVendor=0fcf, idProduct=1008
Mar 21 13:42:11 musasabi kernel: [ 2360.583217] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 21 13:42:11 musasabi kernel: [ 2360.583222] usb 1-1.1: Product: ANT USBStick2
Mar 21 13:42:11 musasabi kernel: [ 2360.583226] usb 1-1.1: Manufacturer: Dynastream Innovations
Mar 21 13:42:11 musasabi kernel: [ 2360.583229] usb 1-1.1: SerialNumber: 102
Mar 21 13:42:11 musasabi kernel: [ 2360.584938] usb_serial_simple 1-1.1:1.0: suunto converter detected
Mar 21 13:42:11 musasabi kernel: [ 2360.585168] usb 1-1.1: suunto converter now attached to ttyUSB0
Mar 21 13:42:11 musasabi mtp-probe: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1"
Mar 21 13:42:11 musasabi mtp-probe: bus: 1, device: 9 was not an MTP device
Mar 21 13:42:11 musasabi upowerd[1072]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0
Mar 21 13:42:11 musasabi upowerd[1072]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1
Mar 21 13:42:13 musasabi ModemManager[847]: (ttyUSB0): port attributes not fully set
Mar 21 13:42:22 musasabi ModemManager[847]: Creating modem with plugin 'Generic' and '1' ports
Mar 21 13:42:22 musasabi ModemManager[847]: Could not grab port (tty/ttyUSB0): 'Cannot add port 'tty/ttyUSB0', unhandled serial type'
Mar 21 13:42:22 musasabi ModemManager[847]: Couldn't create modem for device at '/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1': Failed to find primary AT port

clarify nature of project and relationship with Garmin-Forerunner-610-Extractor

Tigge/antfs-cli#38 says that this project "holds just the ANT parts (along with some new fixes and an example)" and that the next task is to remove it from the extractor and then use the separate openant repository instead.

But that sounds to me like the extractor code will be left in the Garmin-Forerunner-610-Extractor project, and doesn't that defeat the point of the new naming? Or is the extractor going to be moved somewhere as well? If so, where?

It would be really helpful if this project's README explained the roadmap for this. Currently anyone reading it without deep technical understanding of ANT doesn't have much of a chance to understand what they can use it for (if anything, at this early stage of development).

WeightScale

Hello,

Is there a module to comunicate with a weight scale?
If yes, any examples?

Thank you

Timeout issues and filter module

I often have to start antfs-cli again 1 or 2 times to get the files downloading without those timeout issues.

I think there's a small design issue in ant.easy.filter module that prevents protocol error message to be displayed properly to the user, and that could be used to retry the request properly.

wait_for_message function works nicely when all is working like expected. But the output is cryptic when the device sends an error message.

There are some hardcoded events (EVENT_TRANSFER_TX_FAILED & EVENT_RX_FAIL_GO_TO_SEARCH) that raise a more readable error, but i think an explicit error message should be displayed for every possible error message. Also, the retry on error should be more explicit.

Maybe the signature of wait_for_message(match, process, queue, condition) could be changed to something like wait_for_message(match, error_match, process, queue, condition) where error_match is a function that returns an Exception if an error message has been received ?

Other Profiles

Hi Tigge,

I should want to ask you, if it is possible to use your ant code with other ant profile, for example FE-C.

Thanks for all

Not understanding data transmittted by Magene L508

Hey folks,
This is for Magene L508 using ANT+, I am getting data in this format data: array('B', [81, 255, 12, 1, 105, 26, 215, 13, 128, 21, 136, 40, 5]) where the first 9 values I am not understanding and last 4 are values are for device number, type and transmission type. Last 5 values are always fixed so what this 128 is and what are first 8 values? which ones are range and speed? if you have any idea what are these could you please help?

Best way to listen from multiple USB dongles

Hello due to USB ANT coverage issue I would like to attach more than one USB dongles in a machine,

but when I tried to instantiate to the two nodes, the code didn't seem to support that usecase. What would be the best way to handle it?

Thanks!

"Could not check if kernel driver was active, not implemented in usb backend" and other stuff

Hi,
first excuse my bad english.
So I have made a small script to recieve data from a Elite Justo and it's kinda working. But I have some problems. I'm using a cheap USB Stick from Amazon

Here is the code:

from openant.easy.node import Node
from openant.easy.channel import Channel
from openant.base.message import Message

NETWORK_KEY = [0xb9, 0xa5, 0x21, 0xfb, 0xbd, 0x72, 0xc3, 0x45] # Standard network key for communication with ANT+ devices


def callback_data_power(data): # This function returns the data as soon as it has been received
    print('Leistung ', data) # Example data: array('B', [16, 181, 47, 0, 26, 253, 11, 0]). The value you are looking for (power) should be the penultimate value in the array. Check again

# def callback_data_cadence(data): # This function returns the data as soon as it is received
# print('Cadence ', data)

def main(node):
    node.set_network_key(0x00, NETWORK_KEY) # Set the node's network key to the default network for ANT+ devices 

    ### This channel (channel_pmeter) is for transmitting the power
    channel_power = node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE) # Create a channel for the node to receive data
    channel_power.on_broadcast_data = callback_data_power # Execute callback_data when data is received
    #channel_power.on_burst_data = callback_data_power # Execute callback_data when data is received

    channel_power.set_rf_freq(57) # Set the correct radio frequency of 2.4 Ghz
    channel_power.set_id(0, 11, 0) # Establishes the channel between ANT+ dongle and the device with ID 11. To find the desired ID, run "openant scan" in the terminal and search for the device_type of the desired device. 
    
    
    
    ### This channel (channel_cadence) is for the transmission of the cadence
    # channel_cadence = node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE) # Create a channel for the node to receive data
    # channel_cadence.on_broadcast_data = callback_data_cadence # Execute callback_data when data is received
    # channel_cadence.set_rf_freq(57) # Set the correct radio frequency of 2.4 Ghz
    # channel_cadence.set_id(0, 121, 0)



    try:
        channel_power.open() # Try to open the channel
        # channel_cadence.open() 
        node.start() # Start the node
    finally:
        node.stop() #close the channel if connection attempt is unsuccessful
        print("Node shut down")

node = Node() # Create a node for the connection of ANT+ dongle and Elite Justo for performance
main(node)

To analyze the problems better, i commented out the second part of the script (see code), but it does the same thing like the first part.

My problem is that I get the message "Could not check if kernel driver was active, not implemented in usb backend" every time I run the Script. And the output of data is regularly interrupted with an error. Are both problems caused by an old driver, did I buy a bad USB Stick or is my code just garbage?

This picture shows the result of some seconds of data recieved, interrupted with the timeout error.
Skript Output

canot communicate with device

Hi

Tried to use antfs and get this (I think) openant related message:
Driver available: [<class 'ant.base.driver.SerialDriver'>, <class 'ant.base.driver.USB2Driver'>, <class 'ant.base.driver.USB3Driver'>]

  • Using: <class 'ant.base.driver.USB3Driver'>
    Request basic information...
    Capabilities: array('B', [8, 8, 0, 186, 54, 0, 223])
    Starting system...
    Key done...
    Searching...
    Exception in thread ant.base:
    Traceback (most recent call last):
    File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
    File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
    File "/usr/local/lib/python3.7/dist-packages/ant/base/ant.py", line 180, in _worker
    and message.data[1] == 0x01
    AttributeError: 'Message' object has no attribute 'data'

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/antfs_cli-0.4-py3.7.egg/antfs_cli/program.py", line 384, in main
g.start()
File "/usr/local/lib/python3.7/dist-packages/ant/fs/manager.py", line 223, in start
self._main()
File "/usr/local/lib/python3.7/dist-packages/ant/fs/manager.py", line 150, in _main
if self.on_link(beacon):
File "/usr/local/lib/python3.7/dist-packages/antfs_cli-0.4-py3.7.egg/antfs_cli/program.py", line 167, in on_link
self.link()
File "/usr/local/lib/python3.7/dist-packages/ant/fs/manager.py", line 383, in link
self._send_command(LinkCommand(self._frequency, 4, self._serial_number))
File "/usr/local/lib/python3.7/dist-packages/ant/fs/manager.py", line 199, in _send_command
self._channel.send_acknowledged_data(data)
File "/usr/local/lib/python3.7/dist-packages/ant/easy/channel.py", line 119, in send_acknowledged_data
self.wait_for_event([Message.Code.EVENT_TRANSFER_TX_COMPLETED])
File "/usr/local/lib/python3.7/dist-packages/ant/easy/channel.py", line 50, in wait_for_event
return wait_for_event(ok_codes, self._node._events, self._node._event_cond)
File "/usr/local/lib/python3.7/dist-packages/ant/easy/filter.py", line 73, in wait_for_event
return wait_for_message(match, process, queue, condition)
File "/usr/local/lib/python3.7/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

Dmesg:
[774373.170310] usb 1-2: new full-speed USB device number 111 using xhci_hcd
[774414.389989] usb 1-1: new full-speed USB device number 112 using xhci_hcd
[774414.541123] usb 1-1: New USB device found, idVendor=0fcf, idProduct=1009, bcdDevice= 1.00
[774414.541126] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[774414.541128] usb 1-1: Product: ANT USB-m Stick
[774414.541129] usb 1-1: Manufacturer: Dynastream Innovations
[774414.541130] usb 1-1: SerialNumber: 098
[774414.543446] usb_serial_simple 1-1:1.0: suunto converter detected
[774414.543914] usb 1-1: suunto converter now attached to ttyUSB0

and then after running antfs-cli
usb 1-1: reset full-speed USB device number 112 using xhci_hcd

Device is a forerunner 310XT

Any help appriciated

kind regards Sepp

Exception removing channel #0: Responded with error 21: CHANNEL_IN_WRONG_STATE

Hi, thanks for developing such a good project.

Many of the repositories are updated and running the program, but I noticed one error.

I ran program examples/heart_rate.py and received several heartbeats and got the following error.

Traceback (most recent call last):
File "/Users/abc/code/tmp/openant/examples/heart_rate.py", line 35, in
main()
File "/Users/abc/code/tmp/openant/examples/heart_rate.py", line 26, in main
node.start()
File "/usr/local/lib/python3.11/site-packages/openant/easy/node.py", line 217, in start
self._main()
File "/usr/local/lib/python3.11/site-packages/openant/easy/node.py", line 204, in _main
self.channels[channel].on_broadcast_data(data)
File "/usr/local/lib/python3.11/site-packages/openant/devices/common.py", line 334, in _on_data
self.channel.open()
File "/usr/local/lib/python3.11/site-packages/openant/easy/channel.py", line 88, in open
return self.wait_for_response(Message.ID.OPEN_CHANNEL)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openant/easy/channel.py", line 69, in wait_for_response
return wait_for_response(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openant/easy/filter.py", line 95, in wait_for_response
return wait_for_message(match, process, queue, condition)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openant/easy/filter.py", line 49, in wait_for_message
return process(message)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/openant/easy/filter.py", line 91, in process
raise Exception(
Exception: Responded with error 21: CHANNEL_IN_WRONG_STATE

In debug mode, extended mode is specified when assigning channels, Background Scanning is enabled,
and Extended Messages is enabled.

DEBUG:openant.base.ant:Write data: [a4 04 42 00 00 00 01 e3] #Assign ch with extended(Background Scanning Enable)
DEBUG:openant.base.ant:Write data: [a4 02 66 00 01 c1] #Enable Extended Messages

Aren't these unnecessary when connecting specific devices?

examples/raw_device_data.py, which does not contain these, operates normally.
Maybe devices/common.py needs the following modifications.

def open_channel(self, extended=True, channel_type=None, ext_assign: Optional[int]=0x01):
-> def open_channel(self, extended=False, channel_type=None, ext_assign=None):

`NotImplementedError: attach_kernel_driver` when stopping node

When stopping the node, e.g. via Ctrl+C in the heart_rate.py example, I receive the following exception on Windows

Closing ANT+ device...
Traceback (most recent call last):
  File "C:\Users\...\openant\examples\heart_rate.py", line 33, in <module>
    main()
  File "C:\Users\...\openant\examples\heart_rate.py", line 29, in main
    node.stop()
  File "c:\users\...\openant\openant\easy\node.py", line 223, in stop
    self.ant.stop()
  File "c:\users\...\openant\openant\base\ant.py", line 80, in stop
    self._driver.close()
  File "c:\users\...\openant\openant\base\driver.py", line 355, in close
    self.dev.attach_kernel_driver(0)
  File "C:\Users\...\openant\.venv\lib\site-packages\usb\core.py", line 1133, in attach_kernel_driver
    self._ctx.backend.attach_kernel_driver(
  File "C:\Users\...\openant\.venv\lib\site-packages\usb\backend\__init__.py", line 384, in attach_kernel_driver
    _not_implemented(self.attach_kernel_driver)
  File "C:\Users\...\openant\.venv\lib\site-packages\usb\backend\__init__.py", line 83, in _not_implemented
    raise NotImplementedError(func.__name__)
NotImplementedError: attach_kernel_driver

The reason is that the call to attach_kernel_driver() is not wrapped in a try...except, as is the previous one to detach_kernel_driver()

I prepared a small PR to fix this in a similar way.

set_time fails on Garmin vívofit 1. Gen, latest fw

antfs-cli fails with the following traceback while processing response to set_time:

Traceback (most recent call last):
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/antfs_cli-0.3-py3.7.egg/antfs_cli/program.py", line 356, in main
g.start()
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/manager.py", line 217, in start
self._main()
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/manager.py", line 155, in _main
self.on_transport(beacon)
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/antfs_cli-0.3-py3.7.egg/antfs_cli/program.py", line 198, in on_transport
result = self.set_time()
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/manager.py", line 349, in set_time
result = self._get_commandpipe()
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/manager.py", line 228, in _get_commandpipe
return ant.fs.commandpipe.parse(self.download(0xfffe))
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/commandpipe.py", line 213, in parse
return commandpipe_type._parse(data)
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/commandpipe.py", line 87, in _parse
args = cls._parse_args(data)
File "/home/as/Downloads/garmin/lib/python3.7/site-packages/ant/fs/commandpipe.py", line 83, in _parse_args
return struct.unpack(cls._format, data)
struct.error: unpack requires a buffer of 16 bytes

Full consolelog with antfs-cli --debug attached.

consolelog.txt

Edit: sync.pcap.gz didn't add any value; removed it

plans for bike lights

Hi,

is there any plans for bike lights support as profile?
I can help with the this file D00001621_ANT+Device_Profile-_Bike_Lights_Rev_2.0_M.001.pdf :)

Multiple Channel data receiving and receiving period issues

Hi everyone, i need some help.

  1. I'm using the raw_device_data.py script in the examples folder, in order to receive heart rate data from two devices (polar band H10 and garmin vivosmart 4).
    I'm able to receive data from one device at a time, but i would like to receive data concurrently from the two devices.

I tried to create a second channel, specifying the two device ID in the channel.set_id() function for each channel, but i receive the two data alternatively, for a few seconds from the polar band and then for a few seconds from the garmin.
What's wrong with my solution?

  1. I have some doubt about the receiving period. I read in the ant+ protocol documentation the formula to calculate the channel period value depending on the needed frequency:
    channel_period_val = 32768/MessageRate(Hz)
    If i want a frequency of 4Hz, i should use 8192 as channel period, and receive data every 0.25 seconds. But actually i receive the data every 3/4 seconds with this value. What I'm missing?

  2. In the heart_beat.py example I would like to change the period, but I did't find how to do it. Any suggestion?

Thanks for the help.

from openant.easy.node import Node
from openant.easy.channel import Channel
import datetime

NETWORK_KEY = [0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45]


def on_data(data):
    page = data[0]
    if len(data) > 8:
            device_id = data[9] + (data[10] << 8)
            device_type = data[11]
            trans_type = data[12]
    if (page & 0x0F) <= 7:
        heartrate = data[7]
        print(f"on data - device id: {device_id} - heart rate: {heartrate} BPM - time: {datetime.datetime.now()}")
        
    #print(f"on_data: {data}")



def main():
    # uncomment to show verbose module logging
    # import logging
    # logging.basicConfig(level=logging.DEBUG)

    # create the network node with key
    node = Node()
    node.set_network_key(0x00, NETWORK_KEY)
    #node1 = Node()
    #node1.set_network_key(0x00, NETWORK_KEY)
    
    # create channel
    channel = node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE)
    channel1 = node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE)

    # setup callbacks
    channel.on_broadcast_data = on_data
    channel.on_burst_data = on_data
#
    channel1.on_broadcast_data = on_data
    channel1.on_burst_data = on_data
    ## setup slave channel
    channel.set_period(80) #8070
    channel.set_search_timeout(12)
    channel.set_rf_freq(57)
    channel.set_id(YYYYY, 120, 0)
    channel.enable_extended_messages(1)

    channel1.set_period(80) #8070
    channel1.set_search_timeout(12)
    channel1.set_rf_freq(57)
    channel1.set_id(XXXXX, 120, 0)
    channel1.enable_extended_messages(1)
    
    try:
        channel1.open()
        channel.open()
        node.start()
    finally:
        node.stop()


if __name__ == "__main__":
    main()

Can connect to HR monitor but not speed or cadence sensors

Thanks so much for sharing this code. It's exactly what I've been looking for for a project.
Apologies in advance: I am a product designer new to python and coding in general (previous experience of Arduino only) so please excuse me if I have missed something fundamental in the question I'm asking here.

I have Garmin heartrate, speed, and cadences sensors, running into a Raspberry Pi 4 Model B via the Garmin ANT USB stick.

Your program cadence_speed_heart.py runs fine, although I quite often see the (110, 'Operation timed out') error mentioned in another thread when running it from Thonny instead of terminal.

It picked up the HR sensor straight away and is returning correct values for that (I checked them concurrently against the Garmin Edge cycle computer). But it does not seem to be connecting with the cadence or speed sensors - it is just returning 'n/a' in those fields. I know both devices are working because the Edge reads their data. Would this be an issue with the channel setting maybe?

Thanks

Barney

Successful use of ANTUSB2 Stick on GARMIN's heart rate monitor

Hi I successfully used ANTUSB2 Stick on GARMIN's heart rate meter

But I want to connect GARMIN's heart rate meter & powertap p1 power meter at the same time.
I would like to ask if it is possible to achieve

If this article is difficult to read, please forgive me from google translate
Thank you

TypeError: 'NoneType' object is not iterable when connecting to the Device

I'm trying to run the scan.py example (on windows) but I'm getting the following error. I tried playing around with the driver code according to other ant libs but still gives the same error...

  File "c:\Users\Stavros Avramidis\Downloads\openant-master\openant\ant\base\ant.py", line 59, in __init__
    driver.open()
  File "c:\Users\Stavros Avramidis\Downloads\openant-master\openant\ant\base\driver.py", line 231, in open
    out = usb.util.find_descriptor(
  File "C:\msys64\mingw64\lib\python3.9\site-packages\usb\util.py", line 192, in find_descriptor
    return _interop._next(desc_iter(**args))
  File "C:\msys64\mingw64\lib\python3.9\site-packages\usb\_interop.py", line 68, in _next
    return next(iter)
  File "C:\msys64\mingw64\lib\python3.9\site-packages\usb\util.py", line 183, in desc_iter
    for d in desc:
TypeError: 'NoneType' object is not iterable

OpenAnt at higher sampling Rates

Hi there!

First of all I would like to thank you very much for the library, after the inital setup and understanding ANT+ it seems really easy.

In my application I do have a problem when going into higer messaging rates. I have a powermeter device which has an additional "FastMode" in which Torquevalues are transmitted at a rate of 50Hz.
I do receive the correct data pages but in very unregular intervals between 1 and 15Hz. I already was checking the correct message rate with the software of the device-company and with Antware II. Both allow me to read data at the high rate. The settings and the USB-Stick are the same I´m using with openant, but I can´t manage to receive all data-messages.

I somehow suspect the USB-driver to maybe be the problem. Could you tell me for which version of PyUSB - openant was developed? Currently I´m using the latest version with. The driver used by openant is the USB3Driver.

I would be happy for any ideas - as I really would like to use openant for my project.

Here also some config details:
channel.set_period(655) # of 32768
channel.set_search_timeout(30) # in s
channel.set_rf_freq(57) # 2457 MHz
channel.set_id(54968, 11, 5) # SerialNumber, DeviceType, Transmissiontype

Thank you very much in advance

Documentation needed?

Hello,

I’ve been working on a platform for editable codebase documentation and noticed this repo lacked documentation besides the README. Would it be useful if I generated/hosted docs for this repo?

The platform:

  1. has a modern markdown editor to allow people to quickly and easily create new documents/user guides
  2. is similar to readthedocs/sphinx in that reads through the codebase and builds/hosts linkable pages describing classes and functions, as well as their usages in the codebase. However unlike readthedocs/sphinx, it doesn't require any configuration to get up and running
  3. tracks the github repo so that every build has the latest code

Sincerely hoping I can be of use to you and your project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.