Closed matchcat closed 7 years ago
Had this effect once and hat to change the can library version. Code was testet on live cars and using a CAN-Sniffer and I never had double sends. Did you try the example code? Please check the can library settings and can lib CAN_send.ino example to see if the lib works. How did you check the double send?
http://s014.radikal.ru/i326/1707/6c/127bffe41489.jpg(url) - normal http://s019.radikal.ru/i613/1707/20/b1f30f9715b3.jpg(url) - is my arduino
isotp_send -> send_sf -> CANLib SendMsgBuffer, no loops in my code which could cause duplicate sends. Can be can lib configuration or your can bus when using the arduino (termination, setup of sniffer). Sniffer needs to acknowledge the frame to mark it as successfully sent if there is no other device doing this. An ACK is required to complete any CAN message, otherwise its an error. For normal operation the CAN node will keep automatically retrying the same Tx over and over until it gets an ACK.
I use the dash and getaway of VAG 2013 (Tiguan) . the dash meets 2 times the same.
VAG and iostp? Didn't they use their own CAN TP 2.0...but thats not the problem. I still suspect the CAN setup. Please try only the can lib send example and check your sniffer. I currently have no working can setup here to double check but I know the code is working as I used it to programm my car and sniffed the sessions to double check.
command CAN0.sendMsgBuf(can_tx, 0, 8, data); sends 2 times the same ((
So it's CAN lib or setup and not my lib. Will close this, maybe you should check the can lib git and the issues there.
Hi! I need your help . My code for Arduino : `#include
include
include
include
define MCP_INT 2
MCP_CAN CAN0(9); IsoTp isotp(&CAN0,MCP_INT);
struct Message_t TxMsg, RxMsg; uint32_t can_tx = 0x714; uint32_t can_rx = 0x77E;
byte sesion[] = { 0x10, 0x03 }; byte reset[] = { 0x11, 0x01 }; //byte sesion[] = { 0x3E, 0x00 }; byte id[] = { 0x22, 0xF1 , 0x87 }; byte hw[] = { 0x22, 0xF1 , 0x89 }; byte type[] = { 0x22, 0xF1 , 0x9E };
void setup() { Serial.begin(1000000); pinMode(MCP_INT, INPUT); CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ); CAN0.setMode(MCP_NORMAL); }
void print_buf(uint32_t id, byte *buf, uint16_t len) { Serial.print(F("Buffer: ")); Serial.print(id,HEX); Serial.print(F(" [")); Serial.print(len); Serial.print(F("] ")); for(byte i=0;i<len;i++) { if(buf[i] < 0x10) Serial.print(F("0")); Serial.print(buf[i],HEX); Serial.print(F(" ")); }
Serial.println(); }
void send_to_can(byte data[],int a) { TxMsg.len=a; TxMsg.Buffer=(uint8_t *)calloc(MAX_MSGBUF,sizeof(uint8_t)); TxMsg.tx_id=can_tx; TxMsg.rx_id=can_rx; memcpy(TxMsg.Buffer,data,a); isotp.print_buffer(TxMsg.tx_id, TxMsg.Buffer, TxMsg.len); isotp.send(&TxMsg);
RxMsg.tx_id=can_tx; RxMsg.rx_id=can_rx; RxMsg.Buffer=(uint8_t *)calloc(MAX_MSGBUF,sizeof(uint8_t)); Serial.println(F("Receive...")); isotp.receive(&RxMsg); print_buf(RxMsg.rx_id, RxMsg.Buffer, RxMsg.len);
}
void loop() { if (Serial.available() > 0){ byte x = Serial.read();
switch (x) { case 0x30: send_to_can(sesion,2); break; case 0x31: send_to_can(id,3); break; case 0x32: send_to_can(hw,3); break; case 0x33: send_to_can(type,3); break;
} } }`
Arduino sends to can bus 2 times one and the same ((((