Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookbackdemoESP32:I only can read the receiveFrameCount and the sentFrameCount, Can not read and send the data[],why . Can any one give a sample about to sent data and receive data. thanks #17

Open
giu-wxyao opened this issue May 23, 2020 · 2 comments

Comments

@giu-wxyao
Copy link

void loop () {
CANMessage frame_rx;
CANMessage frame_tx;
frame_tx.len = 8;
frame_tx.ext = false;
frame_tx.rtr = false;
frame_tx.idx = 0;
frame_tx.id = 0x12;

if (gBlinkLedDate < millis ()) {
gBlinkLedDate += 2000 ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
const bool ok = can.tryToSend (frame_tx) ;
if (ok) {
gSentFrameCount += 1 ;
Serial.print ("Sent: ") ;
Serial.println (gSentFrameCount) ;
}else{
Serial.println ("Send failure") ;
}
}
if (can.available ()) {
can.receive (frame_rx) ;
gReceivedFrameCount ++ ;
Serial.print ("Received: ") ;
Serial.println (gReceivedFrameCount) ;
Serial.println (frame.data[0]) ;
Serial.println (frame.data[1]) ;
Serial.println (frame.data[2]) ;
Serial.println (frame.data[3]) ;
Serial.println (frame.data[4]) ;

}
}

@pierremolinaro
Copy link
Owner

pierremolinaro commented May 23, 2020 via email

@giu-wxyao
Copy link
Author

thanks, frame object ,this is my mistake. i changed arready. but still only can read receiveFrameCount and the sentFrameCount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants