Troubles with Serial Cam L1, T43 Module

Okay, so I’m finally getting around to trying out more of the modules I bought during the Christmas sale (since taylorza helped me resolve the issues I had with the hub and motor driver)

Now I’m trying very very basic things, and failing miserably again :frowning:

First, I tried just capturing images from the SerialCameraL1 Module, and displaying the images on the t43 module.

This was a disaster. Just having the T43 module connected caused the raptor (and then the hydra) to reboot frequently.

I checked the current draw, and most of the time it would max out around 420mA, but sometimes it would go up to 610-620 mA. (all I have attached to the raptor is the t43 module, serialcamera and usbclientdp)
So I suspect I simply cant use the t43 module if I am debugging via standard (500ma) USB port.

But even trying to deploy code to use it without the display module attached, then attaching the t43, then switching power to a 2.1A USB Battery, it still seemed to be rebooting.

Ive tried other USB ports just in case, but no difference. Ive also tried other power modules (usbDP and usbSP both). Ive tried other USB cables. Ive tried changing Sockets. Ivew tried powering the usbDP with just USB, with just the DC connector, and with both.

The docs for ther T43 and n18 are a little muddled - the first set is marked “Obsolete” and the 2nd set talks about needing to configure the display prior to use.

Ive tried using fez config, however this is problematic because of the reboots when connected to my PC. Also, a note says that configurations written by fez config are overwritten and lost on program execution anyway…

There is an example showing how to configure in code, but this example uses namespaces (GHI.Processor) that I cant resolve… So “Display.Populate()” is not found. I suspect this is also outdated/obsolete documentation. Is there anything up to date? or am I missing something? Is this necessary?

So I moved onto the N18 module (less power, seemingly no need to configure?)

Now I notice that the serialcameral1 module seems to be unpredictable as to if it ever has NewImageReady=true. I’ve gone through as many posts in the forum as I can find, and tried every suggestion I could find, and even the ones that seem to fix the problems for others seem to fail for me.

When I am occasionally able to get an image from the sercam, if I try to display it on the N18 module, I get either an exception, or a screen full of multicolor static snow. I cant find any documentation about scaling or cropping the image…

Combine this with the fact that when I deploy from visual studio, half the time it fails, and only eventually succeeds by plugging/unplugging/fingers crossing…this is with both the raptor, and the Hydra (although it is much worse with the hydra+)

Im thinking there -has- to be something obvious, some single root cause for all of my issues.

As far as I can tell, I have the latest software/firmware for everything,

GHI Elections NetMF SDK 2014.5.0.0 (R5)
NetMF Gadgeteer Core 2.43.10000.0
NetMF SDK 4.3 (SDK-R2-Beta) (4.3.2)
Visual Studio 2012 Professional Update 4
(And Visual Studio 2013 Professional Update 4)

Raptor:
TinyCLR 4.3.6
NetMF 4.3

So I have some basic questions, to see if I am missing something:

1: All of these things are supposed to work with the latest SW right? NetMF 4.3 is tested, and not some sort of unstable beta that people are just now trying out, right? Most people can get it to work normally, right?

2: How do you use display modules with the raptor/hyrdra, etc? DO you need to configure with Fez Config? Do you need to pre-configure and save this configuration in code? Does it matter? Why does the sample the web site directs us to, at https://www.ghielectronics.com/docs/34/graphics, not compile? “using GHI.Processor?” “Display.Populate()?”

3: Has anyone been able to use the T43 module on a raptor? On a standard 500mA usb port?

4: has anyone been able to get the SerialCameraL1 module to stream images reliably?

5: Are there more complete documents anywhere? Is there a recent/working example of code showing streaming from a serialcameraL1 to a display module (N18, T43?) I found a thread with fragments, and someone “demanding” a response, and understandable reactions to that, but even the supplied responses refer to older APIs, and wont compile on the recent/latest software. Also, SetRatio is documented as “sets the ratio” - but I still cant discover what ratio is being talked about. The samples shown in the “developers guide” compile, but even with the 100ms timer, “newImageReady” never (or extremely rarely) becomes true.

6: All of this struggling has taken a toll on my confidence as an embedded engineer. Why cant I get -any- of these things to work reliably? I’m a former Sr Microsoft engineer, I’ve been using Visual Studio since 1.0, .Net since it came our. I’ve written NetMF device drivers for my own commercial hardware (RFID devices)…I’ve been employed as an embedded firmware engineer for the past 10+ years… I’m a big fan of NetMF - but I cant get the serial camera or display modules to work.

Maybe I should pack it in and become a tomato farmer.

Okay… after some digging it looks like the N18 module is currently incompatible with the Raptor (edit: for displaying bitmaps from the serial camera)

https://www.ghielectronics.com/community/forum/topic?id=17180

And people are waiting on a patch/fix, right?

