can bus

Bonjour,
J'ai commander une carte CANBUS SHIELD pour pouvoir introduire une trame sur le réseau de bord automobile afin de simuler "ignition" pour pouvoir intervenir sur les appareillages...
Je suis novice sur Arduino, mais j'ai introduit ceci mais cela ne fonctionne pas...Je me suis inspirer d'un exemple de la librairie.
Je dois introduire toutes les 100ms une trame à l'ID 0x130; 45 40 21 8E FE
Pouvez vous m'aider?

Hello,
I ordered a CANBUS SHIELD card to be able to introduce a frame on the car dashboard to simulate "ignition" to be able to intervene on the equipment ...

I'm new to Arduino, but I've introduced this but it does not work ... I'm inspired by an example from the bookstore.

I have to insert every 100ms a frame at ID 0x130; 45 40 21 8E FE
Can you help me?

#include <mcp_can.h>
#include <SPI.h>

const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);

void setup()
{
Serial.begin(115200);

while (CAN_OK != CAN.begin(CAN_100KBPS))
{
Serial.println("CAN BUS Shield init fail");
Serial.println(" Init CAN BUS Shield again");
delay(100);
}
Serial.println("CAN BUS Shield init ok!");
}

unsigned char stmp[5] = {45, 40, 21, 8F, FE};
void loop()
{
stmp[7] = stmp[7]+1;
if(stmp[7] == 100)
{
stmp[7] = 0;
stmp[6] = stmp[6] + 1;

if(stmp[6] == 100)
{
stmp[6] = 0;
stmp[5] = stmp[6] + 1;
}
}

CAN.sendMsgBuf(0x130, 1, 5, stmp);
delay(100);
}

unsigned char stmp[5] = {45, 40, 21, 8F, FE};
void loop()
{
        stmp[7] = stmp[7]+1;

An array of size 5 does NOT have an element at position 7. Or 6. Or 5.

Hello, i've modified it, but...

Arduino : 1.8.5 (Windows 7), Carte : "Arduino Uno WiFi"

Les options de compilation ont été modifiées, tout sera recompilé
sendluc2.ino:21: error: exponent has no digits

unsigned char stmp[7] = {45, 40, 21, 8E, FE};

^

sendluc2.ino:21: error: 'FE' was not declared in this scope

unsigned char stmp[7] = {45, 40, 21, 8E, FE};

^

exit status 1
exponent has no digits

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.

luce46M57:
Bonjour,
J'ai commander une carte CANBUS SHIELD pour pouvoir introduire une trame sur le réseau de bord automobile afin de simuler "ignition" pour pouvoir intervenir sur les appareillages...
Je suis novice sur Arduino, mais j'ai introduit ceci mais cela ne fonctionne pas...Je me suis inspirer d'un exemple de la librairie.
Je dois introduire toutes les 100ms une trame à l'ID 0x130; 45 40 21 8E FE
Pouvez vous m'aider?

Hello,
I ordered a CANBUS SHIELD card to be able to introduce a frame on the car dashboard to simulate "ignition" to be able to intervene on the equipment ...

I'm new to Arduino, but I've introduced this but it does not work ... I'm inspired by an example from the bookstore.

I have to insert every 100ms a frame at ID 0x130; 45 40 21 8E FE
Can you help me?

#include <mcp_can.h>
#include <SPI.h>

const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);

void setup()
{
Serial.begin(115200);

while (CAN_OK != CAN.begin(CAN_100KBPS))
{
Serial.println("CAN BUS Shield init fail");
Serial.println(" Init CAN BUS Shield again");
delay(100);
}
Serial.println("CAN BUS Shield init ok!");
}

unsigned char stmp[5] = {45, 40, 21, 8F, FE};
void loop()
{
stmp[7] = stmp[7]+1;
if(stmp[7] == 100)
{
stmp[7] = 0;
stmp[6] = stmp[6] + 1;

if(stmp[6] == 100)
{
stmp[6] = 0;
stmp[5] = stmp[6] + 1;
}
}

CAN.sendMsgBuf(0x130, 1, 5, stmp);
delay(100);
}

Take look at this discussion.

Thanks, but I think my worries are too complicated for me ...

luce46M57:
Thanks, but I think my worries are too complicated for me ...

Hint

unsigned char stmp[7] = {45, 40, 21, 8E, FE};

as compared to

unsigned char stmp[7] = {"5", "4",...};

or

unsigned char stmp[7] = {"45", "40", ....};

Yes, compiler error messages can (most of the time) be like foreign language.
Don't give up.

Now, i tried another code...
i do send an CanID 0X130 , and datapacketHEX 45 40 21 8F FE

is it good?

#include <mcp_can.h>
#include <SPI.h>

const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);

void setup()
{
Serial.begin(115200);

while (CAN_OK != CAN.begin(CAN_100KBPS))
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(500);
}
Serial.println("CAN BUS Shield init ok!");
}

unsigned char stmp[5] = { 0x45, 0x40, 0x21, 0x8F, 0xFE };

void loop()
{
Serial.println("WAKE UP");
CAN.sendMsgBuf(0x130, 1, 5, stmp);
delay(500);
}