I have serial buffer - RS232 to PACE BMS - that i need to split and then convert to ascii / decimal values.
I do not understand how to split the receive buffer.
Here are two examples of the data i receive and how i need to split them.
<- Incoming data: b'~25014600602850313653323030412D4132313038342D312E3035F57F\r'
BMS Version: P16S200A-A21084-1.05 # BYTE 8 - 27
<- Incoming data: b'~25014600400C4CF236B14E20FAF1\r'
Pack Remaining Capacity: 196980 mAh # BYTE 7-8 - (0x4CF2)*10
Pack Full Capacity: 140010 mAh # BYTE 9-10 - (0x36B1)*10
Pack Design Capacity: 200000 mAh # BYTE 11-12 - (0x4E20)*10
Pack SOC: 140.69 % Calculated - (Remaining Capacity / Full Capacity)*100
Pack SOH: 70.0 % Calculated - (Full Capacity / Design Capacity) *100
My UART settings is as follow:
# ##############################################################
# Battery RS232 UART Setup
# #############################################################
uart:
id: uart_2
baud_rate: 9600
tx_pin: GPIO17
rx_pin: GPIO16
debug:
direction: RX
dummy_receiver: true
after:
delimiter: "\r"
sequence:
- lambda: |-
UARTDebug::log_string(direction, bytes);
Each of the incoming date has different lengths, so i can use.
if (bytes.size()==xx) {
"Split buffer"
}
This is the part i do not understand on how to.
If someone can point me on how do i split the bytes, that will help.