📅  最后修改于: 2023-12-03 15:04:43.039000             🧑  作者: Mango
pyubx is a Python library for parsing and creating UBX protocol messages, used by u-blox GPS receivers.
Install via pip:
pip install pyubx
import pyubx
data = b"\xB5\x62\x05\x01\x02\x00\x09\x08\x00\x67\xEB"
parser = pyubx.Parser()
msg = parser.parse(data)
# Output: {'class_id': b'\x05', 'message_id': b'\x01', 'payload': b'\x02\x00\x09\x08\x00', 'length': 9, 'checksum': b'\x67\xEB'}
import pyubx
msg = pyubx.Message("CFG", "CFG-PRT")
msg.add("portID", 2)
msg.add("inProtoMask", 1)
msg.add("outProtoMask", 1)
msg.add("baudRate", 9600)
msg.pack()
# Output: b'\xb5b\x06\x00\x14\x00\x02\x01\x01\x00\x00\x00\x00\x00\x00`\xea\x00\x00\x07\x00\x01\x01\x01d\xfe'
Full documentation is available at https://pyubx.readthedocs.io/en/latest/.
pyubx is licensed under the MIT License. See LICENSE for details.