Not fully receiving CanBus data on Teensy 3.6

Status
Not open for further replies.

Ashraff

New member
/*
* Object Oriented CAN example for Teensy 3.6 with Dual CAN buses
* By Collin Kidder. Based upon the work of Pawelsky and Teachop
*
* Both buses are set to 500k to show things with a faster bus.
* The reception of frames in this example is done via callbacks
* to an object rather than polling. Frames are delivered as they come in.
*/

#include <FlexCAN.h>

class ExampleClass : public CANListener
{
public:
void printFrame(CAN_message_t &frame, int mailbox);
bool frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller); //overrides the parent version so we can actually do something
};

void ExampleClass::printFrame(CAN_message_t &frame, int mailbox)
{
Serial.print("ID: ");
Serial.print(frame.id, HEX);
Serial.print(" Data: ");
for (int c = 0; c < frame.len; c++)
{
Serial.print(frame.buf[c], HEX);
Serial.write(' ');
}
Serial.write('\r');
Serial.write('\n');
}

bool ExampleClass::frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller)
{
printFrame(frame, mailbox);

return true;
}

ExampleClass exampleClass;

// -------------------------------------------------------------
void setup(void)
{
delay(1000);
Serial.println(F("Hello Teensy Single CAN Receiving Example With Objects."));

Can0.begin(500000);

//if using enable pins on a transceiver they need to be set on
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);

Can0.attachObj(&exampleClass);
exampleClass.attachGeneralHandler();
}


// -------------------------------------------------------------
void loop(void)
{
delay(1000);
Serial.write('.');
}

I'm using this example from Collin Kidder to Receive data from MR72 Nanoradar but i can't get full data compare using USBCAN I Adapter.
canbus soft.jpg
Here are image that data should be but i can get full 3 sector of ID 60B using teensy 3.6
Teensy 3.6.PNG

i event use https://github.com/tonton81/IFCT/blob/master/IFCT.h library but still no luck.

And why it cannot read ID 0X700 or it related to 11-bit filter?
 
Last edited:
Status
Not open for further replies.
Back
Top