Skip to content

Need to run twice #169

@gabrielecoppi

Description

@gabrielecoppi

Describe the bug

I am running the latest version of pyUBX2 installed with pip on a RPi4. When I run for the first time the following code, I get the everything correct (I get the ACK message after configuring it) and I get the first 3/4 UBX messages on the UART1 and then nothing else. I checked and the code enters this loop here and stays there indefinitely. I also check that on UART2 I am not getting any NMEA messages.

At this point, if I stop the code and run it again, I get everything as expected.

import serial 
from pyubx2 import UBXReader, UBXMessage

port = '/dev/ttyAMA0'
baudrate = 38400
new_baudrate = 115200


msg = [
	('CFG_UART1OUTPROT_UBX', 1),
	('CFG_UART1OUTPROT_NMEA', 0),
	('CFG_UART2OUTPROT_NMEA', 1),
	('CFG_MSGOUT_UBX_NAV_POSECEF_UART1', 1),
	('CFG_MSGOUT_UBX_NAV_POSLLH_UART1', 1),
	('CFG_MSGOUT_UBX_RXM_SFRBX_UART1', 1),
	('CFG_MSGOUT_UBX_RXM_RAWX_UART1', 1),
	('CFG_RATE_MEAS', 1000),
	('CFG_MSGOUT_NMEA_ID_GGA_UART2', 1),
	('CFG_MSGOUT_NMEA_ID_GSV_UART2', 1),
	('CFG_MSGOUT_NMEA_ID_GSA_UART2', 1),
	('CFG_MSGOUT_NMEA_ID_GST_UART2', 1),
	('CFG_MSGOUT_NMEA_ID_GNS_UART2', 1),
	('CFG_MSGOUT_NMEA_ID_ZDA_UART2', 1)
]

ser = serial.Serial(port, baudrate, timeout = 1)

msg_baud = UBXMessage.config_set(1, 0, [('CFG_UART1_BAUDRATE', new_baudrate)])

ser.write(msg_baud.serialize())

ser.close()

ser = serial.Serial(port, new_baudrate, timeout = 1)

msg_cfg = UBXMessage.config_set(1, 0, msg)

print(msg_cfg)

ser.write(msg_cfg.serialize())

reader = UBXReader(ser)

while True:
	raw_data, parsed_data = reader.read()
	print(raw_data)
	print(parsed_data)

To Reproduce

You can just run after boot the code, stop it and then re-run it

Expected Behaviour

I just would expect it to work at the first time, not at the second.

Desktop (please complete the following information):

I am running on UART1 with a Raspberry PI 4 updated at Bookworm.

GNSS/GPS Device (please complete the following information as best you can):

  • Device Model/Generation: ZED-F9P 04B
  • Firmware Version: 1.50.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions