Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Scanning for devices with python-ant

RankRank

Total Posts: 42

Joined 2020-01-26

PM

have you checked if it is well identified with "lsusb" in the terminal (ubuntu)?      
Rank

Total Posts: 4

Joined 2020-05-22

PM

Yes, it is well identified with 0fcf:1008: Dynastream Innovations, Inc.
I'll try to start again formatting raspberry.

Thank for all      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

good luck!      
Rank

Total Posts: 1

Joined 2020-07-07

PM

akixum - 10 June 2020 04:02 AM
AlexDer - 26 May 2020 03:14 PM
lin.xc - 20 April 2020 04:41 AM
Hi Alex,

...


Thanks again lin.xc for pointing out openant. I forked the package and was able to extend it by the functionalities "enable extended messages" and "background scanning". You can find my changes under https://github.com/pirower/openant/ (I even added an additionnal example under scan.py)

Hi,
I've tryed to use your example heart rate monitor and thows a exception:
usb.core.USBError [Errno 32]

Do you know why?

Thanks


Hi Akixum,

I am having this exact same problem you had, with the same USB stick:
usb.core.USBError [Errno 32]

How did you end up solving it?

Thank you      
Rank

Total Posts: 4

Joined 2020-12-20

PM

Maybe this could help: https://github.com/Tigge/openant/issues/51

I saw the usb.core.USBError [Errno 32] error when using a compatible USB Ant+ Stick from Anself.

Following the patch from theller by editing ant/base/driver.py solved it.

No problem then when using heart rate sensor. But when using cadence sensor new problems occur. So I stick to the original Garmin USB Ant+ Stick.

kkarsten62      
Rank

Total Posts: 5

Joined 2020-12-27

PM

AlexDer - 02 March 2020 10:18 AM
Aquakitty - 31 January 2020 02:13 PM
I don't know if this is what you want because I barely know what I am doing myself, but I happened across this when searching to see if anyone expanded on python-ant examples: https://github.com/asantacreuTwoNav/python-ant/blob/develop/demos/ant.core/10-scan.py


Thanks a lot for this. The last fork I copied, didn't include this example. I will definitely check this out and keep you updated.



Hi Alex
did you able to scan the HRM with USB dongle now ? I would like to capture the HRM data with ANT as well. thank you if could help post the result you have.


Best Regards

Lvmc      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

Hi Lvmc,

yes, I was able to scan for Ant+ devices based on their device number. I was able to connect to an Ant+ device and to ask for extended messages. This means, that the Ant+ device sends after connection its sensor data including the device number.

You can check out my examples on https://github.com/pirower/openant which is based on https://github.com/Tigge/openant

Sorry for the late reply!      
Rank

Total Posts: 7

Joined 2022-02-04

PM

Hi,

New member here and just jumping in on this. I have managed to get your code up and running on an RPi. I am able to run scan.py and can find my HRM and see output in the console. I would like to also connect to my Stages Power Meter, however it does not appear when running scan.py. I don't fully understand all of the details here and my Python is basic at best. I was just wondering if anyone had managed to connect to a cycle power meter, ideally stages or could point me in the right direction. I have downloaded the device profile which I believe to be the right one, but its a very long document and I am a little lost. Any help would be most appreciated wink

Thanks

Danny      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

Hi,
according to
set_id(selfdeviceNumdeviceTypetransmissionType
in class
channel 

(cf https://github.com/pirower/openant/blob/master/ant/easy/channel.py ) the relevant call in "scan.py" is
channel.set_id(01200
. So
deviceType=120 
means, that the scan function only searches for heart rate monitors. You need to get the number for the ant+ device type power meter and replace the
120 
. Hope that helps!

I once found this list. Might be
11 
, not sure...

# 1, "Sync"
# 11, "Bike Power Sensors"
# 15, "Multi-Sport Speed and Distance"
# 16, "Controls"
# 16, "Ranging"
# 17, "Fitness Equipment Devices"
# 18, "Blood Pressure Monitors"
# 19, "Geocache Transmitters"
# 20, "Light Electric Vehicle"
# 25, "Environment Sensors"
# 26, "Racquet"
# 30, "Running Dynamics"
# 31, "Muscle Oxygen"
# 34, "Shifting"
# 40, "Bike Radar"
# 41, "Tracker"
#115, "Dropper Seatpost"
#116, "Suspension"
#119, "Weight Scale"
#120, "Heart Rate Sensors"
#121, "Bike Speed and Cadence Sensors"
#122, "Bike Cadence Sensors"
#123, "Bike Speed Sensors"
#124, "Stride-Based Speed and Distance Sensors"
#-1, "Unknown"      
Rank

Total Posts: 7

Joined 2022-02-04

PM

Ah thanks for that I will give it a try, I think it is 11 smile I assume its possible to have both device types in one "profile"? Ideally I would like to connect to a HRM and Power Meter, then based upon the output do something else. Perhaps fan control and light control, directly or via MQTT.      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

In this case, you need to open for each device, which you wan to connect, one individual channel.      
Rank

Total Posts: 7

Joined 2022-02-04

PM

So I have managed to get this working now, thanks for the pointers:) I am able to collect HRM data and power data at the same time, and output to the console. I can also specify the ANT ID of the devices I wish to use. I have just modified some of the example code in "openant". I don't know Python so working things out as I go smile

Things work fine if the ANT devices are on and the RPI is able to speak to them (or just one of them). If however the devices are turned off I receive a timeout, <class 'usb.core.USBTimeoutError'>, (110, 'Operation timed out')

That's fine I guess, but if I leave it for 20 seconds or so then turn either device back on, it does not connect and I have to close everything down to reset and run the code again. Its like the USB crashes or something and cannot start again. Is there a way to trap this, or is it my awful coding? I can provide a code sample if needed.

Thanks in advance! smile
Danny      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

<class 'usb.core.USBTimeoutError'
means, that the code is waiting for a message from the Ant+ device on the USB dongle.

Unfortunately, once a device is disconnected, it won't reconnect automatically (like you are used to from your mobile phone to a known wifi network).

Once a device is turned off or looses the connection, you would need to remove the channel via
channel.close()
channel._unassign() 


and you need to reconnect to the device
channel node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE)
...
channel.set_id(01200)
... 
     
Rank

Total Posts: 7

Joined 2022-02-04

PM

Ah ok that makes sense thanks smile Is it possible to detect/trap this error programmatically so I can close and setup the channel again?      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

definitely, but now, you have to start to code on your own, good luck!