update python tools to new proto names
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
|
||||
import serial
|
||||
import struct
|
||||
from usb_pb2 import UsbPackageType
|
||||
from usb_pb2 import PackageType
|
||||
from serial.tools import list_ports
|
||||
|
||||
|
||||
def make_header(typeid: UsbPackageType, length: int) -> bytearray:
|
||||
def make_header(typeid: PackageType, length: int) -> bytearray:
|
||||
struct_format = '<HHB' # '<' for little-endian, 'H' for uint16_t, 'B' for uint8_t
|
||||
# Calculate the check byte as the sum of length and type
|
||||
typeidint = int(typeid)
|
||||
@@ -13,7 +13,7 @@ def make_header(typeid: UsbPackageType, length: int) -> bytearray:
|
||||
packed_data = struct.pack(struct_format, length, typeid, check)
|
||||
return packed_data
|
||||
|
||||
def send_package(typeid : UsbPackageType, data: bytearray, serial: serial.Serial):
|
||||
def send_package(typeid : PackageType, data: bytearray, serial: serial.Serial):
|
||||
head = make_header(typeid, len(data))
|
||||
package = head + data
|
||||
serial.write(package)
|
||||
|
||||
Reference in New Issue
Block a user