vpower icon indicating copy to clipboard operation
vpower copied to clipboard

Implement Long ID sensor

Open benjdour opened this issue 5 years ago • 9 comments

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

benjdour avatar May 07 '19 21:05 benjdour

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.

dhague avatar May 09 '19 16:05 dhague

I had the same problem https://github.com/dhague/vpower/issues/9 Couldn't figure it out, only got it working with 60655 as device ID.

oldnapalm avatar May 13 '19 23:05 oldnapalm

I use the same method as you

benjdour avatar May 14 '19 15:05 benjdour

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

paytufo avatar Nov 24 '19 01:11 paytufo

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

oldnapalm avatar Jul 08 '20 21:07 oldnapalm

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="")

pjg7 avatar Jan 02 '21 18:01 pjg7

Are you using Python 3?

oldnapalm avatar Jan 02 '21 19:01 oldnapalm

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

pjg7 avatar Jan 02 '21 20:01 pjg7

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.

oldnapalm avatar Jan 02 '21 21:01 oldnapalm