From 4813e9ff342a6de10c36774c41d0f7cbdc032c3c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Fri, 6 Mar 2020 21:12:12 +0100 Subject: [PATCH] some bugfixes for new IDs --- config/OBSW_Config.py | 15 +++++++++++++++ tc/OBSW_TcPacker.py | 20 +++++++++++--------- tc/OBSW_TcPacket.py | 9 ++++++++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/config/OBSW_Config.py b/config/OBSW_Config.py index 33154c9..6608e59 100644 --- a/config/OBSW_Config.py +++ b/config/OBSW_Config.py @@ -8,6 +8,21 @@ """ import socket + +""" +Mission/Device specific information. +""" + +# TODO: Automate / Autofill this file with the MIB parser + +# Object IDs +GPS0_ObjectId = bytearray([0x44, 0x10, 0x1F, 0x00]) +GPS1_ObjectId = bytearray([0x44, 0x20, 0x20, 0x00]) + +# SIDs +GPS0_SID = bytearray([0x00, 0x00, 0x1f, 0x00]) +GPS1_SID = bytearray([0x00, 0x00, 0x2f, 0x00]) + """ All global variables, set in main program with arg parser """ diff --git a/tc/OBSW_TcPacker.py b/tc/OBSW_TcPacker.py index 5d8d810..609313a 100644 --- a/tc/OBSW_TcPacker.py +++ b/tc/OBSW_TcPacker.py @@ -18,7 +18,7 @@ from tc.OBSW_TcService2 import packService2TestInto from tc.OBSW_TcService3 import packService3TestInto from tc.OBSW_TcService8 import packService8TestInto from tc.OBSW_TcService200 import packModeData, packService200TestInto - +import config.OBSW_Config as g from datetime import datetime import queue @@ -42,11 +42,11 @@ def serviceTestSelect(service, serviceQueue): return packDummyDeviceTestInto(serviceQueue) elif service == "GPS0": # Object ID: GPS Device - objectId = bytearray([0x44, 0x00, 0x1F, 0x00]) + objectId = g.GPS0_ObjectId return packGpsTestInto(objectId, serviceQueue) elif service == "GPS1": # Object ID: GPS Device - objectId = bytearray([0x44, 0x00, 0x20, 0x00]) + objectId = g.GPS1_ObjectId return packGpsTestInto(objectId, serviceQueue) elif service == "Error": return packErrorTestingInto(serviceQueue) @@ -145,10 +145,12 @@ def packDummyDeviceTestInto(tcQueue): def packGpsTestInto(objectId, tcQueue): - if bytes(objectId).hex() == "44001f00": + if objectId == g.GPS0_ObjectId: gpsString = "GPS0" - elif bytes(objectId).hex() == "44002000": + elif objectId == g.GPS1_ObjectId: gpsString = "GPS1" + else: + gpsString = "unknown" tcQueue.put(("print", "Testing " + gpsString + " Device")) # Set Mode Off tcQueue.put(("print", "\n\rTesting " + gpsString + ": Set Off")) @@ -162,13 +164,13 @@ def packGpsTestInto(objectId, tcQueue): tcQueue.put(command.packCommandTuple()) # Enable HK report sidGps = 0 - if objectId == bytearray([0x44, 0x00, 0x1F, 0x00]): - sidGps = bytearray([0x00, 0x00, 0x1f, 0x00]) + if objectId == g.GPS0_ObjectId: + sidGps = g.GPS0_SID tcQueue.put(("print", "\r\nTesting " + gpsString + ": Enable HK Reporting")) command = PUSTelecommand(service=3, subservice=5, SSC=13, data=sidGps) tcQueue.put(command.packCommandTuple()) - elif objectId == bytearray([0x44, 0x00, 0x20, 0x00]): - sidGps = bytearray([0x00, 0x00, 0x2f, 0x00]) + elif objectId == g.GPS1_ObjectId: + sidGps = g.GPS1_SID tcQueue.put(("print", "\r\nTesting " + gpsString + ": Enable HK Reporting")) command = PUSTelecommand(service=3, subservice=5, SSC=14, data=sidGps) tcQueue.put(command.packCommandTuple()) diff --git a/tc/OBSW_TcPacket.py b/tc/OBSW_TcPacket.py index 8151e0d..123f03c 100644 --- a/tc/OBSW_TcPacket.py +++ b/tc/OBSW_TcPacket.py @@ -6,6 +6,7 @@ Created on Wed Apr 4 11:43:00 2018 """ import crcmod +import logging class PUSTelecommand: @@ -28,7 +29,13 @@ class PUSTelecommand: # print("Apid:" + str(self.apid)) def getLength(self): - return 4 + len(self.data) + 1 + try: + length = 4 + len(self.data) + 1 + return length + except TypeError as e: + print("OBSW_TcPacket: Invalid type of data") + logging.exception("Error: ") + exit() def pack(self): dataToPack = bytearray() -- GitLab