Hello,
I want to active fan throw press button on realdash using arduino.
I created a button on realdash app :
Then I attached a new action to the button :
And for action type I choosed “Send CAN frame”, But what should I put in the field “FRAME” ?
Here is my XML file :
<RealDashCAN version="2">
<frames baseId="3200">
<frame id="3200" writeInterval="1000">
<value name="OnOff_FAN" units="bit" offset="0" length="1"/>
</frame>
</frames>
</RealDashCAN>
And here is my arduino code :
byte incomingFrame[17] = { 0 };
unsigned int incomingFramePos = 0;
unsigned int digitalPins = 0;
int OnOff_FAN = 5;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while (Serial.available() > 0)
{
incomingFrame[incomingFramePos++] = Serial.read();
if (incomingFrame[0] != 0x44)
{
memset(incomingFrame, 0, 17);
incomingFramePos = 0;
}
if (incomingFramePos >= 17)
{
if (incomingFrame[0] == 0x44 && incomingFrame[1] == 0x33 && incomingFrame[2] == 0x22 && incomingFrame[3] == 0x11)
{
unsigned long canFrameId = 0;
memcpy(&canFrameId, incomingFrame + 4, 4);
byte checkByte = 0;
for (int i=0; i<16; i++)
{
checkByte += incomingFrame[i];
}
if (incomingFrame[16] == checkByte)
{
if (canFrameId == 3200)
{
memcpy(&digitalPins, incomingFrame + 8, 2);
digitalWrite(OnOff_FAN, HIGH);
}
}
memset(incomingFrame, 0, 17);
incomingFramePos = 0;
}
}
}
}