Netduino home hardware projects downloads community

Jump to content


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.

trth

Member Since 03 Sep 2014
Offline Last Active Feb 10 2016 05:27 AM
-----

Posts I've Made

In Topic: Unable to deploy without disconnect\reconnect USB cable

10 February 2016 - 05:12 AM

I know the last post was very long ago, but I had the same problem and think I have a solution. I was coding everything in separate threads and allowing Main() to end, with the remaining threads actually doing the work. With a lot of trial and error, I finally decided to let Main() live forever, even though the thread had no work left to be done. Once I placed Thread.Sleep(Timeout.Infinite); at the end of Main(), I have never had to reset my USB connection. Hope this is helpful.

Would you please post an example of code for this?

 

I attempted to add it and get an warning "unreachable code"

 

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
 
namespace buttonOnboardLED
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort button = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);
 
            bool buttonState = false;
            while (true)
            {
                buttonState = button.Read();
                led.Write(buttonState);
            }
            Thread.Sleep(Timeout.Infinite);
        }
    }
}

In Topic: Unable to deploy without disconnect\reconnect USB cable

10 February 2016 - 05:03 AM

I just bought a Netduino 3 and seem to be having a similar problem.  

 

I tried the "pushing the onboard button" from "getting started with netduino" and a similar thing happen.  

 

Sequence of what happens:

-I upload the program to the netduino 

-I press and release the onboard button

-The computer makes the USB disconnect sound

-The LED turns on for about 5 seconds

-LED turns off

 

If I press and hold the onboard button:

-I press and hold the onboard button

-The computer makes the USB disconnect sound and the onboard LED turns on

-I release the onboard button

-The USB reconnect sound comes from the computer

-The LED stays on for an additional 5 seconds after the button release

-The LED goes out

 

 

Here is the code:

 

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
 
namespace buttonOnboardLED
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort button = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);
 
            bool buttonState = false;
            while (true)
            {
                buttonState = button.Read();
                led.Write(buttonState);
            }
 
        }
 
    }
}
 
Any help would be greatly appreciated!

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.