Beispiel #1
0
    def sendSettings(self, baudrate):
        response = self.sendRequest({"type": "settings", "baudrate": baudrate})
        if response["type"] != "ack":
            raise common.BadResponseException()

        self.configurePort(baudrate)
        time.sleep(2)
Beispiel #2
0
    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
Beispiel #3
0
    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()
Beispiel #4
0
 def sendClose(self):
     response = self.sendRequest({"type": "close"})
     if response["type"] != "ack":
         raise common.BadResponseException()
Beispiel #5
0
 def sendPing(self):
     response = self.sendRequest({"type": "ping"})
     if response["type"] != "pong":
         raise common.BadResponseException()