maehw / ubx-gps-simulator

Simulator of u-blox 6 serial communication protocol (UBX)
GNU General Public License v3.0
4 stars 1 forks source link

Issue runnig the simulator with Ardupilot #1

Open RadionL opened 8 months ago

RadionL commented 8 months ago

Hi, I'm trying run simulate ubx GPS into Ardupilot (4.4.2) after im running the script Ardupilot detects the GPS as ublox and disconnects.

thats the log from Pycharm terminal

C:\PycharmProjects\GPS\venv\Scripts\python.exe C:\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py -b 115200 -t 2 COM17 Opened serial port 'COM17' with a baudrate of 115200 and serial blocking read timeout of 0.01 seconds. Simulating I/O target #2.

Received VALID message: class 0x06, ID 0x01 w/ payload b'\x01\x06\x01' (length: 3). CFG-MSG for class 0x01, ID 0x06 (NAV-SOL). Rate for current target: b'\x01' Requested rate change: class=0x01, ID=0x06, rate=b'\x01' <<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x01\x0f8'

Received VALID message: class 0x06, ID 0x00 w/o payload. Poll the configuration of the used I/O Port. <<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Received VALID message: class 0x06, ID 0x00 w/o payload. Poll the configuration of the used I/O Port. <<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Received VALID message: class 0x06, ID 0x00 w/o payload. Poll the configuration of the used I/O Port. <<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Traceback (most recent call last): File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 1051, in run() File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 1047, in run simulator.run() File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 324, in run if self.check_cyclic_tx(base_rate_count, msg_class=b'\x01', msg_id=b'\x06'): File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 764, in check_cyclic_tx return base_rate_count % self.message_rates[msg_class][msg_id]['rate'] == 0 TypeError: unsupported operand type(s) for %: 'int' and 'bytes'

Process finished with exit code 1

maehw commented 8 months ago

Hi @RadionL,

this is the first user feedback. Thanks for creating the ticket here.

Seems to be a type incompatibility around the modulo operator (%): base_rate_count is an integer, self.message_rates[msg_class][msg_id]['rate'] is bytes. I don't have time & a working test setup here to validate this - and I don't know why I've never run into this (maybe I've always had a 0 there). The second one should also be integer.

Maybe, you can do two things:

Add a print statement before the line with modulo: print(self.message_rates[msg_class][msg_id]['rate'])

Try to convert the bytes to an integer (if it's multi-byte, the following probably won't work - we'll need to specify endianness): return base_rate_count % int(self.message_rates[msg_class][msg_id]['rate']) == 0

Have a nice weekend!

RadionL commented 8 months ago

Hi, Converted to int and it's working. Thanks

maehw commented 8 months ago

Hi @RadionL,

great to hear! I'd be happy if you made a pull request with your change(s).

Kind regards