Apparent Infinite Loop When Calling AxisCamera.getInstance()

We have a stripped down version of 2014VisionImageSample Project that is apparently going into an infinite loop when it reaches the AxisCamera.getInstance() call. This is our code:

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.camera.AxisCamera;

public class VisionSampleProject2014 extends SimpleRobot {

AxisCamera camera;

public void robotInit() {
    System.out.println("about to be initialized... the camera");
    camera = AxisCamera.getInstance();
    System.out.println("camera initialization complete");
}

public void autonomous() {
}

public void operatorControl() {
}

}

When the call to AxisCamera.getInstance is made, we can trace the code into the constructor using the debugger.
When cameraStartFn.call1 is called, it never returns (this code is inside AxisCamera.java inside WPILIB)

/**
 * Axis camera constructor that calls the C++ library to actually create the instance.
 * @param IPAddress 
 */
AxisCamera(String IPAddress) {
    Pointer ptr = Pointer.createStringBuffer(IPAddress);
    cameraStartFn.call1(ptr);
}

Our camera IP address is 10.36.63.100
So when we run the code above we expect to not find the camera because the default address is 10.36.63.11. The code does not find the camera as expected but it never returns and repeats the following error message.

Debugger output with incorrect camera IP address

Established connection to Debugger (handshake took 32700ms)

Excluding compile: com.sun.squawk.SymbolParser::getSignatureTypeAt

Excluding compile: com.sun.squawk.Method::getParameterTypes

[cRIO] about to be initialized… the camera
[cRIO] JavaCameraLib was compiled from SVN revision 2962
[cRIO] camera initialization complete
[cRIO] Default disabled() method running, consider providing your own
[cRIO]
[cRIO]
[cRIO] >>>>ERROR: S_errno_EINPROGRESS (0x00000044): Failed to connect to the camera …in CreateCameraSocket() in C:/WindRiver/workspace/WPILib/Vision/AxisCameraParams.cpp at line 457
[cRIO]
[cRIO]
[cRIO] >>>>ERROR: S_errno_EINPROGRESS (0x00000044): Failed to connect to the camera …in CreateCameraSocket() in C:/WindRiver/workspace/WPILib/Vision/AxisCameraParams.cpp at line 457
[cRIO]

<Error Messages repeat apparently forever>

When we pass in the correct IP address, the error messages go away but the call still never returns.
camera = AxisCamera.getInstance(“10.36.63.100”);

Debugger output with correct camera IP address

Established connection to Debugger (handshake took 2315ms)

Excluding compile: com.sun.squawk.SymbolParser::getSignatureTypeAt

Excluding compile: com.sun.squawk.Method::getParameterTypes

Attached JPDA debugger to localhost:2900
[cRIO] about to be initialized… the camera
[cRIO] JavaCameraLib was compiled from SVN revision 2962

<Output stops>


We’ve repeated this with 2 different cameras and 3 different computers. Does anyone have an idea what is wrong?
Thanks,
Angelique

Just using a webbrower can you connect to the camera from the driverstation?

Is the camera set to enable anonymous viewing?

I don’t use the WPI libraries to access the camera, but if I recall correctly, in the past (2011, 2012) the WPI library used to take about 10-12 seconds to initalize a connection to the camera, and it would block robot functionality while this was being done.

I am not sure, if this has been fixed or rectified in recent versions of WPILib.

What if you reset your camera to the default IPgiven to it using the axis camera tool. Does the code work then?

Yes, the camera image display’s fine in the DS and when browsing directly. And anonymous viewing/login is enabled.

We will try moving the camera’s IP to the default tonight.

Thanks for the suggestion

Brian*

Have you created an an account with the username and password “FRC”?

We moved it to the default IP address and added the FRC account and somewhere along those lines, it worked!!! Thanks for your help!
-Angelique:D

great!