mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 18:29:48 +02:00
Remove millis calls from transmit_rs485
This commit is contained in:
parent
3369639795
commit
3d1644c14e
3 changed files with 5 additions and 8 deletions
|
@ -151,7 +151,7 @@ void setup_battery(void);
|
|||
void update_values_battery();
|
||||
|
||||
#ifdef RS485_BATTERY_SELECTED
|
||||
void transmit_rs485();
|
||||
void transmit_rs485(unsigned long currentMillis);
|
||||
void receive_RS485();
|
||||
#else
|
||||
void handle_incoming_can_frame_battery(CAN_frame rx_frame);
|
||||
|
|
|
@ -154,24 +154,21 @@ void decode_packet(uint8_t command, uint8_t data[8]) {
|
|||
}
|
||||
}
|
||||
|
||||
void transmit_rs485() {
|
||||
void transmit_rs485(unsigned long currentMillis) {
|
||||
static uint8_t nextCommand = 0x90;
|
||||
|
||||
if (millis() - lastPacket > 60) {
|
||||
if (currentMillis - lastPacket > 60) {
|
||||
lastPacket = currentMillis;
|
||||
uint8_t tx_buff[13] = {0};
|
||||
tx_buff[0] = 0xA5;
|
||||
tx_buff[1] = 0x40;
|
||||
tx_buff[2] = nextCommand;
|
||||
tx_buff[3] = 8;
|
||||
tx_buff[12] = calculate_checksum(tx_buff);
|
||||
|
||||
#ifdef DEBUG_VIA_USB
|
||||
dump_buff("transmitting: ", tx_buff, 13);
|
||||
#endif
|
||||
|
||||
Serial2.write(tx_buff, 13);
|
||||
lastPacket = millis();
|
||||
|
||||
nextCommand++;
|
||||
if (nextCommand > 0x98)
|
||||
nextCommand = 0x90;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue