I have got an working FEZ Mini while debugging. Breakpoints are reached consistenly and got no problem at all with debugging.
But when I deploy the program I can’t get it working.
Should I do something escpecially to create a standalone FEZ Mini without being connected to a PC? I thought deploy is the way to get the files on the FEZ Mini and then can unplug the USB and connect it to a battery that everything should work fine.
What do you mean when you say, “can’t get it working”? How are you powering the Mini? How do you know if it is working or not (what is it supposed to do?)
Registering for the DataReceived event of the serial port should be done after the port has been opened.
In your main, doing [italic]while(true); [/italic]will slow down your program. You have put the main thread into a loop. Use [italic]Thread.Sleep(TimeOut.Infinite);[/italic]
You do a compare [italic]if (r == “T”)[/italic] to see if a ‘T’ has been received. You should be doing the compare as [italic]if (t.Equals(“T”))[/italic]. What you did was comparing references not the content of the strings.
I suggest you single step in the debugger and follow the data flow.
In most cases, if the program works properly while connected to the debugger it will work standalone.
public static void Main()
{
Program program = new Program();
program.OpenSerial();
while (true)
{
}
}
This looks very problematic to me. NETMF will call Main() when it starts. Your Main() is in the ‘Program’ class. Then you create a new instance of Program class (from inside the program class) but your Program class has no constructor (which IMHO is bad for a non-static class) and you’ll wind up defining all of this stuff (below) again:
private const byte sensorAddress = 72;
TMP102Sensor temperatureSensor = new TMP102Sensor(sensorAddress);
public SerialPort _port;
OutputPort Di8 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, false);
OutputPort Di9 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di9, false);
double SetPoint = 21;
I would do away with creating a new instance of the Program class and just make OpenSerial a static member.
I believe that you are assuming that you will get the entire message from the serial port with a single read. This is not a good assumption to make. You could get the message one byte at a time from the serial port.
I suggest you make the output port and the temperature sensor to be static members of the Program class. Then you only have to initialize them once.
It is generally undesireable to spend a lot of time in an interrupt routine, such as the DataReceived handler routine. The 500 ms sleep is not good practice. I suspect this is present to allow all the serial data to arrive?
But, these are more advanced techniques. Kudos on getting the program working!
I have a similar issue, Fez Mini. I run it in debug and it works fine.
I deploy a release version. Says it deployed fine, but when I power it down and power it back up all I get is the red led light up. I’m using the Com2 port to talk to it. The code should echo back an ack. It does so in Debug mode, dead in Release.
Your question is missing one or more of these details:[ul]
The name of the product.
The code you’re trying to run.
Details on your setup.[/ul]
(Generated by QuickReply)