Can't Deploy Application from VS 2010 - Visual Studio - Netduino Forums
   
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.
Photo

Can't Deploy Application from VS 2010


  • Please log in to reply
18 replies to this topic

#1 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 11 September 2012 - 09:13 PM

Hello everyone, I've been running into a situation where I have an existing, previously deployed app running in the Netduino Plus (Don't know if this happend on the Go as well) and it prevents me from deploying a new app to it. VS 2010 hangs for a while and then throws an exception. So, my last resort to this situation is to launch MFDeploy and then select the USB option from the Device dropdown and then hit Erase and if I am lucky enough at that moment get the screen shown below to be able to delete my previous deployment, and then be able to deploy from VS 2010 afterwards.Posted ImageThis seems to happen when the application deployed to the Netduino is doing some work at the moment like running background threads that read values, etc. I also tried resetting the NPlus while deploying but didn't help at all. Is there another solution to this annoying issue or this is just the way it is?

#2 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 12 September 2012 - 12:02 AM

This happens to me all the time with .NET MF 4.2 (wasn't a problem in earlier versions), it seems to happen when the Netduino app has a main application loop with long (1 second) Thread.Sleep()s in it. I have two different ways that I solve it: 1. Unplug the Netduino and plug it back in, then press F5 really fast so that it catches the Netduino before it has finished booting up. 2. (better) Add some code to your netduino application to allow you to terminate your application. An easy way to do this is to add a jumper (or a switch) to one of the pins, and use an InterruptPort to set a boolean flag which terminates the loop.

#3 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 12 September 2012 - 04:35 AM

This happens to me all the time with .NET MF 4.2 (wasn't a problem in earlier versions), it seems to happen when the Netduino app has a main application loop with long (1 second) Thread.Sleep()s in it. I have two different ways that I solve it:

1. Unplug the Netduino and plug it back in, then press F5 really fast so that it catches the Netduino before it has finished booting up.

2. (better) Add some code to your netduino application to allow you to terminate your application. An easy way to do this is to add a jumper (or a switch) to one of the pins, and use an InterruptPort to set a boolean flag which terminates the loop.



Thanks for your response Anthony,

I like # 2, do you happen to have an example on how to accomplish that?

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 12 September 2012 - 04:55 AM

This is very interesting. I'm wondering if some feature in .NET MF 4.2 QFE2 is locking out the debugger. If we can figure out which feature it is (or reproduce a simple loop which exhibits this issue), we can share it with Microsoft and try to get to the bottom of it. If you have a simple repro (~10 lines of code) which reproduces this issue, we'd really appreciate it if you shared it with us. We want to make sure that deployment to .NET MF 4.2 devices is as smooth as possible and even better than with .NET MF 4.1. Also...if it's not too much trouble to ask, can you try forcing your computer to use the MFUSB drivers for your Netduino instead of the new WinUSB drivers? If the problem is specific only to WinUSB, then that may make this a much easier problem to isolate. Thank you, Chris

#5 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 12 September 2012 - 07:25 PM

This is very interesting.

I'm wondering if some feature in .NET MF 4.2 QFE2 is locking out the debugger. If we can figure out which feature it is (or reproduce a simple loop which exhibits this issue), we can share it with Microsoft and try to get to the bottom of it.

If you have a simple repro (~10 lines of code) which reproduces this issue, we'd really appreciate it if you shared it with us. We want to make sure that deployment to .NET MF 4.2 devices is as smooth as possible and even better than with .NET MF 4.1.

Also...if it's not too much trouble to ask, can you try forcing your computer to use the MFUSB drivers for your Netduino instead of the new WinUSB drivers? If the problem is specific only to WinUSB, then that may make this a much easier problem to isolate.

Thank you,

Chris


Hi Chris,

Sure, I will be more than glad to help on this, so I guess I should try the MFUSB drivers and see if the problem persist. Can you point me out where to get them?

#6 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 13 September 2012 - 02:37 AM

Hi Chris,

Sure, I will be more than glad to help on this, so I guess I should try the MFUSB drivers and see if the problem persist. Can you point me out where to get them?


Never mind, I found it here:

http://forums.netdui...-mfusb-drivers/


Let's see how it goes with it and I will post my results. By the way I didn't find WINUSB drivers under the C:\Program Files (x86)\Secret Labs\Netduino SDK\Drivers folder, so I guess I don't have them or might be located somewhere else in my hard drive, either that or I always have used MFUSB drivers and didn't know about that :)

#7 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 17 September 2012 - 04:08 AM

If it still happens let me know and I will post an example like you asked.

#8 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 17 September 2012 - 05:49 PM

If it still happens let me know and I will post an example like you asked.


Yes, it is still happening. I noticed that any program that has a Thread.Sleep longer than 2 seconds causes the issue. Also if the program has 2 or more threads running with a Thread.Sleep in them or a lot of processing going on with all of them together.

Anthony, if you already have a sample program that recreates this issue, please upload it here, so Chris can take a look at it, otherwise I will try to have something for him tonight.

Thank you

#9 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 17 September 2012 - 10:41 PM

I don't have a repro sample as such, except to say that I have observed this behaviour (since 4.2) with any netduino app that has this kind of thing at the end of main():

While Not mblnStopped
  System.Threading.Thread.Sleep(500)
End While

PS: My code for terminating the program goes something like this. This code assumes that you are using an external pull-up resistor & connecting a jumper or switch to one of the digital pins (replace "Pin" below in the Interrupt port constructror call with the actual pin).

Private mobjInput As InterruptPort
Sub main
  mobjInput = New InterruptPort(Pin, True, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh)
  mobjInput.EnableInterrupt()

  AddHandler mobjInput.OnInterrupt, AddressOf OnButtonPressed

  While Not mblnStopped
    System.Threading.Thread.Sleep(500)
  End While
End Sub

Sub OnButtonPressed(port As UInteger, state As UInteger, time As Date)
  If state = 1 Then
    mblnStopped=True
  End If
End Sub


#10 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 18 September 2012 - 01:05 AM

Thanks for the sample Anthony.

#11 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 18 September 2012 - 01:41 AM

Thanks for the sample Anthony.


I put a little C# sample together using Anthony's VB code provided and using Stefan's speaker class. So this is the way it works:

Once the program is launched (after the N+ is reset) it will make a beep sound using a speaker, if you have one connected to Pin D9 & GND.

If you press the on board switch, then the program will make 2 beeps, indicating it is going into the end state, therefore ending the while loop.

You can use the on board LED instead (led = new OutputPort(Pins.ONBOARD_LED, false); ) or whatever your imagination tells you if you don't have a speaker handy.

Attached Files



#12 awaiK

awaiK

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 21 September 2012 - 04:02 PM

Similar behaviour with my netduino (mini).
After a while, trying to deploy a second (or third) time, Visual Studio says

Unable to communicate with device - Serial:COM10


Edit: False alert. It's a different situation.
I changed my program from COM1 to COM2. But I use COM2 to deploy the application.
I guess because my program use COM2 now, Visual Studio can't deploy a new application.

Edited by awaiK, 21 September 2012 - 04:41 PM.


#13 Anthony Glenwright

Anthony Glenwright

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 24 September 2012 - 12:22 AM

Just a tip, if your device happens to have any kind of output (like an LCD, or a number of LEDs) - I usually put a last line of code in (after the loop) to light up everything, as an indicator that the netduino is "ready for update" - or if you have an LCD, just print something on the screen.

#14 drea

drea

    New Member

  • Members
  • Pip
  • 6 posts
  • LocationNewcastle, UK

Posted 09 October 2012 - 09:34 PM

I'm having a similar (maybe the same) problem. I am a netduino newb, so I might well be doing something stupid, but I've had a fair amount of .NET (and other coding) experience.

It seems that some programs will happily deploy while others cause a VS/TinyCRL exception.

For example, when I try to deploy this program I consistently get the VS exception, even if I do a full erase/re-flash first.

SecretLabs.NETMF.Hardware.PWM led = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D10);

