From 8a6d7a89645127d5f50b4727710121247fa18142 Mon Sep 17 00:00:00 2001 From: Thomas Niederberger <781000+Niederb@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:30:44 +0200 Subject: [PATCH 1/5] Move reserved inside repeated group as specified --- src/pyubx2/ubxtypes_get.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyubx2/ubxtypes_get.py b/src/pyubx2/ubxtypes_get.py index 8fff526..53c9741 100644 --- a/src/pyubx2/ubxtypes_get.py +++ b/src/pyubx2/ubxtypes_get.py @@ -3434,9 +3434,9 @@ "timeElapsed": U4, "detectionType": U1, "eventType": U1, + "reserved1": U2, }, ), - "reserved1": U2, }, "SEC-SIGN": { "version": U1, From 4f39e06e5c65d59af404d2c974835fc9d5bbae98 Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:15:52 +0100 Subject: [PATCH 2/5] update to version 1.2.45 --- .vscode/settings.json | 2 +- RELEASE_NOTES.md | 6 ++++++ pyproject.toml | 2 +- src/pyubx2/_version.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) 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..37cc192 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,11 @@ # pyubx2 Release Notes +### RELEASE 1.2.45 + +FIXES: + +1. Fix SEC-SIGLOG payload definition - thanks to @Niederb for contribution. + ### 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" From db9780dd6d6d1abf4fe24d68f0a44399fa971093 Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:57:40 +0100 Subject: [PATCH 3/5] update SEC-SIG definitions - Fixes #156 --- RELEASE_NOTES.md | 1 + src/pyubx2/ubxtypes_core.py | 2 +- src/pyubx2/ubxtypes_get.py | 16 +++++++++++++++- src/pyubx2/ubxvariants.py | 25 +++++++++++++++++++++++++ tests/pygpsdata-SEC.log | Bin 0 -> 88 bytes tests/test_stream.py | 18 ++++++++++++++++++ 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/pygpsdata-SEC.log diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 37cc192..070e46c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,6 +5,7 @@ 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 diff --git a/src/pyubx2/ubxtypes_core.py b/src/pyubx2/ubxtypes_core.py index cf59fa9..cce513a 100644 --- a/src/pyubx2/ubxtypes_core.py +++ b/src/pyubx2/ubxtypes_core.py @@ -401,7 +401,7 @@ # *************************************************************** # Security messages # *************************************************************** - b"\x27\x09": "SEC-SIG", + 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 53c9741..6101523 100644 --- a/src/pyubx2/ubxtypes_get.py +++ b/src/pyubx2/ubxtypes_get.py @@ -3404,7 +3404,7 @@ # ******************************************************************** # Security Feature Messages # Messages in the SEC class are used for security features of the receiver. - "SEC-SIG": { + "SEC-SIG-V1": { "version": U1, # 0x01 "reserved0": U3, "jamFlags": ( @@ -3424,6 +3424,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, 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 0000000000000000000000000000000000000000..ca4d1e7088afe1d2a29e0d19be39a40bf27f2f57 GIT binary patch literal 88 zcmdm*q%Oe0z{tSBu;{5A!&CpQN$Q+33{0~b*#2-zFmPQGXSh%(!4R-ph#@6gh{1qa fm|@OVpc<&2u9tEQ7k`8F@PN%=1)9SS#GdZ~&`lJ9 literal 0 HcmV?d00001 diff --git a/tests/test_stream.py b/tests/test_stream.py index 034e229..9a68005 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -281,6 +281,24 @@ 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, 4) + def testCFGLOG( self, ): # test stream of UBX CFG messages From ad79d867202156602ee166b65533f6c0838067b4 Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:02:34 +0100 Subject: [PATCH 4/5] add SEC-OSNMA --- RELEASE_NOTES.md | 4 ++ src/pyubx2/ubxtypes_core.py | 2 + src/pyubx2/ubxtypes_get.py | 85 ++++++++++++++++++++++++++++++++++++ src/pyubx2/ubxtypes_poll.py | 1 + tests/pygpsdata-SEC.log | Bin 88 -> 156 bytes tests/test_stream.py | 10 +++-- 6 files changed, 98 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 070e46c..e765ab0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,6 +2,10 @@ ### RELEASE 1.2.45 +ENHANCEMENTS: + +1. Add SEC-OSNMA payload definition. + FIXES: 1. Fix SEC-SIGLOG payload definition - thanks to @Niederb for contribution. diff --git a/src/pyubx2/ubxtypes_core.py b/src/pyubx2/ubxtypes_core.py index cce513a..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,6 +402,7 @@ # *************************************************************** # Security messages # *************************************************************** + b"\x27\x0a": "SEC-OSNMA", b"\x27\x09": "SEC-SIG", # 2 versions b"\x27\x10": "SEC-SIGLOG", b"\x27\x01": "SEC-SIGN", diff --git a/src/pyubx2/ubxtypes_get.py b/src/pyubx2/ubxtypes_get.py index 6101523..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,6 +3405,90 @@ # ******************************************************************** # Security Feature Messages # Messages in the SEC class are used for security features of the receiver. + "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, 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/tests/pygpsdata-SEC.log b/tests/pygpsdata-SEC.log index ca4d1e7088afe1d2a29e0d19be39a40bf27f2f57..34937282a8de387236a5c3f2e563569c2b882728 100644 GIT binary patch literal 156 zcmdm*q%Oe0z{tSB;BqLHVfCM_N$OlO49q}2NDKs)0mT_uAZ!q+WCc{iDZ{`tn}O{Q zrvwAnC2@ueg%S(_yM-81vV|B7n1vbUYz3-;nyYgxm0|h{Omho?;>hNHR72", + "", + "", "", - "", - "", + "", + "", + "", ) i = 0 with open(os.path.join(DIRNAME, "pygpsdata-SEC.log"), "rb") as stream: @@ -297,7 +299,7 @@ def testSEC( # print(f'"{parsed}",') self.assertEqual(str(parsed), EXPECTED_RESULTS[i]) i += 1 - self.assertEqual(i, 4) + self.assertEqual(i, 6) def testCFGLOG( self, From 4f7799a1cde8a457f7e9b054e6dfa02815f41cdf Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:06:21 +0100 Subject: [PATCH 5/5] enhance SEC test cases --- tests/pygpsdata-SEC.log | Bin 156 -> 176 bytes tests/test_stream.py | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pygpsdata-SEC.log b/tests/pygpsdata-SEC.log index 34937282a8de387236a5c3f2e563569c2b882728..37cfdaab2dcbbb58a7b76142e9939d98a37100f7 100644 GIT binary patch delta 27 fcmbQkxPfuP9FeU_>YO|bj0_A6tU$~T#GdZ~Sy=@q delta 6 NcmdnMIEQh<8~_Mf0($@e diff --git a/tests/test_stream.py b/tests/test_stream.py index a902a58..3935874 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -291,6 +291,7 @@ def testSEC( "", "", "", + "", ) i = 0 with open(os.path.join(DIRNAME, "pygpsdata-SEC.log"), "rb") as stream: @@ -299,7 +300,7 @@ def testSEC( # print(f'"{parsed}",') self.assertEqual(str(parsed), EXPECTED_RESULTS[i]) i += 1 - self.assertEqual(i, 6) + self.assertEqual(i, 7) def testCFGLOG( self,