Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Scanning for devices with python-ant

Rank

Total Posts: 7

Joined 2022-02-04

PM

I had a feeling you may say that! smile I am trying and will post here if I manage it. If anyone has any tips then please do share. wish me luck smile      
Rank

Total Posts: 7

Joined 2022-02-04

PM

So good progress I think now smile I am a bit confused about the power reading though. I am connected to the power device (stages crank left side on stages SB20 bike) and I am getting data, but it does not seem to correlate to what it should be, and its leaping all over the place. Looking at the device profile two elements are listed for power as below.

Byte 6 Instantaneous Power LSB
Byte 7 Instantaneous Power MSB

Am I supposed to read one of these, or both or add them? I don't understand what LSB and MSB mean.

I get readings but they don't seem quite right to me. This could be totally wrong as I am learning as I go, so any help would be gratefully received! smile

Thanks

     
RankRank

Total Posts: 42

Joined 2020-01-26

PM

https://en.wikipedia.org/wiki/Bit_numbering

LSB=least significant bit, MSB=most significant bit

For an example how to decode LSB and MSB, please take a look at the scan.py (https://github.com/pirower/openant/blob/master/examples/scan.py) example:

deviceNumberLSB data[9]
deviceNumberMSB 
data[10]
deviceNumber 
"{}".format(deviceNumberLSB + (deviceNumberMSB << 8)) 


You don't have to format it to a string smile      
Rank

Total Posts: 7

Joined 2022-02-04

PM

ah ok, that makes sense.

This seems to work, thanks so much for the heads up!

PowerNumberLSB=data[6]
PowerNumberMSB=data[7]
self.power = "{}".format(PowerNumberLSB + (PowerNumberMSB << 2))


however the example in scan uses <<8, is there a recommended metric for this? I have tried both and there isn't too much difference.

I also realised that I was receiving a few different data pages, which was throwing out my figures too. I am not filtering down just to "main page" which is helping also.

Thanks

Danny      
RankRank

Total Posts: 42

Joined 2020-01-26

PM

Hi,

you might want to check what the "<<" function does in python, especially when it comes to bits. I wouldn't change <<8 to <<2 without knowing what it does.

Concerning the different pages: in the document "ANT+ Device Profile - Bicycle Power" you can see under chapter 7 "Bicycle Power Sensor Types" the different pages depending on the sensor type you are using. If you want to decrypt the received data, you need to know which data page you are receiving...      
Rank

Total Posts: 1

Joined 2022-10-17

PM

Does anyone success with Bike Lights ?

I got a PDF with documentation, here is part of it.
Parameter Device Type
Value 
35 (0x23)
Comment An ANTbike light shall transmit its device type as 0x23.
Please see the ANT Message Protocol and Usage document for more details