int dutyCycle = 0;
led.SetDutyCycle((uint)dutyCycle);
int dir = 1;
int cycles = 0;

while (true)
{
    if (dutyCycle > 100)
    {
        dir = -1;
    }
    else if (dutyCycle < 0)
    {
        dir = 1;
        cycles += 1;

        if (cycles >= 10)
        {
            break;
        }
    }

    dutyCycle += dir;
    led.SetDutyCycle((uint)dutyCycle);
}

The exception is...

---------------------------
TinyCLR Error
---------------------------
An exception occurred while attempting to launch the debugger: Object reference not set to an instance of an object.
---------------------------
OK
---------------------------

There's also an error in the VS output...

Device not found or cannot be opened - USB:Netduino

This program always works fine though.

bool state = false;
OutputPort led = new OutputPort(Pins.ONBOARD_LED, state);
int flashLength = 250;

while (true)
{
    state = !state;
    led.Write(state);
    flashLength += 10;
    Thread.Sleep(flashLength);
}

I'm very confused and somewhat frustrated.

#15 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 09 October 2012 - 10:33 PM


I'm very confused and somewhat frustrated.


These sorts of issues can be incredibly frustrating, especially when you're not sure it's the code or the Visual Studio issues.

Can you provide some details on your development environment, such as the type of Netduino you're using, the Netduino Firmware version, the .Net Micro Framework you have installed, and the Netduino SDK version?

