hi i am new for Embedded , i want to communicate multiple device using Can protocols using node ID ,
for example i want to communicate 10 devices, theses ID also 1to 10; how i will select the id and i want to sending the string={“kalaivananworkingthecanbuscommunication”}received the string={“thecanbuscommunicationworkingfine”}
#include "mbed.h"
#if defined (DEVICE_CAN) || defined(DOXYGEN_ONLY)
Serial pc(USBTX,USBRX);
Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
CAN can1(PD_0, PD_1);
CAN can2(PB_5,PB_6);
//char counter []= {'0','8','5','9','5'};
char counter = 0;
void send()
{
printf(" Start to send the Data \n");
if(can1.write(CANMessage(1, &counter, 1))) //id data second
{
printf("Sending Data Done \n");
counter++;
printf("Message sent: %d \n", counter);
}
led1 = !led1;
}
int main()
{
pc.baud(9600);
can1.frequency(115200);
can2.frequency(115200);
printf("main()\n");
ticker.attach(&send, 1);
CANMessage msg;
while(1) {
// printf("loop()\n");
//if(can1.read(msg))
if(can2.read(msg))
{
printf("Message received: %d\n", msg.data[0]);
led2 = !led2;
wait_ms(300);
printf(" Start to send the Data \n");
}
}
}
#else
#error CAN NOT SUPPORTED
#endif
these code working fine in my Nucleo F767ZI
pls help …