I’m having a problem with the Camera & EthernetJ11D modules on a Spider.
If I include the J11D module in designer the camera.CameraConnected and camera.BitmapStreamed events never fire. If I remove the J11D from the project the events are fired as expected.
Anybody else experienced this issue (or possibly confirm it)?
@ Sprigo - Can you post some code that reliably shows the problem? Using the latest 2014 R4 SDK, I had a camera and J11D module connected in the designer and both BitmapStreamed and CameraConnected fired fine.
I suspect that it’s the setup on this machine then John. Just created a new project with the following.
namespace GadgeteerApp5
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Debug.Print("Program Started");
camera.CameraConnected += camera_CameraConnected;
camera.BitmapStreamed += camera_BitmapStreamed;
}
void camera_BitmapStreamed(Camera sender, Bitmap e)
{
Debug.Print("Bitmap Streamed Event");
}
void camera_CameraConnected(Camera sender, EventArgs e)
{
Debug.Print("Camera Connected Event");
camera.StartStreaming();
}
}
}
Before adding the EthernetJ11D I get the output shown in Camera1.jpg. After adding the J11D I don’t see the camera events fire. If I don’t add the J11D to designer but manually create an instance AFTER registering the camera event everything appears to work normally.
@ Sprigo - When you say you manually created an instance after setting up the event, it worked, was it an instance of the EthernetJ11D module or the EthernetBuiltIn class from GHI.Networking? Have you by any chance tried with a different camera, Spider, or Ethernet module if you have any?
@ Sprigo -The problem is a race condition. I’m guessing you have the camera connected to the Spider all the time. So, when you power up the device, the camera is seen and the CameraConnected event is fired. When you have the events early in ProgramStarted, you subscribe to them before our host controller finishes initializing the device and you catch the event. When you put them after the Ethernet initialization, too much time has passed and the event already fired so you missed it.
To work around this, you can check the CameraReady property. It returns true when the camera is connected and not currently taking a picture. So if it is true, you can just call StartStreaming as the camera is already connected.
In your sample program, at the bottom of ProgramStarted, I added the following and it worked:
// With these here the events never fire. (Camera2.jpg)
camera.CameraConnected += camera_CameraConnected;
camera.BitmapStreamed += camera_BitmapStreamed;
if (camera.CameraReady)
camera.StartStreaming();