Forum Rule: Always post complete source code & details to reproduce any issue!
Page 8 of 8 FirstFirst ... 6 7 8
Results 176 to 178 of 178

Thread: IFCT - Improved Flexcan Teensy Library

  1. #176
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,021
    Please check the simple examples posted with the library, it shows you how to send/receive the 8 bytes.
    You can do your 32 bit conversions before/after if necessary

  2. #177
    Junior Member
    Join Date
    Jun 2019
    Posts
    4
    Code:
    void loop() {
      CAN_message_t msg;
      if ( Can0.read(msg) ) canSniff(msg);
    }
    
    void canSniff(const CAN_message_t &msg) {
      Serial.print("MB "); Serial.print(msg.mb);
      Serial.print("  LEN: "); Serial.print(msg.len);
      Serial.print(" EXT: "); Serial.print(msg.flags.extended);
      Serial.print(" REMOTE: "); Serial.print(msg.rtr);
      Serial.print(" TS: "); Serial.print(msg.timestamp);
      Serial.print(" ID: "); Serial.print(msg.id, HEX);
      Serial.print(" Buffer: ");
      for ( uint8_t i = 0; i < msg.len; i++ ) {
        Serial.print(msg.buf[i], HEX); Serial.print(" ");
      } Serial.println();
    }
    I'm unsure of if FIFO is what im after. Basically what Id want is to do would be to

    Code:
    X = Can0.read(0x234) // read a specific CAN ID and address is to a variable. is this possible? I know my nomenclature is going to be wrong but I hope you get what I'm trying to achieve.
    or do I do a

    Code:
    if(msg.id = 0x234)
    {
      for ( sint8_t i = 0; i < msg.len; i++ ) 
     {
        b =x*10
        a=msg.buf[i]
        x = b+a       // makes it a single string of bits
      }
    
    }

    Sorry I am a total nub at CAN messages.

  3. #178
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,021
    it’s just an array of 8 bytes, by default it will pickup all IDs however you can filter it in callback via software or hardware via filtering.

    your second code is software filtering but yeah that’s acceptable.
    you can just set the variable to X = msg.id; .
    Since that is a standard frame ID it uses 11bits, I would still use 32bit unsigned for peace of mind.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •