Go to Post Afterall, there's a thread for everything and everything in it's thread. - Molten [more]
Home
Go Back   Chief Delphi > Technical > Electrical > CAN
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 26-02-2010, 17:35
Bryscus's Avatar
Bryscus Bryscus is offline
EE, CpE
AKA: Bryce B.
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 1999
Location: Jupiter, FL
Posts: 173
Bryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud ofBryscus has much to be proud of
Re: CAN Jaguar enhancements

Jason,

Let me apologize first. I was apparently having a long day and misspoke a number of times. I see what you are trying to do now and also must say that the mode is also set at initialization for C++ as well - I remembered incorrectly. I must warn you that I do not have any Java experience, so if there are any weird errors that are logical because of syntax I probably won't be able to spot them.

To preface my post, I am referencing Rev. 50 and 29 of the CANJaguar.java and JaguarCANDriver.java files, respectively located on the firstforge page.

Well, then. Let me begin:

1.) I'm not quite sure why you chose to make your LM_API_SYNC_GROUP_...(s) of type short and not byte. I do see that you cast them to a byte, but why not just keep them as bytes to begin with. Either way, unless there's some weird casting issue in Java, the group ID portion should still work just fine.

2.) In public void setControlMode(), you disableControl as you should. Do you make sure you re-enable control? You should also set up your encoder references again just to be safe and probably the number of lines too (couldn't hurt).

At this point, your code seems to look pretty good to me at least for switching modes. Next is my 2 bits for why your synchronous updates don't work.

1.) Your code looks good to me. I've delved into the bit masks and everything seems fine. Here's where it gets interesting. I'm willing to bet that the problem lies within the JaguarCANDriver.sendMessage() method that we can't see. Here is "protected void sendMessage(int messageID, byte[] data, int dataSize)":

Code:
 protected void sendMessage(int messageID, byte[] data, int dataSize) {
        final int[] kTrustedMessages = {
            LM_API_VOLT_T_EN, LM_API_VOLT_T_SET, LM_API_SPD_T_EN, LM_API_SPD_T_SET,
            LM_API_POS_T_EN, LM_API_POS_T_SET, LM_API_ICTRL_T_EN, LM_API_ICTRL_T_SET};

        byte i;
        for (i = 0; i < kTrustedMessages.length; i++) {
            if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) {
                sendTrustedDataBuffer[0] = 0;
                sendTrustedDataBuffer[1] = 0;
                // Make sure the data will still fit after adjusting for the token.
                if (dataSize > JaguarCANDriver.kMaxMessageDataSize - 2) {
                    // TODO: Error
                    return;
                }

                byte j;
                for (j = 0; j <
                        dataSize; j++) {
                    sendTrustedDataBuffer[j + 2] = data[j];
                }

                JaguarCANDriver.sendMessage(messageID, sendTrustedDataBuffer, dataSize + 2);
                return;
            }
        }
        JaguarCANDriver.sendMessage(messageID, data, dataSize);
    }
If you notice, the trusted messages are matched with constant values. This means that for trusted messages, the messageID does not contain the Device ID, otherwise the if statement with kTrustedMessages[i] would never be true. This means that JaguarCANDriver.sendMessage() must add the Device ID to the message that it sends (from m_deviceNumber). Normally this is fine, but this is BAD when you want to send a SYNC message that probably requires a Device ID value of 0. You might want to try setting m_deviceNumber to 0 before you send the sync command. So try:

Code:
    public void syncUpdate(short syncGroup){
        byte[] dataBuffer = new byte[8];
        dataBuffer[0] = (byte) syncGroup;
        //temporarily store m_deviceNumber;
        //set m_deviceNumber = 0;
        sendMessage(CAN_MSGID_API_SYNC, dataBuffer, (byte) 1);
        //restore m_deviceNumber to previous value;
    }
Again, I don't know the Java syntax so there's the pseudo-code.

Anyway, I think these are your problems. I have not implemented these changes in C++ yet, but I do have the plan to do so. I'll email Joe Hershberger about these potential issues. I've been looking at this code for 2-3 hours now so I think I'll just give it a rest for now.

I'm sorry if some of this doesn't make sense, but I'll try to answer any other questions that I can.

- Bryce

P.S. What is the status of the LEDs when your system stops working?
__________________
The opulence of the front office decor varies inversely with the fundamental solvency of the firm.

Last edited by Bryscus : 26-02-2010 at 18:24.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CAN Jaguar Malfunction PranavSathy CAN 4 21-02-2010 18:32
CAN Jaguar Synchronous Updates?? Bryscus Programming 3 30-01-2010 16:13
Getting started with CAN/Jaguar CVassos Programming 1 27-01-2010 23:43
CAN bus Jaguar intermittent errors bear1511 Programming 1 27-01-2010 22:49
Black Jaguar RS232->CAN - anyone? oddjob C/C++ 12 22-01-2010 16:25


All times are GMT -5. The time now is 02:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi