Skip to content

Commit

Permalink
add AID-ALPSRV GET variants
Browse files Browse the repository at this point in the history
  • Loading branch information
semuadmin committed Jan 21, 2025
1 parent 3bd75a5 commit 015ad7c
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

### RELEASE 1.2.50

FIXES:

1. Fix typos in AID-ALPSRV message definitions - thanks to @wheirman for contribution.
1. Add alternate AID-ALPSRV Request and Send GET message types.

ENHANCEMENTS:

1. Minor internal streamlining of helper methods.
Expand Down
17 changes: 15 additions & 2 deletions src/pyubx2/ubxtypes_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
"reserved3": U1,
"reserved4": U1,
},
"AID-ALPSRV": {
"AID-ALPSRV-REQ": { # ALP client requests AlmanacPlus data from server
"idSize": U1,
"type": U1,
"type": U1, # must not be 0xFF
"ofs": U2,
"size": U2,
"fileId": U2,
Expand All @@ -164,6 +164,19 @@
"id2": U1,
"id3": U4,
},
"AID-ALPSRV-SEND": { # ALP client sends AlmanacPlus data to server
"idSize": U1,
"type": U1, # must be 0xFF
"ofs": U2,
"size": U2,
"fileId": U2,
"group": (
"size",
{
"data": U2,
},
),
},
# ********************************************************************
# Configuration Input Messages: i.e. Set Dynamic Model, Set DOP Mask, Set Baud Rate, etc..
# Messages in the CFG class are used to configure the receiver and read out current configuration values. Any
Expand Down
2 changes: 1 addition & 1 deletion src/pyubx2/ubxtypes_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
),
},
"AID-ALPSRV": {
"AID-ALPSRV": { # ALP server sends AlmanacPlus data to client
"idSize": U1,
"type": U1,
"ofs": U2,
Expand Down
25 changes: 25 additions & 0 deletions src/pyubx2/ubxvariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,30 @@ def get_secsig_dict(**kwargs) -> dict:
return UBX_PAYLOADS_GET["SEC-SIG-V2"]


def get_alpsrv_dict(**kwargs) -> dict:
"""
Select appropriate AID-ALPSRV GET payload definition by checking
value of 'type' attribute (2nd byte of payload).
:param kwargs: optional payload key/value pairs
:return: dictionary representing payload definition
:rtype: dict
"""

if "type" in kwargs:
typ = val2bytes(kwargs["type"], U1)
elif "payload" in kwargs:
typ = kwargs["payload"][1:2]
else:
raise UBXMessageError(
"AID-ALPSRV GET message definitions must include type or payload keyword"
)
if typ == b"\xff":
return UBX_PAYLOADS_GET["AID-ALPSRV-SEND"]
return UBX_PAYLOADS_GET["AID-ALPSRV-REQ"]


VARIANTS = {
POLL: {b"\x06\x31": get_cfgtp5_dict}, # CFG-TP5
SET: {
Expand All @@ -304,6 +328,7 @@ def get_secsig_dict(**kwargs) -> dict:
b"\x06\x06": get_cfgdat_dict, # CFG-DAT
},
GET: {
b"\x0b\x32": get_alpsrv_dict, # AID-ALPSRV
b"\x13\x21": get_mga_dict, # MGA FLASH
b"\x13\x60": get_mga_dict, # MGA ACK NAK
b"\x02\x72": get_rxmpmp_dict, # RXM-PMP
Expand Down
38 changes: 38 additions & 0 deletions tests/test_specialcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@author: semuadmin
"""

# pylint: disable=line-too-long, invalid-name, missing-docstring, no-member

import unittest
Expand Down Expand Up @@ -379,6 +380,43 @@ def testUnknownID(self): # test for known class, unknown id
# print(msg)
self.assertEqual(str(msg), EXPECTED_RESULT)

def testAIDALPSRVREQ(self):
EXPECTED_RESULT = "<UBX(AID-ALPSRV, idSize=60, type=253, ofs=23, size=24, fileId=12, dataSize=6, id1=1, id2=2, id3=3)>"
msg = UBXMessage(
"AID",
"AID-ALPSRV",
GET,
idSize=0x3C,
type=0xFD,
ofs=23,
size=24,
fileId=12,
dataSize=6,
id1=1,
id2=2,
id3=3,
)
# print(msg)
self.assertEqual(str(msg), EXPECTED_RESULT)

def testAIDALPSRVSEND(self):
EXPECTED_RESULT = "<UBX(AID-ALPSRV, idSize=60, type=255, ofs=23, size=6, fileId=12, data_01=1, data_02=2, data_03=3, data_04=0, data_05=0, data_06=0)>"
msg = UBXMessage(
"AID",
"AID-ALPSRV",
GET,
idSize=0x3C,
type=0xFF,
ofs=23,
size=6,
fileId=12,
data_01=1,
data_02=2,
data_03=3,
)
# print(msg)
self.assertEqual(str(msg), EXPECTED_RESULT)


if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
Expand Down

0 comments on commit 015ad7c

Please sign in to comment.