def sendSettings(self, baudrate): response = self.sendRequest({"type": "settings", "baudrate": baudrate}) if response["type"] != "ack": raise common.BadResponseException() self.configurePort(baudrate) time.sleep(2)
def testCase(self): size = random.randrange(1, 16 * 1024) response = self.sendRequest({"type": "data", "size": size}) if response["type"] != "ack": raise common.BadResponseException() while size: packetSize = min(random.randrange(1, 32), size) sendData = generateRandomData(packetSize) self.uart.write(sendData) receiveData = self.uart.read(packetSize) if sendData != receiveData: raise common.DataMismatchException() size -= packetSize
def testCase(self): size = random.randrange(1, 16 * 1024) response = self.sendRequest({"type": "data", "size": size}) if response["type"] != "ack": raise common.BadResponseException() results = {} sender = threading.Thread(target=self.threadSender, args=(size, results)) receiver = threading.Thread(target=self.threadReceiver, args=(size, results)) sender.start() receiver.start() sender.join() receiver.join() if results["sender"] != results["receiver"]: raise common.DataMismatchException()
def sendClose(self): response = self.sendRequest({"type": "close"}) if response["type"] != "ack": raise common.BadResponseException()
def sendPing(self): response = self.sendRequest({"type": "ping"}) if response["type"] != "pong": raise common.BadResponseException()