diff --git a/OBSW_UdpClient.py b/OBSW_UdpClient.py index a96aeedab5ac9498a03a0f25264359faa0690243..5edb5e88f14cd6592f470e73e91921e7ee6401a3 100644 --- a/OBSW_UdpClient.py +++ b/OBSW_UdpClient.py @@ -162,7 +162,8 @@ def parseInputArguments(): argParser.add_argument('--clientIP', help='Client(Computer) IP. Default:\'\'', default='') argParser.add_argument('--boardIP', help='Board IP. Default: 169.254.1.38', default='169.254.1.38') argParser.add_argument('-s', '--service', help='Service to test. Default: 17', default=17) - argParser.add_argument('-t', '--tmTimeout', type=float, help='TM Timeout. Default: 6, 3(Serial)', default=6.0) + argParser.add_argument('-t', '--tmTimeout', type=float, help='TM Timeout when listening to verification sequence.' + ' Default: 12, 6(Serial)', default=6.0) argParser.add_argument('-p', '--printFile', help='Supply -p to print output to file. Default: False', action='store_true') argParser.add_argument('-o', '--tcTimeoutFactor', type=float, help='TC Timeout Factor. Default: 3.5', default=3.5) @@ -177,8 +178,8 @@ def parseInputArguments(): args = argParser.parse_args() if args.comIF == 1 and not args.COM: print("No COM port provided, using COM0 !") - if args.comIF == 1 and args.tmTimeout == 6.0: - args.tmTimeout = 3 + if args.comIF == 1 and args.tmTimeout == 12.0: + args.tmTimeout = 6.0 print(args) return args diff --git a/sendreceive/OBSW_CommandSenderReceiver.py b/sendreceive/OBSW_CommandSenderReceiver.py index dd2709df67e1e8b4c022bc75b42e8d3877ccd0b3..0efbee77e6663c17cf560d4189fb17748cf99290 100644 --- a/sendreceive/OBSW_CommandSenderReceiver.py +++ b/sendreceive/OBSW_CommandSenderReceiver.py @@ -37,8 +37,11 @@ class CommandSenderReceiver: self.doPrintToFile = doPrintToFile self.queueEntryIsTelecommand = True + # needed to store last actual tc packet form queue self.lastTc = [] self.lastTcInfo = [] + # ignore periodic packets for timeout when checking a sequence + self.isPacketToIgnore = False # checks for replies. if no reply is received, send telecommand again def checkForFirstReply(self): @@ -58,6 +61,7 @@ class CommandSenderReceiver: self.queueEntryIsTelecommand = False if self.pusPacketInfo == "wait": waitTime = self.pusPacket + self.tmTimeout = self.tmTimeout + waitTime time.sleep(waitTime) elif self.pusPacketInfo == "print": printString = self.pusPacket @@ -66,6 +70,8 @@ class CommandSenderReceiver: exportName = self.pusPacket if self.doPrintToFile: self.tmtcPrinter.printToFile(exportName, True) + elif self.pusPacketInfo == "timeout": + self.tmTimeout = self.pusPacket else: self.queueEntryIsTelecommand = True self.lastTc, self.lastTcInfo = (self.pusPacket, self.pusPacketInfo) @@ -83,18 +89,26 @@ class CommandSenderReceiver: self.start_time = time.time() time.sleep(1) - # check for one sequence of replies for a telecommand (e.g. TM[1,1] , TM[1,7] ...) + # check for sequence of replies for a telecommand (e.g. TM[1,1] , TM[1,7] ...) for tmTimeout value # returns True on success def checkForOneTelemetrySequence(self): tmReady = self.comInterface.dataAvailable(self.tmTimeout * self.tcSendTimeoutFactor) if tmReady is False: return False else: - while tmReady: - self.comInterface.receiveTelemetry() - tmReady = self.comInterface.dataAvailable(self.tmTimeout / 1.5) - if not tmReady: - return True + self.comInterface.receiveTelemetry() + start_time = time.time() + elapsed_time = 0 + while elapsed_time < self.tmTimeout: + tmReady = self.comInterface.dataAvailable(1.0) + if tmReady: + self.comInterface.receiveTelemetry() + elapsed_time = time.time() - start_time + # the timeout value can be set by special TC queue entries if packet handling takes longer, + # but it is reset here to the global value + if self.tmTimeout is not g.tmTimeout: + self.tmTimeout = g.tmTimeout + return True def connectToBoard(): diff --git a/tc/OBSW_TcService3.py b/tc/OBSW_TcService3.py index 41e940bb6a6d075bdf066d1a84c0c2036298e69d..49ec25dd875d4ac9b370859ad0f899a3f86d84f1 100644 --- a/tc/OBSW_TcService3.py +++ b/tc/OBSW_TcService3.py @@ -16,6 +16,7 @@ def packService3TestInto(tcQueue): tcQueue.put(("print", "\r\nTesting Service 3: Adding custom HK definition")) sid1 = bytearray([0x00, 0x00, 0x43, 0x00]) sid2 = bytearray([0x00, 0x00, 0x44, 0x00]) + sidGps = bytearray([0x00, 0x00, 0x1f, 0x00]) collectionInterval = struct.pack('>f', 3) numberOfParameters = struct.pack('B', 5) p1 = bytearray([0x01, 0x01, 0x01, 0x01]) @@ -32,6 +33,13 @@ def packService3TestInto(tcQueue): command = PUSTelecommand(service=3, subservice=2, SSC=3020, data=hkDefinition2) tcQueue.put(command.packCommandTuple()) # enable custom hk definition + tcQueue.put(("print", "\r\nTesting Service 3: Enable custom definition")) + command = PUSTelecommand(service=3, subservice=5, SSC=3030, data=sid1) + tcQueue.put(command.packCommandTuple()) + # enable gps0 + tcQueue.put(("print", "\r\nTesting Service 3: Enable GPS definition")) + command = PUSTelecommand(service=3, subservice=5, SSC=3030, data=sidGps) + tcQueue.put(command.packCommandTuple()) # enable custom diag definition # disable custom hk definition # disable custom diag definition