|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#6
|
||||
|
||||
|
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);
}
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;
}
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? Last edited by Bryscus : 26-02-2010 at 18:24. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |