def test_decoderZveiInvalid(): """Test invalid ZVEI""" assert Decoder.decode("ZVEI1: 1245A") is None assert Decoder.decode("ZVEI1: 1245") is None assert Decoder.decode("ZVEI1: 135") is None assert Decoder.decode("ZVEI1: 54") is None assert Decoder.decode("ZVEI1: 54") is None
def test_decoderPocsagInvalid(): """!Test invalid POCSAG""" assert Decoder.decode( "POCSAG512: Address: 333333F Function: 0 Alpha: invalid") is None assert Decoder.decode( "POCSAG512: Address: 333333F Function: 1 Alpha: invalid") is None assert Decoder.decode( "POCSAG512: Address: 3333333 Function: 4 Alpha: invalid") is None
def test_decoderPocsagText(): """!Test POCSAG with text""" assert not Decoder.decode( "POCSAG512: Address: 1000000 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG512: Address: 1000001 Function: 1 Alpha: test") is None assert not Decoder.decode( "POCSAG1200: Address: 1000002 Function: 2 Alpha: test") is None assert not Decoder.decode( "POCSAG2400: Address: 1000003 Function: 3 Alpha: test") is None
def test_decoderPocsagValid(): """!Test valid POCSAG""" assert not Decoder.decode( "POCSAG512: Address: 1000000 Function: 0") is None assert not Decoder.decode( "POCSAG512: Address: 1000001 Function: 1") is None assert not Decoder.decode( "POCSAG1200: Address: 1000002 Function: 2") is None assert not Decoder.decode( "POCSAG2400: Address: 1000003 Function: 3") is None
def test_decoderFmsInvalid(): """!Test invalid FMS""" assert Decoder.decode( """FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct""" ) is None assert Decoder.decode( """FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Sta 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct""" ) is None assert Decoder.decode( """FMS: 14170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC incorrect""" ) is None assert Decoder.decode( """FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Sta 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC incorrect""" ) is None
def test_decoderPocsagShortRic(): """!Test short POCSAG""" assert not Decoder.decode( "POCSAG512: Address: 3 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG512: Address: 33 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG1200: Address: 333 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG1200: Address: 3333 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG2400: Address: 33333 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG2400: Address: 333333 Function: 0 Alpha: test") is None assert not Decoder.decode( "POCSAG2400: Address: 3333333 Function: 0 Alpha: test") is None
def test_decoderZveiDoubleTone(): """!Test doubleTone included ZVEI""" assert not Decoder.decode("ZVEI1: 6E789") is None assert not Decoder.decode("ZVEI1: 975E7") is None assert not Decoder.decode("ZVEI1: 2E87E") is None
def test_decoderZveiValid(): """!Test valid ZVEI""" assert not Decoder.decode("ZVEI1: 12345") is None assert not Decoder.decode("ZVEI1: 12838") is None assert not Decoder.decode("ZVEI1: 34675") is None
def test_decoderNoData(): """!Test a empty string""" assert Decoder.decode("") is None
reconnectDelay = bwConfig.get("client", "reconnectDelay", default="3") logging.warning("connection to server lost - sleep %d seconds", reconnectDelay) time.sleep(reconnectDelay) bwClient.connect(ip, port) elif not inputQueue.empty(): data = inputQueue.get() logging.info("get data from queue (waited %0.3f sec.)", time.time() - data[1]) logging.debug("%s packet(s) still waiting in queue", inputQueue.qsize()) bwPacket = Decoder.decode(data[0]) inputQueue.task_done() if bwPacket is None: continue bwPacket.printInfo() misc.addClientDataToPacket(bwPacket, bwConfig) for sendCnt in range( bwConfig.get("client", "sendTries", default="3")): bwClient.transmit(str(bwPacket)) if bwClient.receive() == "[ack]": logging.debug("ack ok") break sendDelay = bwConfig.get("client", "sendDelay", default="3")
bwConfig.get("decoder")) else: logging.fatal("Invalid input source: %s", bwConfig.get("client", "inputSource")) exit(1) inputSource.start() else: logging.warning("STARTING TESTMODE!") logging.debug("reading testdata from file") testFile = open("test/testdata.list", mode="r", encoding="utf-8") for testData in testFile: if (len(testData.rstrip(' \t\n\r')) > 1) and ("#" not in testData[0]): logging.info("Testdata: %s", testData.rstrip(' \t\n\r')) bwPacket = Decoder.decode(testData.rstrip(' \t\n\r')) inputQueue.put_nowait((bwPacket, time.time())) logging.debug("finished reading testdata") bwClient = TCPClient() bwClient.connect(ip, port) while 1: if not bwClient.isConnected: reconnectDelay = bwConfig.get("client", "reconnectDelay", default="3") logging.warning("connection to server lost - sleep %d seconds", reconnectDelay) time.sleep(reconnectDelay) bwClient.connect(ip, port)