I’ve spent the last 48 hours trying to configure CAN communication through Java without any success. I’m getting consistent timeouts while trying to connect to the Jaguars. I’d really appreciate any help from anyone who has successfully configured CAN.
Here’s my current configuration:
-A single black Jaguar, flashed with Black_Jaguar_92 firmware, device ID set to ‘2’, connected via its serial/CAN port (the left one) with a hybrid serial cable/CAN terminator (built to the manual’s specs) to the serial port on the cRIO. CAN terminator in place on the other port of the Jaguar.
-Jaguar firmware version/device ID and CAN/serial cables/terminators verified via BDC-COMM. Outgoing CAN communication from the Jaguar verified by chaining up to 4 black jaguars and operating them simultaneously through BDC-COMM.
-cRIO freshly imaged with the 2011_v25 image, with the “Black Jaguar Serial Bridge” selected as the CAN driver before imaging. Verified serial port functionality by connecting a computer and observing cRIO boot process through HyperTerminal. Boot is observable through serial connection until NetConsole plugin loads.
-All FRC Java plugins updated to the latest revision (posted Jan 17th).
Here’s my test code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.CANJaguar;
import edu.wpi.first.wpilibj.Timer;
public class CANTestBot extends IterativeRobot {
CANJaguar jag;
public void robotInit() {
for (int i = 0; i < 5; i++) { //try to instantiate the jag a few times
try {
jag = new CANJaguar(2);
System.out.println(jag.getFirmwareVersion());
} catch(Exception e) {
e.printStackTrace();
}
Timer.delay(1);
}
}
}
Here’s the NetConsole output from a deploy of this code (with the cRIO “Console Out” DIP switch set to OFF):
[cRIO] VxWorks
[cRIO]
[cRIO] Copyright 1984-2006 Wind River Systems, Inc.
[cRIO]
[cRIO] CPU: MPC5200 – Wind River Lite5200 BSP.
[cRIO] Runtime Name: VxWorks
[cRIO] Runtime Version: 6.3
[cRIO] BSP version: 2.0/10
[cRIO] Created: Jul 29 2009, 13:41:47
[cRIO] ED&R Policy Mode: Deployed
[cRIO] WDB Comm Type: WDB_COMM_END
[cRIO] WDB: Ready.
[cRIO]
[cRIO] Leaving debug.o StartupLibraryInit
[cRIO] * Loading StartupDlls: NiRioRpc
[cRIO] * Loading StartupDlls: niorbs
[cRIO] * Loading StartupDlls: NiViSrvr
[cRIO] * Loading StartupDlls: visa32
[cRIO] * Loading StartupDlls: nivissvc
[cRIO] task 0xee4928 (PAL00fb5da8) deleted: errno=0 (0) status=0 (0)
[cRIO] NI-RIO Server 3.2 started successfully.
[cRIO] task 0xc5fe68 (NiRioRpc) deleted: errno=0 (0) status=0 (0)
[cRIO] * Loading StartupDlls: nivision
[cRIO] * Loading StartupDlls: niserial
[cRIO] * Loading StartupDlls: FRC_FPGA
[cRIO] * Loading StartupDlls: FRC_NetworkCommunication
[cRIO] task 0x1b0d818 (t2) deleted: errno=0 (0) status=0 (0)
[cRIO] FRC_NetworkCommunication was compiled from SVN revision 2203
[cRIO]
[cRIO] NI-VISA Server 4.5 started successfully.
[cRIO] task 0xe63110 (t1) deleted: errno=1835009 (0x1c0001) status=1 (0x1)
[cRIO] FPGA Hardware GUID: 0x2EAA5E59CAF1A8A966853A011B61CC91
[cRIO] FPGA Software GUID: 0x2EAA5E59CAF1A8A966853A011B61CC91
[cRIO] FPGA Hardware Version: 2011
[cRIO] FPGA Software Version: 2011
[cRIO] FPGA Hardware Revision: 1.5.3
[cRIO] FPGA Software Revision: 1.5.3
[cRIO] * Loading StartupDlls: FRC_BlackJagBridgePlugin
[cRIO] FRC_BlackJagBridgePlugin was compiled from SVN revision 60
[cRIO] * Loading StartupDlls: FRC_JavaVM
[cRIO]
[cRIO]
[cRIO] [OTA Server] Version: 2011 FRC, Jan 6 2011, 09:47:42
[cRIO]
[cRIO]
[cRIO] Welcome to LabVIEW Real-Time 8.6.1f3
[cRIO]
[cRIO] [Squawk VM] Version: 2011 FRC, Jan 17 2011, 16:12:19
[cRIO]
[cRIO] [Squawk VM] Version: 2011 FRC, Jan 17 2011, 16:12:19
[cRIO] FPGA Hardware GUID: 0x2eaa5e59caf1a8a966853a011b61cc91
[cRIO] FPGA Software GUID: 0x2eaa5e59caf1a8a966853a011b61cc91
[cRIO] edu.wpi.first.wpilibj.can.CANTimeoutException
[cRIO] at edu.wpi.first.wpilibj.can.CANExceptionFactory.checkStatus(CANExceptionFactory.java:38)
[cRIO] at edu.wpi.first.wpilibj.can.JaguarCANDriver.receiveMessage(JaguarCANDriver.java:67)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.receiveMessage(CANJaguar.java:579)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.receiveMessage(CANJaguar.java:584)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.getTransaction(CANJaguar.java:634)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.getFirmwareVersion(CANJaguar.java:1192)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.initCANJaguar(CANJaguar.java:240)
[cRIO] at edu.wpi.first.wpilibj.CANJaguar.<init>(CANJaguar.java:267)
[cRIO] at edu.wpi.first.wpilibj.templates.CANTestBot.robotInit(CANTestBot.java:27)
[cRIO] at edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:73)
[cRIO] at edu.wpi.first.wpilibj.RobotBase.startApp(RobotBase.java:154)
[cRIO] in virtual method #10 of javax.microedition.midlet.MIDlet(bci=17)
[cRIO] at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(64)
[cRIO] at com.sun.squawk.imp.MIDletMainWrapper.main(110)
[cRIO] in virtual method #95 of com.sun.squawk.Klass(bci=25)
[cRIO] at com.sun.squawk.Isolate.run(1506)
[cRIO] at java.lang.Thread.run(231)
[cRIO] in virtual method #47 of com.sun.squawk.VMThread(bci=42)
[cRIO] in static method #3 of com.sun.squawk.VM(bci=6)
</snip four more CANTimeoutException stack traces>
If I turn the cRIO “Console Out” DIP switch to ON, then the cRIO boot process hangs after:
[cRIO] * Loading StartupDlls: FRC_BlackJagBridgePlugin
[cRIO] FRC_BlackJagBridgePlugin was compiled from SVN revision 60
…and the cRIO is unresponsive until rebooted.
What have I missed, where have I gone wrong? Thanks in advance.