The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Several different topics, but hopefully the answers don't have to be elaborate.
It says "netduino go (and all 4.2 upgrades)" on the download page, and Plus is not mentioned. So should I not upgrade to .NET Framework 4.2 and SDK 4.2 if I have a Plus?
I also wonder if there's new released firmware, as I've been looking for 1-Wire support that was discussed in the forum some time ago. I now have 4.1.1.0.
I upgraded to .NET 4.2 and SDK 4.2 (anyhow) and there's a weird problem with possibly garbage collect. If I run this with a Thread.Sleep of 10 or 100 doesn't matter. It will anyway get out of memory after a rather short while. If I add a Debug.print it will not. Isn't memory management performed during Thread.Sleep?
Sadly below is the only way I've found to switch meaning of different ports. This should not have been handled as instances, for memory and performance reasons. Is there a way to address the ports and port configuration more directly?
The code:
public static bool scan(out int X, out int Y)
{
analog1 = new AnalogInput(X2);
analog2 = new AnalogInput(X1);
digital1 = new OutputPort(Y1, false);
digital2 = new OutputPort(Y2, true);
int valueX = analog1.Read();
X = adapt(valueX);
analog1.Dispose();
analog2.Dispose();
digital1.Dispose();
digital2.Dispose();
analog1 = new AnalogInput(Y1);
analog2 = new AnalogInput(Y2);
digital1 = new OutputPort(X2, false);
digital2 = new OutputPort(X1, true);
int valueY = analog2.Read();
Y = adapt((range - 1) - valueY);
analog1.Dispose();
analog2.Dispose();
digital1.Dispose();
digital2.Dispose();
analog1 = null;
analog2 = null;
digital1 = null;
digital2 = null;
return valueX != range - 1 && valueY != range - 1;
}
Cheers,
Anders
Edited by Stefan, 21 August 2012 - 08:51 AM. Added [code] tags
It says "netduino go (and all 4.2 upgrades)" on the download page, and Plus is not mentioned. So should I not upgrade to .NET Framework 4.2 and SDK 4.2 if I have a Plus?
I also wonder if there's new released firmware, as I've been looking for 1-Wire support that was discussed in the forum some time ago. I now have 4.1.1.0.
1-Wire is not yet supported in a non-beta build, it's only supported in a specific 4.1.1 beta build.
I upgraded to .NET 4.2 and SDK 4.2 (anyhow) and there's a weird problem with possibly garbage collect. If I run this with a Thread.Sleep of 10 or 100 doesn't matter. It will anyway get out of memory after a rather short while. If I add a Debug.print it will not. Isn't memory management performed during Thread.Sleep?
Good question, I don't -think- it's performed during a sleep. I thought the GC is started at the end of a loop or method. But I can't say for sure, I'm no expert in these matters.
I do know though, that it's possible to force garbage collecting, with Debug.GC(true);
Sadly below is the only way I've found to switch meaning of different ports. This should not have been handled as instances, for memory and performance reasons. Is there a way to address the ports and port configuration more directly?
I'm not sure what you're trying to do to be honest. I see you are using the same pins for both digital and analog, but what is connected to it? I ask this, because this could be potentially dangerous. Digital signals are 5V tolerant, analog signals are not.
All considered, it works fine if I have one Debug.print in the external loop calling scan(), and hopefully it doesn't lower performance too much when not communicating with a PC, but it seems redundant and a crutch.
A touch screen, using the principle described in Practical Arduino (chapter 8), transferred to Netduino. Except for the "memory loss" problem it all works nicely.
The project is described here: http://abiro.com/w/2...uch-the-screen/
I dusted the project off yesterday, to see if I can improve it.
1-Wire is not yet supported in a non-beta build, it's only supported in a specific 4.1.1 beta build.
Good question, I don't -think- it's performed during a sleep. I thought the GC is started at the end of a loop or method. But I can't say for sure, I'm no expert in these matters.
I do know though, that it's possible to force garbage collecting, with Debug.GC(true);
I'm not sure what you're trying to do to be honest. I see you are using the same pins for both digital and analog, but what is connected to it? I ask this, because this could be potentially dangerous. Digital signals are 5V tolerant, analog signals are not.
Great about 4.2, despite 1-Wire. This would be hard to implement on my own in C#, so I won't try in any case .
Garbage collect after a loop or call seems very unlikely (and potentially very inefficient). I'll use Debug.GC instead of Debug.print. Thanks.
Hi Anders,
Garbage collection should happen automatically whenever memory gets tight. If you allocate an object when there's not enough contiguous memory available, garbage collection should kick in then to try to find you enough space.
I'm following your example but don't quite understand...are you saying that the garbage collector in NETMF 4.2 is not collecting fully and that you need to call Debug.GC(true) to force it to collect?
Chris
Garbage collection should happen automatically whenever memory gets tight. If you allocate an object when there's not enough contiguous memory available, garbage collection should kick in then to try to find you enough space.
I'm following your example but don't quite understand...are you saying that the garbage collector in NETMF 4.2 is not collecting fully and that you need to call Debug.GC(true) to force it to collect?
Chris
I've now updated to 4.2 firmware, so I'll check if it behaves differently, which it should not the least due to the more free RAM, but in any case Debug.GC took the problem away for 4.1. Not that my application uses large arrays or such.
At the time of testing I had .NET 4.2, SDK 4.2 and firmware 4.1.
I've now updated to 4.2 firmware, so I'll check if it behaves differently, which it should not the least due to the more free RAM, but in any case Debug.GC took the problem away for 4.1. Not that my application uses large arrays or such.
At the time of testing I had .NET 4.2, SDK 4.2 and firmware 4.1.
Okay, great, thank you for the clarification.
The Garbage Collector in .NET MF 4.1 had a few limitations--which were fixed in .NET MF 4.2. This is one of the reasons it is so important that all NETMF boards are upgraded to .NET MF 4.2. Incorrectly running out of memory--in production devices deployed in the field--is not a good scenario.
The Garbage Collector in .NET MF 4.1 had a few limitations--which were fixed in .NET MF 4.2. This is one of the reasons it is so important that all NETMF boards are upgraded to .NET MF 4.2. Incorrectly running out of memory--in production devices deployed in the field--is not a good scenario.
Chris
Agreed!
With .NET 4.2 came changes to how analog inputs (separate from digital pins and scaling) and serial output (Write no longer returns bytes sent) work. I resolved that, yet I get InvalidOperationException instead. I'm not sure on what, as it doesn't point to a specific line in my code. Hopefully I'll find a remedy.
This is how the code looks now. adapt() is somewhat redundant as I can do scaling via AnalogInput, yet I also do border detection there.
public static bool scan(out int X, out int Y)
{
analog1 = new AnalogInput(aX2);
analog2 = new AnalogInput(aX1);
digital1 = new OutputPort(dY1, false);
digital2 = new OutputPort(dY2, true);
int valueX = (int)(analog1.Read() * range);
X = adapt(valueX);
Hi Anders,
Can you please provide a repro case which we can run here? A small, complete project file which raises the exception?
Also, SerialPort.Write should still return the number of bytes written. Are you getting "0" returned each time?
Chris
Hi Anders,
We'll need the source. To understand why you're getting an exception, we need to run the code and see where the exception is thrown.
Alternatively...what line is the exception thrown on?
Chris
Noted:
With Debug.GC: "A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll", likely at the first call to Debug.GC.
Without Debug.GC: Loops for almost 20 times, then hangs.
System.InvalidOperationException occurs both for Microsoft.SPOT and SecretLabs.NETMF classes.
For both it usually happen in Thread.Sleep(10) based on Debug.Prints. I never see from the exception what line is causing the problem.
When that happens I need to power cycle or reset the Netduino to be able to deploy new software.
It's still scan() that causes it, as it works fine if I simply comment out the call to scan and simulate values for touched, X and Y, but I can't see how it's my code's fault per se.