I’m looking for an example of how to schedule a message to be sent in a 1s loop. I tried the following. I don’t get an error, but I also don’t get many messages on the CAN bus.
iStatus = canSchedulerOpen( pCanControllers->hBoardHandle, CAN1, &phCanChn );
iStatus = canSchedulerGetCaps( phCanChn, &pCanCaps );
ucPacketSize = 8;
pMessage.wCycleTime = (pCanCaps.dwCmsDivisor / pCanCaps.dwCanClkFreq) * 1;
pMessage.bIncrMode = CAN_CTXMSG_INC_NO;
pMessage.bByteIndex = 0;
pMessage.dwMsgId = 0x243;
pMessage.uMsgInfo.Bytes.bType = CAN_MSGTYPE_DATA;
pMessage.uMsgInfo.Bytes.bFlags = CAN_MAKE_MSGFLAGS(ucPacketSize,0,0,0,0);
pMessage.uMsgInfo.Bits.srr = 0; //dont rx the tx
pMessage.uMsgInfo.Bits.ext = 0; //Standard
pMessage.uMsgInfo.Bits.edl = 0;
pMessage.uMsgInfo.Bits.fdr = 0;
pMessage.uMsgInfo.Bits.dlc = ucPacketSize;
pMessage.abData[0] = 0x40;
pMessage.abData[1] = 0x01;
pMessage.abData[2] = 0x00;
pMessage.abData[3] = 0x00;
pMessage.abData[4] = 0x00;
pMessage.abData[5] = 0x00;
pMessage.abData[6] = 0x00;
pMessage.abData[7] = 0x00;
iStatus = canSchedulerAddMessage( phCanChn, &pMessage, &pdwIndex );
iStatus = canSchedulerStartMessage( phCanChn, pdwIndex, 0 );
iStatus = canSchedulerActivate( phCanChn, TRUE );
Sleep(1000);
iStatus = canSchedulerStopMessage( phCanChn, pdwIndex );
iStatus = canSchedulerClose( phCanChn );