code/WPILib/CANJaguar.cpp
/**
 * Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication
 * 
 * Trusted messages require a 2-byte token at the beginning of the data payload.
 * If the message being sent is trusted, make space for the token.
 * 
 * @param messageID The messageID to be used on the CAN bus
 * @param data The up to 8 bytes of data to be sent with the message
 * @param dataSize Specify how much of the data in "data" to send
 * @return Status of send call
 */
Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication

Trusted messages require a 2-byte token at the beginning of the data payload.
If the message being sent is trusted, make space for the token.

@param messageID The messageID to be used on the CAN bus
@param data The up to 8 bytes of data to be sent with the message
@param dataSize Specify how much of the data in "data" to send
@return Status of send call
Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication Trusted messages require a 2 - byte token at the beginning of the data payload . If the message being sent is trusted make space for the token . @param messageID The messageID to be used on the CAN bus @param data The up to 8 bytes of data to be sent with the message @param dataSize Specify how much of the data in " data " to send @return Status of send call
INT32 CANJaguar::sendMessage(UINT32 messageID, const UINT8 *data, UINT8 dataSize)
{
	static const UINT32 kTrustedMessages[] = {
			LM_API_VOLT_T_EN, LM_API_VOLT_T_SET, LM_API_SPD_T_EN, LM_API_SPD_T_SET,
			LM_API_VCOMP_T_EN, LM_API_VCOMP_T_SET, LM_API_POS_T_EN, LM_API_POS_T_SET,
			LM_API_ICTRL_T_EN, LM_API_ICTRL_T_SET};
	INT32 status=0;
	for (UINT8 i=0; i<(sizeof(kTrustedMessages)/sizeof(kTrustedMessages[0])); i++)
	{
		if ((kFullMessageIDMask & messageID) == kTrustedMessages[i])
		{
			UINT8 dataBuffer[8];
			dataBuffer[0] = 0;
			dataBuffer[1] = 0;
			if (dataSize > 6)
			{
				return 0;
			}
			for (UINT8 j=0; j < dataSize; j++)
			{
				dataBuffer[j + 2] = data[j];
			}
			FRC_NetworkCommunication_JaguarCANDriver_sendMessage(messageID, dataBuffer, dataSize + 2, &status);
			return status;
		}
	}
	FRC_NetworkCommunication_JaguarCANDriver_sendMessage(messageID, data, dataSize, &status);
	return status;
}
INT32 CANJaguar :: sendMessage ( UINT32 messageID , const UINT8 * data , UINT8 dataSize ) { static const UINT32 kTrustedMessages [ ] = { LM_API_VOLT_T_EN , LM_API_VOLT_T_SET , LM_API_SPD_T_EN , LM_API_SPD_T_SET , LM_API_VCOMP_T_EN , LM_API_VCOMP_T_SET , LM_API_POS_T_EN , LM_API_POS_T_SET , LM_API_ICTRL_T_EN , LM_API_ICTRL_T_SET } ; INT32 status = 0 ; for ( UINT8 i = 0 ; i < ( sizeof ( kTrustedMessages ) / sizeof ( kTrustedMessages [ 0 ] ) ) ; i ++ ) { if ( ( kFullMessageIDMask & messageID ) == kTrustedMessages [ i ] ) { UINT8 dataBuffer [ 8 ] ; dataBuffer [ 0 ] = 0 ; dataBuffer [ 1 ] = 0 ; if ( dataSize > 6 ) { return 0 ; } for ( UINT8 j = 0 ; j < dataSize ; j ++ ) { dataBuffer [ j + 2 ] = data [ j ] ; } FRC_NetworkCommunication_JaguarCANDriver_sendMessage ( messageID , dataBuffer , dataSize + 2 , & status ) ; return status ; } } FRC_NetworkCommunication_JaguarCANDriver_sendMessage ( messageID , data , dataSize , & status ) ; return status ; }
Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication
Send a message on the CAN bus through the CAN driver in FRC_NetworkCommunication
// Make sure the data will still fit after adjusting for the token. // TODO: Error