Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Early CAN packets not rec'd by IFCT on Teensy 3.2

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Posts
    11

    Early CAN packets not rec'd by IFCT on Teensy 3.2

    Greetings. I am running IFCT on a 3.2 on Arduino 1.8.8. I am talking to a KDE DirectESC (an Electronic Speed Controller, or ESC) over the CAN bus. I can query the state of the ESC using CAN, and I do so.

    My app is simple: write a CAN packet which queries some trivial state on the ESC, call delay(2), then read, if it's available, the response.

    My CANalyst-II CAN bus analyzer tells me that when I send the query, the ESC responds pretty much immediately (the time stamps in the analyzer are supplied by the analyzer and not by Windows). Oddly, the very first response from the ESC is not seen by the Teensy. The rest of the responses are. When I say "seen", I mean that the ISR function in the IFCT source does not see the response (I know because I have mod'd the ISR to capture the data packets which are collected by the ISR).

    Why wouldn't all packets sent to the 3.2 be seen by IFCT?

    Thanks.

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,025
    have you got multiple mailbox receptions or fifo enabled?
    what does Can0.mailboxStatus(); show?

    I say this because you posted no code and you are using delays. The hardware buffers of CAN if not read promptly can be overwritten by hardware, causing your earliest frame to
    be lost. That delay could be sufficient enough for that depending on the quantity of frames streaming in and the amount of buffers and/or FIFO you have loaded.
    Last edited by tonton81; 04-13-2019 at 12:57 PM.

  3. #3
    Junior Member
    Join Date
    Feb 2019
    Posts
    11
    The setup code for IFCT is:
    Can0.begin(baudrate); // baudrate is 1000000
    Can0.enableFIFO();
    Can0.enableFIFOInterrupt();
    Can0.intervalTimer();

    The relevant code which write/reads to the CANbus is:
    union frame_id_t {
    struct {
    uint8_t object_address;
    uint8_t destination_id;
    uint8_t source_id;
    uint8_t priority: 5;
    uint8_t unused: 3;
    };
    uint32_t value;
    } id;
    ...
    id.object_address = 3;
    id.destination_id = dest;
    id.source_id = src;
    id.priority = 0;

    message.id = id.value;
    message.len = 0;
    Can0.write(message);
    delay(2);
    if (Can0.available())
    {
    Can0.read(rxmsg);
    ...print stuff...
    }

    I do have a CANalayst bus analyzer on the bus. The entirety of activity it sees on the bus is shown in the following screenshot from the tool:
    Click image for larger version. 

Name:	Screenshot (38).jpg 
Views:	23 
Size:	63.3 KB 
ID:	16415

    The message labeled in the above image as Index 00001 is not showing up as being read by my app.

    In the IFCT driver, I made the following changes to IFCT.cpp (the IFCT package was grabbed from github earlier this week):
    - I added: "uint32_t _rasd0, _rasdx0" as global vars to the driver.
    - In the two place in IFCT::IFCT_message_ISR() where dataIn is declared and inited, just after the declaration/init, I set, for the first dataIn instance, _rasd0 to dataIn, and in the second dataIn instance, _rasdx0 to dataIn. In my app, I can see if any dataIn variable in the ISR ever saw the data I claim is missing: the driver never saw the incoming message. I did not set up an exam of the mailboxStatus() code because it is my belief, that with so little CAN traffic, it won't get invoked.

    I hope this helps. Sorry for not being clearer before.

    bob

  4. #4
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,025
    it’s the first message lost after teensy bootup? or it’s always missing when running continuously?

  5. #5
    Junior Member
    Join Date
    Feb 2019
    Posts
    11
    First message after bootup is lost. I can create other scenarios where the first *few* messages are lost after bootup. In all cases, once things start working, they seem to stay working.

  6. #6
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,025
    in any case after bootup all the registers are cleared so its impossible to guarentee the beginning frames. however, why are you using Can0.begin(rate), that is not part of the library, if a baudrate is needed you should use Can0.setBaudRate(1000000);

    Have you tried non-FIFO mode as well? just set the callback same as it is now (i dont see your full code), and just enable interrupts of the mailboxes, which can be seen in the mailbox examples

    IFCT supports Can0.teensyThreads(); as well in case you prefer it over intervalTimer

    IFCT was able (when I tested) to stream a payload of 8KB over CAN dissambled at source and reassembled at endpoint with a valid CRC, so the dataflow can definately be handled

Posting Permissions

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