Server.Connect(new IPEndPoint(IPAddress.Parse(Address), Port));
Is Server a static variable declared in your main thread?
  | ||||||||||||||
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.
Community Stats
1
Neutral
User ToolsFriendsTeets hasn't added any friends yet. Posts I've MadeIn Topic: Socket.Connect locks up Netduino if no network29 June 2012 - 08:41 PM
Is Server a static variable declared in your main thread? In Topic: Microsoft.SPOT.Hardware;27 June 2012 - 12:06 AM
WPF and Netduino use different versions of the .NET Framework, so you won't be able to share between them. If you want your WPF app to talk with your Netduino, you'll have to talk over a network or something else.
In Topic: simple timer26 June 2012 - 11:51 PM
The big thing about C# is the event handlers. Instead of looping through code and constantly checking the state of a port, you can add an event handler and have the port tell you when its state has changed. I rewrote your code to take advantage of event handlers. You'll also notice I moved the variables outside the Main() function and made them static so they can be seen by the events. I haven't debugged the code, but it should be what you're looking for.... using System; using System.Threading; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace TimerSample { public class Program { // Input that triggers the timer static InputPort Sens1 = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled); // Output to do stuff with static OutputPort led = new OutputPort(Pins.GPIO_PIN_D0, false); // Interrupts that we need to track static InterruptPort Sens2 = new InterruptPort(Pins.GPIO_PIN_D2, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); static InterruptPort Sens3 = new InterruptPort(Pins.GPIO_PIN_D3, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); // The timer static Timer timer = null; // Input counts static int Sens2Count = 0, Sens3Count = 0; public static void Main() { // Watch for when the input is triggered Sens1.OnInterrupt += new NativeEventHandler(Sens1_OnInterrupt); // Watch for when the interrupts are triggered Sens2.OnInterrupt += new NativeEventHandler(Sens2_OnInterrupt); Sens3.OnInterrupt += new NativeEventHandler(Sens3_OnInterrupt); while (true) { // Do stuff } } static void Sens1_OnInterrupt(uint data1, uint data2, DateTime time) { // If the timer isn't started... if (timer == null) { // ... then start the timer timer = new Timer(timerDelegate, null, 0, 5000); } else { // Stop the timer timer = null; } } static void Sens2_OnInterrupt(uint data1, uint data2, DateTime time) { // Up the count Sens2Count++; } static void Sens3_OnInterrupt(uint data1, uint data2, DateTime time) { // Up the count Sens3Count++; } static TimerCallback timerDelegate = new TimerCallback(TimesUp); private static void TimesUp(object state) { // Check the sensor counts if (Sens2Count != 2 || Sens3Count != 3) { led.Write(true); Sens3Count = 0; Sens2Count = 0; } else { led.Write(false); Sens2Count = 0; Sens3Count = 0; } } } } Let me know if you have any questions... NICK In Topic: Cant add refrences26 June 2012 - 10:54 PM
You can run your MF code against the emulator... would be a more reliable approach, too. In Topic: Visual Studio 11 Beta and Netduino29 April 2012 - 06:41 PM
Did you try re-installing the MF and Netduino SDKs?
| ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||