Messagepar AldaMore_CZ » mer. 9 mai 2018 11:40
I'm afraid that if we can not decode the CAN and rewrite the values of the other units on the ARDUINO platform, we will not get the values there. I already built a unit and started to log in with BIC without script 11 and then with script 11. Unfortunately, I do not have much time, but from the initial data you can already find certain characters specific to script 11.
if you do so, you can use this program. Or if you already have a PID list on CAN, put it here.
#include <mcp_can.h>
#include <mcp_can_dfs.h>
#include <mcp_can.h>
#include <spi.h>
long unsigned int rxId;
unsigned int temp = 0x0;
unsigned char len = 0;
unsigned char rxBuf[8];
unsigned char stmp[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Plantilla de mensaje
MCP_CAN CAN1(5); // Configure CS para la recepción de 1 bus a pin 5
MCP_CAN CAN2(10); // Configure CS para enviar a 2 bus al pin 10
void setup()
{
Serial.begin(115200);
CAN1.begin(CAN_500KBPS, MCP_8MHz); // init can bus : baudrate = 500k / 8MHz
CAN2.begin(CAN_500KBPS, MCP_8MHz); // init can bus : baudrate = 500k / 8MHz
pinMode(2, INPUT); //Pin 2 para entrada INT
Serial.println("Started…"); // Salida iniciada ... al monitor del puerto}
void loop()
{
if(!digitalRead(2)) // If pin 2 is low, read receive buffer
{
CAN1.readMsgBuf(&len, rxBuf); // Lectura de datos: len = data length, buf = data byte (s)rxId = CAN1.getCanId(); // Recibimos el mensaje ID
if(rxId == 0x5DA){
Serial.print("TEMP: "); // Salida TEMP: al monitor del puerto
Serial.println(temp, HEX); // Salida de temperatura en el monitor de puerto en formato decimal
// Enviar un mensaje para restablecer el valor de temperatura en la pantalla
if(temp!=rxBuf[0]){
stmp[2]=0xFF;
}
CAN2.sendMsgBuf(0x558, 0, 8, stmp);
delay(10); // 10 ms de retraso
// Envía el mensaje configurando la nueva temperatura
temp=rxBuf[0];
stmp[2]=temp;
CAN2.sendMsgBuf(0x558, 0, 8, stmp);
}
// Transfiere datos a Driving ECO2
if(rxId == 0x646){
CAN2.sendMsgBuf(0x314, 0, 8, rxBuf);
Serial.print("ID1: ");
Serial.print(rxId, HEX);
Serial.print(" Data: ");
for(int i = 0; i<len; i++) // Print each byte of the data
{
if(rxBuf < 0x10) // If data byte is less than 0x10, add a leading zero
{
Serial.print("0");
}
Serial.print(rxBuf, HEX);
Serial.print(" ");
}
Serial.println();
}
}
}