canbus problem flexcan teensy 3.2 multiple id streams

cruz177

Member
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!
 
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) ) {
    [COLOR="#FF0000"]Serial.printf("0x%02X", rxmsg.buf[0]);[/COLOR]
    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
 
Back
Top