how to use CAN message type MSG_CMD?
Posted: Mon Sep 21, 2015 9:09 pm
I wonder if I could get some help from the GPIO gurus on sending a CAN bus message. My code is based on GPIO_Template_1101. I am trying to "push" 8 bytes of data between two identical tables on two GPIO boards using a CAN bus MSG_CMD.
I defined and allocated a new table (my_door), and put it into tables[10] :
I am creating a CAN message every 100 ms, similar to grabMS2vars(), but I am trying to "push" the data directly to the bus, not request it (this seems way more efficient). I am using MSG_CMD as the CAN message type.
I am presently using only one GPIO board, and monitoring the CAN bus with a Total Phase Komodo. The message is there, the CAN header is as I expect (offset=0, message type=0, from device=1, to device=5, table=11), and there are 8 data bytes, BUT THEY ARE ALWAYS ZERO! I am putting data into the first 8 bytes of my structure, and I have verified thru outpc and TunerStudio that the data is really there. Do I need to copy the data to a CAN buffer somewhere? Am I just miss-using the MSG_CMD type? The CAN bus code looks so complex, I dont want to start hacking at it.
Thanks
-bill
I defined and allocated a new table (my_door), and put it into tables[10] :
Code: Select all
const tableDescriptor tables[NO_TBLES] = {
// RAM copy FLASH copy Table Size
{ NULL, (unsigned int *)cltfactor_table, sizeof(cltfactor_table), 0x3C },
{ NULL, (unsigned int *)sprfactor_table, sizeof(sprfactor_table), 0x3C },
{ NULL, (unsigned int *)linefactor_table, sizeof(linefactor_table), 0x3C },
{ NULL, (unsigned int *)loadfactor_table, sizeof(loadfactor_table), 0x3C },
{ (unsigned int *)&inpram, (unsigned int *)&in1flash, sizeof(inputs1), 0x3C },
{ (unsigned int *)&in2ram, (unsigned int *)&in2flash, sizeof(inputs2), 0x3C },
{ (unsigned int *)&txbuf, NULL, sizeof(txbuf), 0x3C },
{ (unsigned int *)&outpc, NULL, sizeof(outpc), 0x3C },
{ NULL, (unsigned int *)&outmsg, sizeof(outmsg), 0x3C },
{ (unsigned int *)msvar, NULL, sizeof(msvar), 0x3C },
{ (unsigned int *)&my_door, NULL, sizeof(my_door), 0x3C },
{ (unsigned int *)&sis_door, NULL, sizeof(sis_door), 0x3C },
{ NULL, NULL, 0, 0x3C },
{ NULL, NULL, 0, 0x3C },
{ NULL, (unsigned int *)&Signature, sizeof(Signature), 0x3C },
{ NULL, (unsigned int *)&RevNum, sizeof(RevNum), 0x3C }
};
Code: Select all
void sendVarsToSisterBrd(void)
{
unsigned char ix;
ix = can[1].cxno_in;
can[1].cx_msg_type[ix] = MSG_CMD;
can[1].cx_varbyt[ix] = 8; // always send 8 bytes
can[1].cx_myvarblk[ix] = 10; // 10 = my_door; 11 = sis_door
can[1].cx_myvaroff[ix] = 0; // always start from the beginning of the table
can[1].cx_destvarblk[ix] = 11; // inpram.sisVarBLK //the sister board uses the same tables
can[1].cx_destvaroff[ix] = 0; // and same offset
can[1].cx_dest[ix] = 5; // inpram.sisCanID //temporary; sister device CAN address
send_can(1);
//can_mmsclk = 0; // not sure what this is for
return;
}
I am presently using only one GPIO board, and monitoring the CAN bus with a Total Phase Komodo. The message is there, the CAN header is as I expect (offset=0, message type=0, from device=1, to device=5, table=11), and there are 8 data bytes, BUT THEY ARE ALWAYS ZERO! I am putting data into the first 8 bytes of my structure, and I have verified thru outpc and TunerStudio that the data is really there. Do I need to copy the data to a CAN buffer somewhere? Am I just miss-using the MSG_CMD type? The CAN bus code looks so complex, I dont want to start hacking at it.
Thanks
-bill