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

Thread: canbus problem flexcan teensy 3.2 multiple id streams

  1. #1
    Junior Member
    Join Date
    Nov 2020
    Posts
    2

    canbus problem flexcan teensy 3.2 multiple id streams

    Hi

    I am having problems with can messages

    i designed a car screen with nextion and teensy 3.2

    It has worked quite well for me with different can IDs.

    the problem is that I want to send multiple streams id for the same id of can that is to say that for an id of 1000 for example I can be receiving many messages using a byte with an id in each message

    currently i have been using it like this

    if ( CANbus.read(rxmsg) ) {
    switch (rxmsg.id){
    case 1000:

    FAULT = (float)(rxmsg.buf[0]);
    FAULTCOUNT = (float)(rxmsg.buf[1]);
    FAULTCODES = (float)(rxmsg.buf[2]);
    VANALOGSUPPLY = (float)(rxmsg.buf[3]);
    AUX9_10STATUS = (float)(rxmsg.buf[4]);
    DATAFLASHCHKSUM = (float)(rxmsg.buf[5]);
    FUELCALC = (float)(rxmsg.buf[6]);
    HWBLOCK1 = (float)(rxmsg.buf[7]);

    now I want the id to be 1000 all the time but for rxmsg.buf [0] to contain the id of the message, in the ecu I use I can tell you that the id of the frame is 1 for example and assign it to byte 0

    I have tried like this but it is not working for me

    if ( CANbus.read(rxmsg) ) {
    switch (rxmsg.buf[0]){
    case 1:

    FAULTCOUNT = (float)(rxmsg.buf[1]);
    FAULTCODES = (float)(rxmsg.buf[2]);
    VANALOGSUPPLY = (float)(rxmsg.buf[3]);
    AUX9_10STATUS = (float)(rxmsg.buf[4]);
    DATAFLASHCHKSUM = (float)(rxmsg.buf[5]);
    FUELCALC = (float)(rxmsg.buf[6]);
    HWBLOCK1 = (float)(rxmsg.buf[7]);


    somebody could help me?

    thanks!

  2. #2
    Junior Member
    Join Date
    Nov 2020
    Posts
    2
    any help?

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    399
    Quote Originally Posted by cruz177 View Post
    if ( CANbus.read(rxmsg) ) {
    switch (rxmsg.buf[0]){
    case 1:

    FAULTCOUNT = (float)(rxmsg.buf[1]);
    FAULTCODES = (float)(rxmsg.buf[2]);
    VANALOGSUPPLY = (float)(rxmsg.buf[3]);
    AUX9_10STATUS = (float)(rxmsg.buf[4]);
    DATAFLASHCHKSUM = (float)(rxmsg.buf[5]);
    FUELCALC = (float)(rxmsg.buf[6]);
    HWBLOCK1 = (float)(rxmsg.buf[7]);
    Does rxmsg.buf[0] indeed contain 0x01? You could verify this by serial-printing the value:
    Code:
    if ( CANbus.read(rxmsg) ) {
        Serial.printf("0x%02X", rxmsg.buf[0]);
        switch (rxmsg.buf[0]){
        case 1: 
    
            FAULTCOUNT = (float)(rxmsg.buf[1]);
            FAULTCODES = (float)(rxmsg.buf[2]);
            VANALOGSUPPLY = (float)(rxmsg.buf[3]);
            AUX9_10STATUS = (float)(rxmsg.buf[4]);
            DATAFLASHCHKSUM = (float)(rxmsg.buf[5]);
            FUELCALC = (float)(rxmsg.buf[6]);
            HWBLOCK1 = (float)(rxmsg.buf[7]);
    Paul

Posting Permissions

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