CAN: slow event handlers and buffer overflows

I would make a non gadgeteer app

That is a fantastic article, I get it now. What is the difference between a gadgeteer app and a non gadgeteer app? I will be staying with an embedded device, as my project will be integrated into the vehicle, so I am not sure if you mean that I should run this on a PC or not.

But I found with my previously posted code that when the CAN routine is left running, it eats up memory with each call of GetMessage(). Use a GC after each call and watch the debug window, you will see what I mean. Does the Dispose method actually disable the CAN engine? If it does, would that disable a DataReceived event handler? I ask if it disables it since I had to re-initialize it to use GetMessage().

Hi again

Gadgeteer is just an operating paradigm, that sits “above” the netmf layer.

Open Visual C# Express. Create a NEW project.

When you do that, the New Project pane comes up, and in the left pane there is “Gadgeteer” as an option (that takes you to the Gadgeteer model of app) as well as a “Micro Framework”. Select one of those, you’ll see some “templates” in the centre pane.

If you select Gadgeteer then you only get the one option, .Net Gadgeteer Application, in the centre pane.

Most of your issues, to me, seem that you have a scoping issue. You need to NOT dispose the CAN object, because that is what you need to interact with (that’s your null reference exception). But what you DO need to do is to manage how you manage your messagelist. You will probably find that the blob growth is caused by not cleaning up after that.

If you move to a model where you have the CAN object setup and establishment outside the scope of your “loop”, and you create one messagelist, and you read and re-use messagelist appropriately, you won’t have an issue.

oh, and one more comment. The previous testing you did is invalidated because you were blocking the ProgramStarted(). That may have actually been influencing things it shouldn’t have so step 1 is to remove that and then re-evaluate…

@ Brett, thanks for the suggestions! I will try to adjust my scope-issues and provide an update when it is available.