예제 #1
0
 def print(self):
     _print("Data: ", DEBUG)
     _print("\tPreamble=" + hex(self.preamble), DEBUG)
     _print("\tData Flags=" + hex(self.data_flags), DEBUG)
     _print("\tPacket Number=" + str(self.packet_number), DEBUG)
     _print_bytes("\tArgs=", self.args, DEBUG)
     _print("\tMotion=" + str(self.motion), DEBUG)
    def set(self, _bytes):

        #calculate length of remaining bytes
        length = len(_bytes)
        length_hex = length.to_bytes(1, byteorder='little')

        #build
        self.bytes = SERIAL_PREAMBLE + length_hex + _bytes + SERIAL_TRAILER

        _print_bytes("Serial Packet: ", self.bytes, DEBUG)
예제 #3
0
 def write(self, data):
     _print_bytes("Write: ", data, DEBUG)
     return self._serial.write(data)
예제 #4
0
 def read_bytes(self, num_bytes):
     read = self._serial.read(num_bytes)
     _print_bytes("Read: ", read, DEBUG)
     return read
예제 #5
0
 def read_until(self, bytes):
     read = self._serial.read_until(bytes, None)
     _print_bytes("Read: ", read, DEBUG)
     return read
예제 #6
0
 def receive(self):
     serial_packet = SerialPacket()
     serial_packet.receive()
     self.bytes = serial_packet.get_notif()
     _print_bytes("Recieved Notif: ", self.bytes, DEBUG)
예제 #7
0
 def send(self):
     _print_bytes("Sent Notif: ", self.bytes, DEBUG)
     serial_packet = SerialPacket()
     serial_packet.set(self.bytes)
     serial_packet.send()
예제 #8
0
 def print(self):
     _print("Response: ", APP)
     _print("\tPreamble=" + hex(self.preamble), APP)
     _print("\tOpcode=" + hex(self.opcode), APP)
     _print("\tLength=" + str(self.length), APP)
     _print_bytes("\tArgs=", self.args, APP)