requesting VIN number using isotp - CANBUS
Budget: €8 – €30 EUR
I would like to know how to request a VIN Number from c++ code
I have this code for example I can send a message but I want to send a request message for VIN Number
for example, I have the following code to send and read long messages using ISOTP CAN messages
int main(int argc, char **argv)
{
char dataReceive[64] ;
///////////////////
int s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP);
struct ifreq ifr;
strcpy(ifr.ifr_name, "vcan0");
ioctl(s, SIOCGIFINDEX, &ifr); // ifr.ifr_ifindex gets filled
// with that device's index
struct sockaddr_can addr;
////////////////////
/* “a very long message“ */
char data[] = "a very long message";
/* create socket instance */
addr.can_family = AF_CAN;
/* address family AF_CAN */
addr.can_ifindex = ifr.ifr_ifindex;
/* CAN interface index e.g. for can0 */
addr.can_addr.tp.tx_id = 0x7DF;
/* transmit on this CAN ID */
addr.can_addr.tp.rx_id = 0x7E8;
/* receive on this CAN ID */
bind(s, (struct sockaddr *)&addr, sizeof(addr));
/* establish datagramm communication */
write(s, data, strlen(data));
while(1)
{
int limit=read(s, &dataReceive,sizeof(dataReceive));
dataReceive[limit]='\0';
cout<<endl<<dataReceive<<endl;
}
/* reception of messages */
close(s);
/* close socket instance */
return 0;
}
this code works fine but I want to send instead of this message a Request message for VIN Number
I can do it from the terminal like this
cansend can0 7df#0209020000000000 && sleep 0.01 && cansend can0 7e0#3000000000000000
but I want to do that from the code
anyone can help me with that
I have this code for example I can send a message but I want to send a request message for VIN Number
for example, I have the following code to send and read long messages using ISOTP CAN messages
int main(int argc, char **argv)
{
char dataReceive[64] ;
///////////////////
int s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP);
struct ifreq ifr;
strcpy(ifr.ifr_name, "vcan0");
ioctl(s, SIOCGIFINDEX, &ifr); // ifr.ifr_ifindex gets filled
// with that device's index
struct sockaddr_can addr;
////////////////////
/* “a very long message“ */
char data[] = "a very long message";
/* create socket instance */
addr.can_family = AF_CAN;
/* address family AF_CAN */
addr.can_ifindex = ifr.ifr_ifindex;
/* CAN interface index e.g. for can0 */
addr.can_addr.tp.tx_id = 0x7DF;
/* transmit on this CAN ID */
addr.can_addr.tp.rx_id = 0x7E8;
/* receive on this CAN ID */
bind(s, (struct sockaddr *)&addr, sizeof(addr));
/* establish datagramm communication */
write(s, data, strlen(data));
while(1)
{
int limit=read(s, &dataReceive,sizeof(dataReceive));
dataReceive[limit]='\0';
cout<<endl<<dataReceive<<endl;
}
/* reception of messages */
close(s);
/* close socket instance */
return 0;
}
this code works fine but I want to send instead of this message a Request message for VIN Number
I can do it from the terminal like this
cansend can0 7df#0209020000000000 && sleep 0.01 && cansend can0 7e0#3000000000000000
but I want to do that from the code
anyone can help me with that