Skip to content

Commit

Permalink
Merge pull request #158 from semuconsulting/RC-1.2.45
Browse files Browse the repository at this point in the history
Rc 1.2.45
  • Loading branch information
semuadmin authored Sep 2, 2024
2 parents f0f38e6 + 4f7799a commit 41bcb1e
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"editor.formatOnSave": true,
"modulename": "${workspaceFolderBasename}",
"distname": "${workspaceFolderBasename}",
"moduleversion": "1.2.44",
"moduleversion": "1.2.45",
}
11 changes: 11 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pyubx2"
authors = [{ name = "semuadmin", email = "[email protected]" }]
maintainers = [{ name = "semuadmin", email = "[email protected]" }]
description = "UBX protocol parser and generator"
version = "1.2.44"
version = "1.2.45"
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.8"
Expand Down
2 changes: 1 addition & 1 deletion src/pyubx2/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:license: BSD 3-Clause
"""

__version__ = "1.2.44"
__version__ = "1.2.45"
4 changes: 3 additions & 1 deletion src/pyubx2/ubxtypes_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
103 changes: 101 additions & 2 deletions src/pyubx2/ubxtypes_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
U9,
U10,
U12,
U15,
U16,
U20,
U22,
Expand Down Expand Up @@ -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": (
Expand All @@ -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,
Expand All @@ -3434,9 +3533,9 @@
"timeElapsed": U4,
"detectionType": U1,
"eventType": U1,
"reserved1": U2,
},
),
"reserved1": U2,
},
"SEC-SIGN": {
"version": U1,
Expand Down
1 change: 1 addition & 0 deletions src/pyubx2/ubxtypes_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"RXM-SVSI": {},
"RXM-TM": {},
# *************************************************
"SEC-OSNMA": {},
"SEC-SIG": {},
"SEC-SIGLOG": {},
"SEC-SIGN": {},
Expand Down
25 changes: 25 additions & 0 deletions src/pyubx2/ubxvariants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
},
}
Binary file added tests/pygpsdata-SEC.log
Binary file not shown.
21 changes: 21 additions & 0 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,27 @@ def testMONLOG(
i += 1
self.assertEqual(i, 12)

def testSEC(
self,
): # test stream of UBX MON messages
EXPECTED_RESULTS = (
"<UBX(SEC-SIGLOG, version=1, numEvents=0, reserved0=437050933248)>",
"<UBX(SEC-OSNMA, version=3, headerAuthStatus=0, nmaStatus=0, chainInForce=0, CPKS=0, osnmaEnabled=0, numSVs=0, nmaHeaderUpdate=0, timSyncEnabled=0, timSyncStatus=0, timSyncReqDiff=0, reserved0=1, dsmAuthenticationStatus=0, hashFunction=0, macFunction=0, pubKeyId=0, macLookupTable=0, keySize=0, macSize=0, fromNVS=0, teslaKeyAuthStatus=6, wnSf=2132, towSf=203, chainId=0, authSVs=0, authNumTim=16, timingAuthResult=0, macAdkdType=0, pubKeySrc=0, merkleRootSrc=0, merkleRootVal=0, futureMerkleRootSrc=0, futureMerkleRootVal=0, pubKeyVal=0, futurePubKeyVal=0, futurePubKeySrc=0, futurePubKeyId=0)>",
"<UBX(SEC-SIG, version=2, jamDetEnabled=1, jammingState=1, spfDetEnabled=1, spoofingState=1, reserved0=0, jamNumCentFreqs=6)>",
"<UBX(SEC-SIGLOG, version=1, numEvents=0, reserved0=437116469248)>",
"<UBX(SEC-OSNMA, version=3, headerAuthStatus=0, nmaStatus=0, chainInForce=0, CPKS=0, osnmaEnabled=0, numSVs=0, nmaHeaderUpdate=0, timSyncEnabled=0, timSyncStatus=0, timSyncReqDiff=0, reserved0=1, dsmAuthenticationStatus=0, hashFunction=0, macFunction=0, pubKeyId=0, macLookupTable=0, keySize=0, macSize=0, fromNVS=0, teslaKeyAuthStatus=1, wnSf=2254, towSf=203, chainId=0, authSVs=0, authNumTim=16, timingAuthResult=0, macAdkdType=0, pubKeySrc=0, merkleRootSrc=0, merkleRootVal=0, futureMerkleRootSrc=0, futureMerkleRootVal=0, pubKeyVal=0, futurePubKeyVal=0, futurePubKeySrc=0, futurePubKeyId=0)>",
"<UBX(SEC-SIGLOG, version=1, numEvents=0, reserved0=437182005248)>",
"<UBX(SEC-SIG, version=1, reserved0=0, jamDetEnabled=1, jammingState=2, reserved1=0, spfDetEnabled=1, spoofingState=3, reserved2=0)>",
)
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
Expand Down

0 comments on commit 41bcb1e

Please sign in to comment.