View Single Post
  #7   Spotlight this post!  
Unread 27-02-2010, 03:23
imac256 imac256 is offline
Registered User
AKA: Ian McInerney
FRC #2022 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2009
Rookie Year: 2009
Location: Aurora, IL
Posts: 30
imac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of lightimac256 is a glorious beacon of light
Re: CAN Jaguar enhancements

A couple of things:

1st:
The device number is set in the setTransaction method in the sendMessage call. Here is the code for that from Rev 50.
Code:
    byte setTransaction(int messageID, byte[] data, byte dataSize) {
        int ackMessageID = LM_API_ACK | m_deviceNumber;

        // Make sure we don't have more than one transaction with the same Jaguar outstanding.
        synchronized (m_transactionSemaphore) {
            // Throw away any stale acks.
//            receiveMessage(ackMessageID, kNoData, 10.0);
            // Send the message with the data.
            sendMessage(messageID | m_deviceNumber, data, dataSize);
            // Wait for an ack.
//            dataSize = receiveMessage(ackMessageID, kNoData, 0.0);
        }
        return dataSize;
The Bitwise OR operation in the sendMessage call appends the device number to the messageID field, so the sync routine should work since sendMessage is called directly.

The trusted messages feature works because they use a bitwise AND statement to determine the messageID for comparison, so this line:
Code:
if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) {
basically removes the device number from the ID temporarily for the check against the message headers to determine if it is trusted or not and then goes from there.

2nd:
I think that you might want to include more than just the API call in the messageID. For the syncronization program I am writing for my team in C++ I include every field so that my final message ID is this:
Code:
#define CAN_MSGID_MFR_BCAST         0x00000000    //Define the Broadcast manufacturer
//Define the Syncronization message Header
#define LM_API_SYNC       CAN_MSGID_DTYPE_BCAST | CAN_MSGID_MFR_BCAST| CAN_MSGID_API_SYNC
Unfortunately I have not had much time to actually test it thoroughly, but I believe it works. I will have to fire up the cRIO and some Jaguars that we kept this week to see what happens.

That is all that I notice right now, but with more information about what the Jaguars are doing we should be able to help more.

-Ian McInerney
Programmer, Team 2022
Reply With Quote