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

Implement Long ID sensor #12

Open
benjdour opened this issue May 7, 2019 · 9 comments
Open

Implement Long ID sensor #12

benjdour opened this issue May 7, 2019 · 9 comments

Comments

@benjdour
Copy link

benjdour commented May 7, 2019

Hi, I use new speed sensor and they have long ID but in the vpower.cfg file we must use short ID, have you a solution for me ?
Thanks for your help

@dhague
Copy link
Owner

dhague commented May 9, 2019

The extended ID puts the top nibble (4 bits) of the ID into the top nibble of the transmission type - see https://www.thisisant.com/developer/resources/tech-bulletin/pairing-to-devices-with-extended-device-numbers
It looks like you would need to adapt the logic at https://github.com/dhague/vpower/blob/master/SpeedCadenceSensorRx.py#L22-L23 to handle this.

@oldnapalm
Copy link
Contributor

I had the same problem
#9
Couldn't figure it out, only got it working with 60655 as device ID.

@benjdour
Copy link
Author

I use the same method as you

@paytufo
Copy link

paytufo commented Nov 24, 2019

What sensor do you use and how you connect it to the raspi?

@oldnapalm
Copy link
Contributor

oldnapalm commented Jul 8, 2020

The doc linked by @dhague says

Please note that if a display shows the device number to the user, it may show either the 2 byte device number, or the 20 bit extended device number (if the upper nibble of transmission type is used), or possibly the device number and transmission type. These display options are all acceptable. If the display allows the user to key in the device number from the display keyboard, the display should consider there are two possible "device numbers" that could be keyed in.

In conclusion: The extended device number is not intended as a number that must be displayed - it is intended to increase a device's chance of pairing to the right device every time - even in crowded environments.

I understand we don't need to "implement long ID", we can just use the 2 bytes device number and disregard the extra 4 bits of the "extended device number".

speed_sensor = SpeedCadenceSensorRx(antnode, SENSOR_TYPE, SPEED_SENSOR_ID & 0xffff)

Tried to adapt the logic at https://github.com/dhague/vpower/blob/master/SpeedCadenceSensorRx.py#L22-L23 as suggested but with any value other than 0 for transmission_type I get no readings from speed sensor.

        transmission_type = 1
        long_id = sensor_id & 0xf0000
        if long_id:
            high = long_id >> 16
            transmission_type += (high << 4)
        self.channel.setID(sensor_type, sensor_id & 0xffff, transmission_type)

Tried the 4 options in bits 0-1

Captura de Tela 2020-07-09 às 15 13 37

@pjg7
Copy link

pjg7 commented Jan 2, 2021

pi@raspberrypi:~ $ cd /boot/vpower
pi@raspberrypi:/boot/vpower $ sudo python vpower.py ../vpower.cfg
Traceback (most recent call last):
File "vpower.py", line 10, in
from PowerMeterTx import PowerMeterTx
File "/boot/vpower/PowerMeterTx.py", line 66
print(f'Power: {int(power)} W \r', end="")

@oldnapalm
Copy link
Contributor

Are you using Python 3?

@pjg7
Copy link

pjg7 commented Jan 2, 2021

I'm using Python 3.9.2 on PC, Python 3 on raspberry and latest raspbian full version.

@oldnapalm
Copy link
Contributor

oldnapalm commented Jan 2, 2021

Please open another issue since this is not related to long sensor ID and post the full traceback.
Do you get this error also on Windows?
Edit: I don't have a Raspberry Pi to confirm, but I read the Raspbian comes with both Python 2 and 3 but 2 is default, so you should run python3 instead of just python.

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

No branches or pull requests

5 participants