This program causes an exception when it tries to draw to the N18:


namespace GadgeteerApp2
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.  
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            new Thread(VideoStreamming).Start();
            Debug.Print("Program Started");
        }

        void VideoStreamming()
        {
            serCam.StartStreaming();
            Debug.Print("streaming started");
            while (true)
            {
                Thread.Sleep(100);
                if (serCam.NewImageReady)
                {
                    Debug.Print("new image");
                    var image = serCam.GetImage();

                    displayN18.SimpleGraphics.DisplayImage(image, 0, 0, 0, 0, displayN18.Width, displayN18.Height);

                }
            }
        }
    }
}

If I use the T43, I get the same issue. Are both of these displays currently not working with the Raptor? (when it comes to displaying bitmaps from the serial camera) ?

Some More info:

When I run this code, either

A] serCam.NewImageReady never becomes true, so the inner loop -never executes, or

B] serCam.NewImageReady does become true, but a gatgeteer.dll exception is generated on the DisplayImage line.

It seems to be random which symptom is shown when I power up and try to debug.

I’ve just tried a 2nd PC, installing everything fresh. Same thing.

I have no confidence in the serialCam, N18 or T43 modules working together at the moment. I am hoping someone will either point out something stupid that I’m doing, or tell me that these are known issues and that fixes are coming soon.

Take a look at this thread…
https://www.ghielectronics.com/community/forum/topic?id=17180

Yeah, that’s the thread I mentioned, leading me to believe that there’s just a bug in the current SDK meaning you can’t display camera images(bitmaps) to the N18 (and possibly T43) module(s) until the next SDK (unless you modify the framework and reencode the image)

I’m still unsure why I am finding the serial camera is so hard to use though (why, when streaming, it can go forever without having a NewImageReady, even when I try different timers, different threads, different sockets, etc) - but since I cant really display an image on anything until the SDK is fixed, I will put these aside for now.

Is there anyplace that shows an ETA for the next SDK refresh?

Anyone?

I’m using a powered hub… I’ve eliminated it being a power issue.

This is the T43 Display module, not the N18.

Is the image bug affecting the T43 module too?

(See attached image)

Apparently we are not supposed to use the SimpleGraphics.DisplayImage() function, but instead draw to a bitmap and call .Flush()

This seems to work:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp7
{
    public partial class Program
    {
        Bitmap bmap;

        // This method is run when the mainboard is powered up or reset.  
        void ProgramStarted()
        {
            bmap = new Bitmap((Int32)displayT43.Width, (Int32)displayT43.Height);
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            new Thread(VideoStreamming).Start();
            Debug.Print("Program Started");
        }

        void VideoStreamming()
        {
            serCam.StartStreaming();
            Debug.Print("streaming started");
            while (true)
            {
                Thread.Sleep(100);

                if (serCam.NewImageReady)
                {
                    Debug.Print("new image");
                    var image = serCam.GetImage();

                    bmap.DrawImage(0, 0, image, 0, 0, displayT43.Width, displayT43.Height);
                    bmap.Flush();
                }
            }
        }
    }
}

@ mtylerjr - The display bug that Sprigo linked has been fixed for the next SDK release. There are still no other work arounds and we do not have a release date just yet. Since R5 was a relatively minor release, you can always go back to R4 if needed.

Do you have any other modules connected in the designer or any other code in your project? The SerCam has always given us trouble. It uses serial which can lose data, usually under heavy loads, due to the way NETMF is structured internally. The changes Microsoft is making to NETMF should help this issue.

What sample on the graphics document does not compile? When using Gadgeteer, the displays are all configured for you. The SimpleGraphics interface works with no work on your part.

The T43 should run fine on the Raptor, we’ve use daily internally from regular USB ports.

The code you posted should work fine, were it not for the display issue in R5.

Thanks for the reply, John

Is it all serial devices that have issues with NetMF?

Is there a camera solution that others have migrated towards, that doesn’t suffer from this?

And what other details can you share about timelines (for Microsoft restricting the internals to eliminate lost data, or another SDK release)

Any info would be appreciated :slight_smile:

it’s the other way around. There’s an issue with netmf, where some serial data may not arrive correctly. All serial devices are potentially affected.

Ah, okay.

I remember, 18 months ago, them talking about this, or a similar serial bug, in the netduino netMF forums:

http://forums.agentwatches.com/index.php?/topic/129-serialportdatareceived-event-getting-all-of-the-data/

People have been complaining there for at least 2.5 years…

Has the serial code been really broken for that long?

(and if so, is it realistic to think it might be soonish?)

And does anyone have a working patch?

(Sorry for all the questions)

@ mtylerjr - Microsoft only recently has started showing serious activity again in NETMF. We are not sure when a fix will arrive and we do not have a patch sadly.

We do offer a camera module that uses USB host that does not suffer from this problem.