示例#1
0
文件: client.py 项目: kubasejdak/hal
    def sendSettings(self, baudrate):
        response = self.sendRequest({"type": "settings", "baudrate": baudrate})
        if response["type"] != "ack":
            raise common.BadResponseException()

        self.configurePort(baudrate)
        time.sleep(2)
示例#2
0
文件: client.py 项目: kubasejdak/hal
    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
示例#3
0
文件: client.py 项目: kubasejdak/hal
    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()
示例#4
0
文件: client.py 项目: kubasejdak/hal
 def sendClose(self):
     response = self.sendRequest({"type": "close"})
     if response["type"] != "ack":
         raise common.BadResponseException()
示例#5
0
文件: client.py 项目: kubasejdak/hal
 def sendPing(self):
     response = self.sendRequest({"type": "ping"})
     if response["type"] != "pong":
         raise common.BadResponseException()