code/WPILib/CANJaguar.cpp
/**
 * Execute a transaction with a Jaguar that sets some property.
 * 
 * Jaguar always acks when it receives a message.  If we don't wait for an ack,
 * the message object in the Jaguar could get overwritten before it is handled.
 * 
 * @param messageID The messageID to be used on the CAN bus (device number is added internally)
 * @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
 */
Execute a transaction with a Jaguar that sets some property.

Jaguar always acks when it receives a message.  If we don't wait for an ack,
the message object in the Jaguar could get overwritten before it is handled.

@param messageID The messageID to be used on the CAN bus (device number is added internally)
@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
Execute a transaction with a Jaguar that sets some property . Jaguar always acks when it receives a message . If we don ' t wait for an ack the message object in the Jaguar could get overwritten before it is handled . @param messageID The messageID to be used on the CAN bus ( device number is added internally ) @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
void CANJaguar::setTransaction(UINT32 messageID, const UINT8 *data, UINT8 dataSize)
{
	UINT32 ackMessageID = LM_API_ACK | m_deviceNumber;
	INT32 status = 0;
	semTake(m_transactionSemaphore, WAIT_FOREVER);
	receiveMessage(&ackMessageID, NULL, 0, 0.0f);
	status = sendMessage(messageID | m_deviceNumber, data, dataSize);
	wpi_assertCleanStatus(status);
	status = receiveMessage(&ackMessageID, NULL, 0);
	wpi_assertCleanStatus(status);
	semGive(m_transactionSemaphore);
}
void CANJaguar :: setTransaction ( UINT32 messageID , const UINT8 * data , UINT8 dataSize ) { UINT32 ackMessageID = LM_API_ACK | m_deviceNumber ; INT32 status = 0 ; semTake ( m_transactionSemaphore , WAIT_FOREVER ) ; receiveMessage ( & ackMessageID , NULL , 0 , 0.0f ) ; status = sendMessage ( messageID | m_deviceNumber , data , dataSize ) ; wpi_assertCleanStatus ( status ) ; status = receiveMessage ( & ackMessageID , NULL , 0 ) ; wpi_assertCleanStatus ( status ) ; semGive ( m_transactionSemaphore ) ; }
Execute a transaction with a Jaguar that sets some property.
Execute a transaction with a Jaguar that sets some property .
// Make sure we don't have more than one transaction with the same Jaguar outstanding. // Throw away any stale acks. // Send the message with the data. // Wait for an ack. // Transaction complete.