mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Always send initial CAN once
This commit is contained in:
parent
c936b79a03
commit
bd05fbc992
1 changed files with 7 additions and 0 deletions
|
@ -27,6 +27,7 @@ CAN_frame_t BYD_210 = {.FIR = {.B = {.DLC = 8,.FF = CAN_frame_std,}},.MsgID = 0x
|
|||
|
||||
static int discharge_current = 0;
|
||||
static int charge_current = 0;
|
||||
static int initialDataSent = 0;
|
||||
|
||||
void update_values_can_byd()
|
||||
{ //This function maps all the values fetched from battery CAN to the correct CAN messages
|
||||
|
@ -101,6 +102,12 @@ void receive_can_byd(CAN_frame_t rx_frame)
|
|||
void send_can_byd()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
// Send initial CAN data once on bootup
|
||||
if (!initialDataSent)
|
||||
{
|
||||
send_intial_data();
|
||||
initialDataSent = 1;
|
||||
}
|
||||
// Send 2s CAN Message
|
||||
if (currentMillis - previousMillis2s >= interval2s)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue