cleanup
This commit is contained in:
parent
efad36a8db
commit
125268821b
@ -280,7 +280,7 @@ template <class T, size_t N> struct inplace_vector : private details::inplace_ve
|
||||
constexpr const_reverse_iterator crend() const noexcept {
|
||||
return const_reverse_iterator(cbegin());
|
||||
}
|
||||
[[nodiscard]] constexpr bool full() const noexcept{
|
||||
[[nodiscard]] constexpr bool full() const noexcept {
|
||||
return size() == capacity();
|
||||
}
|
||||
[[nodiscard]] constexpr bool empty() const noexcept {
|
||||
@ -295,7 +295,7 @@ template <class T, size_t N> struct inplace_vector : private details::inplace_ve
|
||||
static constexpr size_type capacity() noexcept {
|
||||
return N;
|
||||
}
|
||||
|
||||
|
||||
// constexpr void resize(size_type sz);
|
||||
// constexpr void resize(size_type sz, const T& c);
|
||||
constexpr void reserve(size_type n) {
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
import serial
|
||||
import time
|
||||
import message_pb2 # Import the generated protobuf module
|
||||
import struct
|
||||
import crcmod.predefined
|
||||
|
||||
# UART Configuration
|
||||
SERIAL_PORT = "/dev/ttyUSB0" # Change to your actual UART port
|
||||
BAUD_RATE = 921600
|
||||
TIMEOUT = 2 # Timeout for UART response
|
||||
|
||||
# Compute CRC32
|
||||
def compute_crc32(data: bytes) -> int:
|
||||
crc32_func = crcmod.predefined.mkPredefinedCrcFun('crc-32')
|
||||
return crc32_func(data)
|
||||
|
||||
# Create and serialize a Message
|
||||
def create_message(msg_id: int, payload: bytes):
|
||||
msg = message_pb2.Message()
|
||||
msg.id = msg_id
|
||||
msg.data = payload[:250] # Ensure max 250 bytes
|
||||
msg.crc = compute_crc32(msg.data)
|
||||
|
||||
return msg.SerializeToString()
|
||||
|
||||
# Send message over UART
|
||||
def send_message(ser, msg_data):
|
||||
ser.write(msg_data)
|
||||
print(f"Sent {len(msg_data)} bytes.")
|
||||
|
||||
# Wait for acknowledgment
|
||||
def wait_for_ack(ser):
|
||||
try:
|
||||
ack = ser.read(19)
|
||||
if ack == b'ACK':
|
||||
print("Received ACK: Message successfully received!")
|
||||
else:
|
||||
print(f"Unexpected response: {ack}")
|
||||
except serial.SerialTimeoutException:
|
||||
print("Timeout: No ACK received.")
|
||||
|
||||
def main():
|
||||
# Open serial port
|
||||
ser = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=TIMEOUT)
|
||||
|
||||
try:
|
||||
payload = b"X0000000" # Example payload
|
||||
message_data = create_message(msg_id=17, payload=payload)
|
||||
|
||||
send_message(ser, message_data)
|
||||
wait_for_ack(ser)
|
||||
|
||||
finally:
|
||||
ser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user