diff --git a/.vscode/settings.json b/.vscode/settings.json index c333cd6..fae4f55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,5 @@ "editor.formatOnSave": true, "modulename": "${workspaceFolderBasename}", "distname": "${workspaceFolderBasename}", - "moduleversion": "1.2.44", + "moduleversion": "1.2.45", } \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3cd4b88..e765ab0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,16 @@ # pyubx2 Release Notes +### RELEASE 1.2.45 + +ENHANCEMENTS: + +1. Add SEC-OSNMA payload definition. + +FIXES: + +1. Fix SEC-SIGLOG payload definition - thanks to @Niederb for contribution. +1. Cater for alternate (v1, v2) versions of SEC-SIG message = Fixes [#156](https://github.com/semuconsulting/pyubx2/issues/156). + ### RELEASE 1.2.44 CHANGES: diff --git a/pyproject.toml b/pyproject.toml index b00548b..1908ba5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "pyubx2" authors = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }] maintainers = [{ name = "semuadmin", email = "semuadmin@semuconsulting.com" }] description = "UBX protocol parser and generator" -version = "1.2.44" +version = "1.2.45" license = { file = "LICENSE" } readme = "README.md" requires-python = ">=3.8" diff --git a/src/pyubx2/_version.py b/src/pyubx2/_version.py index 21b7b0c..711f224 100644 --- a/src/pyubx2/_version.py +++ b/src/pyubx2/_version.py @@ -8,4 +8,4 @@ :license: BSD 3-Clause """ -__version__ = "1.2.44" +__version__ = "1.2.45" diff --git a/src/pyubx2/ubxtypes_core.py b/src/pyubx2/ubxtypes_core.py index cf59fa9..7b0b0a9 100644 --- a/src/pyubx2/ubxtypes_core.py +++ b/src/pyubx2/ubxtypes_core.py @@ -78,6 +78,7 @@ U10 = "U010" # Unsigned Int 10 bytes U11 = "U011" # Unsigned Int 11 bytes U12 = "U012" # Unsigned Int 12 bytes +U15 = "U015" # Unsigned Int 15 bytes U16 = "U016" # Unsigned Int 16 bytes U20 = "U020" # Unsigned Int 20 bytes U22 = "U022" # Unsigned Int 22 bytes @@ -401,7 +402,8 @@ # *************************************************************** # Security messages # *************************************************************** - b"\x27\x09": "SEC-SIG", + b"\x27\x0a": "SEC-OSNMA", + b"\x27\x09": "SEC-SIG", # 2 versions b"\x27\x10": "SEC-SIGLOG", b"\x27\x01": "SEC-SIGN", b"\x27\x03": "SEC-UNIQID", diff --git a/src/pyubx2/ubxtypes_get.py b/src/pyubx2/ubxtypes_get.py index 8fff526..d98ddf9 100644 --- a/src/pyubx2/ubxtypes_get.py +++ b/src/pyubx2/ubxtypes_get.py @@ -46,6 +46,7 @@ U9, U10, U12, + U15, U16, U20, U22, @@ -3404,7 +3405,91 @@ # ******************************************************************** # Security Feature Messages # Messages in the SEC class are used for security features of the receiver. - "SEC-SIG": { + "SEC-OSNMA": { + "version": U1, # 0x02 + "nmaHeader": ( + X1, + { + "headerAuthStatus": U1, + "nmaStatus": U2, + "chainInForce": U2, + "CPKS": U3, + }, + ), + "osnmaMonitoring": ( + X1, + { + "osnmaEnabled": U1, + "numSVs": U5, + "nmaHeaderUpdate": U2, + }, + ), + "timeSyncReq": ( + X1, + { + "timSyncEnabled": U1, + "timSyncStatus": U3, + "timSyncReqDiff": U4, # I4 + }, + ), + "reserved0": U4, + "dsmAuthentication": ( + X4, + { + "dsmAuthenticationStatus": U6, + "hashFunction": U2, + "macFunction": U2, + "pubKeyId": U4, + "macLookupTable": U8, + "keySize": U4, + "macSize": U4, + "fromNVS": U1, + }, + ), + "teslaKey": ( + X4, + { + "teslaKeyAuthStatus": U3, + "wnSf": U12, + "towSf": U15, + "chainId": U2, + }, + ), + "generalAndTiming": ( + X4, + { + "authSVs": U6, + "authNumTim": U6, + "timingAuthResult": U2, + "macAdkdType": U1, + "pubKeySrc": U2, + "merkleRootSrc": U2, + "merkleRootVal": U1, + "futureMerkleRootSrc": U2, + "futureMerkleRootVal": U1, + "pubKeyVal": U1, + "futurePubKeyVal": U1, + "futurePubKeySrc": U2, + "futurePubKeyId": U4, + }, + ), + "authSVgroup": ( + "authSVs", # repeating group * authSVs + { + "bitfield1": ( + X2, + { + "IODE": U10, + "authNum": U5, + "authStatus": U1, + }, + ), + "svId": U1, + "reserved1": U1, + }, + ), + }, + "SEC-SIG-V1": { "version": U1, # 0x01 "reserved0": U3, "jamFlags": ( @@ -3424,6 +3509,20 @@ ), "reserved2": U3, }, + "SEC-SIG-V2": { + "version": U1, # 0x02 + "sigSecFlags": ( + X1, + { + "jamDetEnabled": U1, + "jammingState": U2, + "spfDetEnabled": U1, + "spoofingState": U3, + }, + ), + "reserved0": U1, + "jamNumCentFreqs": U1, + }, "SEC-SIGLOG": { "version": U1, # 0x00 "numEvents": U1, @@ -3434,9 +3533,9 @@ "timeElapsed": U4, "detectionType": U1, "eventType": U1, + "reserved1": U2, }, ), - "reserved1": U2, }, "SEC-SIGN": { "version": U1, diff --git a/src/pyubx2/ubxtypes_poll.py b/src/pyubx2/ubxtypes_poll.py index 70bac21..c0c61d3 100644 --- a/src/pyubx2/ubxtypes_poll.py +++ b/src/pyubx2/ubxtypes_poll.py @@ -210,6 +210,7 @@ "RXM-SVSI": {}, "RXM-TM": {}, # ************************************************* + "SEC-OSNMA": {}, "SEC-SIG": {}, "SEC-SIGLOG": {}, "SEC-SIGN": {}, diff --git a/src/pyubx2/ubxvariants.py b/src/pyubx2/ubxvariants.py index 960b283..86275a9 100644 --- a/src/pyubx2/ubxvariants.py +++ b/src/pyubx2/ubxvariants.py @@ -264,6 +264,30 @@ def get_cfgdat_dict(**kwargs) -> dict: return UBX_PAYLOADS_SET["CFG-DAT"] # manual datum set +def get_secsig_dict(**kwargs) -> dict: + """ + Select appropriate CFG-DAT SET payload definition by checking + presence of datumNum keyword or payload length of 2 bytes. + + :param kwargs: optional payload key/value pairs + :return: dictionary representing payload definition + :rtype: dict + + """ + + if "version" in kwargs: + ver = val2bytes(kwargs["version"], U1) + elif "payload" in kwargs: + ver = kwargs["payload"][0:1] + else: + raise UBXMessageError( + "SEC-SIG message definitions must include version or payload keyword" + ) + if ver == b"\x01": + return UBX_PAYLOADS_GET["SEC-SIG-V1"] + return UBX_PAYLOADS_GET["SEC-SIG-V2"] + + VARIANTS = { POLL: {b"\x06\x31": get_cfgtp5_dict}, # CFG-TP5 SET: { @@ -287,5 +311,6 @@ def get_cfgdat_dict(**kwargs) -> dict: b"\x06\x17": get_cfgnmea_dict, # CFG-NMEA b"\x01\x60": get_aopstatus_dict, # NAV-AOPSTATUS b"\x01\x3C": get_relposned_dict, # NAV-RELPOSNED + b"\x27\x09": get_secsig_dict, # SEC-SIG }, } diff --git a/tests/pygpsdata-SEC.log b/tests/pygpsdata-SEC.log new file mode 100644 index 0000000..37cfdaa Binary files /dev/null and b/tests/pygpsdata-SEC.log differ diff --git a/tests/test_stream.py b/tests/test_stream.py index 034e229..3935874 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -281,6 +281,27 @@ def testMONLOG( i += 1 self.assertEqual(i, 12) + def testSEC( + self, + ): # test stream of UBX MON messages + EXPECTED_RESULTS = ( + "", + "", + "", + "", + "", + "", + "", + ) + i = 0 + with open(os.path.join(DIRNAME, "pygpsdata-SEC.log"), "rb") as stream: + ubr = UBXReader(stream) + for raw, parsed in ubr: + # print(f'"{parsed}",') + self.assertEqual(str(parsed), EXPECTED_RESULTS[i]) + i += 1 + self.assertEqual(i, 7) + def testCFGLOG( self, ): # test stream of UBX CFG messages