def testUnicastTTVBecomesTrue(self): self.setupComponent() # Get ports sink = sb.DataSink() # Connect components self.comp.connect(sink, providesPortName='octetIn') # Start components self.comp.start() sink.start() # Create data fakeData = [x % 256 for x in range(1024)] # Create packets and send # 2112 assumes every 31st packet is a parity packet. for i in range(0, 2112): if i != 0 and i % 32 == 31: continue # skip parity packet if i <= 500: h = Sdds.SddsHeader(i, DM=[0, 0, 1], BPS=[0, 1, 0, 0, 0], TTV=0, TT=i, FREQ=60000000) p = Sdds.SddsCharPacket(h.header, fakeData) p.encode() self.userver.send(p.encodedPacket) elif i > 500: h = Sdds.SddsHeader(i, DM=[0, 0, 1], BPS=[0, 1, 0, 0, 0], TTV=1, TT=i, FREQ=60000000) p = Sdds.SddsCharPacket(h.header, fakeData) p.encode() self.userver.send(p.encodedPacket) # Wait for data to be received time.sleep(3) data = sink.getData() # Validate correct amount of data was received self.assertEqual(len(data), 2095104) self.assertEqual(self.comp.status.dropped_packets, 0) sink.stop()
def testUnicastOctetPort(self): """Sends unicast data to the octet port and asserts the data sent equals the data received""" self.setupComponent() # Get ports compDataOctetOut_out = self.comp.getPort('dataOctetOut') # Connect components self.comp.connect(self.sink, providesPortName='octetIn') # Start components self.comp.start() # Create data fakeData = [x % 256 for x in range(1024)] # Create packet and send h = Sdds.SddsHeader(0, DM = [0, 0, 1], BPS = [0, 1, 0, 0, 0], TTV = 1, TT = 0, FREQ = 60000000) p = Sdds.SddsCharPacket(h.header, fakeData) p.encode() self.userver.send(p.encodedPacket) # Wait for data to be received time.sleep(1) # Get data data,stream = self.getData() # Validate correct amount of data was received self.assertEqual(len(data), 1024) # Validate data is correct self.assertEqual([chr(i) for i in data[:256]], list(struct.pack('256B', *fakeData[:256]))) self.assertEqual(self.comp.status.dropped_packets, 0)
def testEmptyInterface(self): self.setupComponent() self.comp.interface = '' # Get ports compDataOctetOut_out = self.comp.getPort('dataOctetOut') # Set properties sink = sb.DataSink() # Connect components self.comp.connect(sink, providesPortName='octetIn') # Start components self.comp.start() sink.start() # Create data fakeData = [x % 256 for x in range(1024)] # Create packet and send h = Sdds.SddsHeader(0, DM=[0, 0, 1], BPS=[0, 1, 0, 0, 0], TTV=1, TT=0, FREQ=60000000) p = Sdds.SddsCharPacket(h.header, fakeData) p.encode() self.userver.send(p.encodedPacket) # Wait for data to be received time.sleep(1) # Get data data = sink.getData() # Validate correct amount of data was received self.assertEqual(len(data), 1024) # Validate data is correct self.assertEqual(data[:256], list(struct.pack('256B', *fakeData[:256]))) self.assertEqual(self.comp.status.dropped_packets, 0) sink.stop()