Hopefully we can get you back up and running.

Cheers,
Steve

#16 drea

drea

    New Member

  • Members
  • Pip
  • 6 posts
  • LocationNewcastle, UK

Posted 09 October 2012 - 10:43 PM

Hi Steve, I've got a Netduino Plus rev. B, 4.2.0.1 firmware, 4.2 .NET framework and the 4.2 sdk. I'm using Visual C# Express 2010. Here's the dump of Device capabilities from MFDeploy. HalSystemInfo.halVersion: 4.2.0.0 HalSystemInfo.halVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLC HalSystemInfo.oemCode: 34 HalSystemInfo.modelCode: 177 HalSystemInfo.skuCode: 4097 HalSystemInfo.moduleSerialNumber: 00000000000000000000000000000000 HalSystemInfo.systemSerialNumber: 0000000000000000 ClrInfo.clrVersion: 4.2.0.0 ClrInfo.clrVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLC ClrInfo.targetFrameworkVersion: 4.2.0.0 SolutionReleaseInfo.solutionVersion: 4.2.0.0 SolutionReleaseInfo.solutionVendorInfo: Netduino Plus (v4.2.0.1) by Secret Labs LLC SoftwareVersion.BuildDate: Sep 19 2012 SoftwareVersion.CompilerVersion: 410894 FloatingPoint: True SourceLevelDebugging: True ThreadCreateEx: True LCD.Width: 0 LCD.Height: 0 LCD.BitsPerPixel: 0 AppDomains: True ExceptionFilters: True IncrementalDeployment: True SoftReboot: True Profiling: False ProfilingAllocations: False ProfilingCalls: False IsUnknown: False

#17 Gutworks

Gutworks

    Advanced Member

  • Members
  • PipPipPip
  • 363 posts
  • LocationOttawa, Ontario

Posted 10 October 2012 - 01:25 AM

Hi Drea,

It is interesting that in your error it said, "Device not found or cannot be opened - USB:Netduino" and you're using the Netduino Plus. When you create the project are you selecting Netduino Plus Application? You should also see at the top of your code:

using SecretLabs.NETMF.Hardware.NetduinoPlus;

I have tested your code, and it works, however it will go by very quickly and end. Your dutyCycle will climb to 101, and down to -1 several times. Then the application ends after 2039 iterations. Why it ends at that point, I cannot answer at the moment, but am curious. :)

In any case, I hope this help.
Cheers,
Steve

#18 drea

drea

    New Member

  • Members
  • Pip
  • 6 posts
  • LocationNewcastle, UK

Posted 10 October 2012 - 07:45 AM

Hi Steve, Here's the includes I'm using using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; There has been a breakthrough though. I switched the deploy target to Emulator to see what would happen. Obviously it didn't do anything, but the deploy did succeed. The fun part is that when I switched back to deploying to the N+ it started working. I wonder if an early build that didn't work left some bad files lying around that weren't being cleaned up properly in subsequent builds? As far as what the code actually does, there should be a sleep at the end of each loop and I guess that the direction changes should probably happen at dutyCycle <= 0 and >= 100. At least I've got another thing to try when the deploy fails in the future. Thanks for your help. Cheers, Drea

#19 disu

disu

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 May 2013 - 09:51 AM

Hi,

I don't know what i did last night, but my Netduino seems to have stopped working.

I used some loop and sleep, as usually, but now I received "Unable to communicate with device - USB:Netduino" message every time I try to deploy a project.

 

In MF Deployment Tool I cannot connect, ping, read capabilities, ....I always receive "Error: No response from device" or "Failure - Devce NetduinoPlus2_Netduino is invalid or not responding".

I try to use another USB port but it doesn't work.

I try to use first Anthony method (unplug and press F5 quickly) but it doesn't work.

Any suggestion? Is there any method to clear netduino Program memory?

Thanks in advance






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.