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

Problem with USB on RC5


  • Please log in to reply
5 replies to this topic

#1 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 11 August 2012 - 06:21 AM

I am having problems with Netduino Plus losing communication with the ouside world after a period of time. I posted about this earlier,

http://forums.netdui...b-connectivity/

In order to isolate the problem, I wrote the simple program appended below to output via USB Debug and also COM2 to simulate a Debug.Print via serial. It writes the output every 10 sec.; forever. I ran two trials, one with USB and serial and one without USB:

First Case Run Conditions:
==========================
External power to Netduino Plus
MFDeploy connected to Netduino via USB (Target --> connect)
Netduino connected to PC terminal via COM2
Ethernet unplugged

Last Output before Netduino stops output on both USB and serial (needs reset to get going again)
-------------------------------------------------------------------------------------------------------
MFDeploy:
hello from (Debug.Print) --> timer:Duration 01:05:50.0006186

PC Terminal:COM9
hello from D in Main --> timer:Duration 01:05:50.0006186
hello From Print in TestClass --> timer:Duration 01:05:50.0006186

and case 2,

Second Case Run Conditions:
===========================
External power to Netduino Plus
Reset Netduino
Disconnect USB
Output from Netduino only through COM2

Last Output, still running
--------------------------
hello from D in Main --> timer:Duration 05:29:50.0011947
hello From Print in TestClass --> timer:Duration 05:29:50.0011947

So,it is seen the Netduino becomes unresponsive after about 1 hr with USB, but was still running after 5 hrs with only serial out. It seems to me that there must be some sort of bug in the USB driver and/or MFDeploy. Also, in my checking to see if the PC was suspending the USB port, I came across the power listing from the port as 280 mA. The following is abstracted from the program, USBDeview output (also, see attached USB Power.PNG),
--
--
--
Driver Filename : MFUSB_Netduino.sys
Device Class : USB
Device Mfg : Secret Labs LLC
Power : 280 mA <---------------------- NB
USB Version : 1.10
Driver Description: Netduino
Driver Version : 4.2.0.0
Instance ID : USB\VID_22B1&PID_1000\5&2e6cfaa2&0&2


I don't know if this is current drawn or the maximum to be supplied. If the latter, then this is inconsistent with what I have read elsewhere in the forum about the current supplied from the PC USB port.

Baxter

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Imports System.IO.Ports
Imports Microsoft.VisualBasic.Constants

Module Module1
    Dim StartTime As Date
    Dim timer As ExtendedTimer
    Public T As TestClass = New TestClass
    Friend D As DebugPrint = New DebugPrint("COM2")

    Sub Main()
        StartTime = DateTime.Now
        timer = New ExtendedTimer(New TimerCallback(AddressOf OnTimer), Nothing, 0, 10000) '10 sec
        Thread.Sleep(Timeout.Infinite)
    End Sub

    Public Sub OnTimer(state As Object)
        Dim delta As System.TimeSpan = (DateTime.Now - StartTime)
        
        'Use regular USB Debug.print
        Debug.Print("hello from (Debug.Print) --> timer:Duration " & delta.ToString)

        'Use COM2 DebugPrint
        D.Print(vbCrLf & "hello from D in Main --> timer:Duration " & delta.ToString)
        T.Print(vbCrLf & "hello From Print in TestClass --> timer:Duration " & delta.ToString)

    End Sub
End Module

TestClass (Separate Class in Project)
=====================================

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus

Class TestClass
    Public Sub New()
    End Sub

    Public Sub Print(ByVal str As String)
        D.Print(str) ' goes out SerialPort COM2
    End Sub
End Class

DebugPrint (Separate Class in Project)
=====================================

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Imports System

Class DebugPrint
    Implements IDisposable

    Private disposedValue As Boolean = False
    Private buff() As Byte = {}
    Dim Port As SerialPort

    Public Sub New(ByVal ComPort As String, Optional ByVal baud As Integer = 9600)
        Port = New SerialPort(ComPort, baud, Parity.None, 8, StopBits.One)
        With Port
            .Handshake = Handshake.None
            .WriteTimeout = 200
            .Open()
        End With
    End Sub

    Public Sub Print(ByVal str As String)
        If (Not Port.IsOpen) Then Port.Open()
        buff = System.Text.Encoding.UTF8.GetBytes(str)
        Port.Write(buff, 0, buff.Length)
    End Sub

    Public Sub close()
        Me.Dispose()
    End Sub

#Region "IDisposable Support"
    'Private disposedValue As Boolean ' To detect redundant calls

    ' IDisposable
    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: dispose managed state (managed objects).
                Port.Close()
                System.Threading.Thread.Sleep(250) 'give some time to close
            End If

            ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
            ' TODO: set large fields to null.
        End If
        Me.disposedValue = True
    End Sub

    ' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
    'Protected Overrides Sub Finalize()
    '    ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
    '    Dispose(False)
    '    MyBase.Finalize()
    'End Sub

    ' This code added by Visual Basic to correctly implement the disposable pattern.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region

End Class

Attached Files



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 August 2012 - 09:23 AM

Hi baxter, The MFUSB drivers may overflow with debug data being written for a long time. There are new drivers for NETMF coming soon... Can you please try this with the new (WINUSB) drivers and let us know if the situation clears up? If it doesn't, we'll want to file a bug report with Microsoft and also try to analyze the traffic with a USB analyzer to see where data is/is not going... Chris

#3 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 11 August 2012 - 07:04 PM

Hi Chris, I am using all of the latest software, .NET Micro Framework v4.2 QFE1 SDK, Firmware_Netduino_4.2.0.0_RC5, NETDUINO_4.2_SIGNED_DRIVERS The USB drivers are those discussed in your post, "Drivers for .NET MF 4.2 Signed and compiled in release mode", http://forums.netdui...-for-net-mf-42/ You are probably right about a buffer overflow. I had this problem with my PC terminal program overflowing the receive textbox. I fixed it by simply flushing before the max number of characters were received. The serial output is still OK after 20 hrs, hello from D in Main --> timer:Duration 20:03:00.0011520 hello From Print in TestClass --> timer:Duration 20:03:00.0011520 I am curious about the reason for a current of 280 mA on the USB port. Could this be a source of some of the deployment errors for a USB powered board (e.g. not enough power to start cleanly)? Baxter

Attached Files



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 13 August 2012 - 05:00 PM

Hi Baxter,

I am curious about the reason for a current of 280 mA on the USB port. Could this be a source of some of the deployment errors for a USB powered board (e.g. not enough power to start cleanly)?

Long story short, that's a legacy setting based on Atmel's general recommendations. We're looking at switching it to 500mA in the future, but we need to get some more data from the field before making that change wholesale.

With Netduino Go, we've put FETs on each of the sockets so that we can power up the modules after boot. This allows us to keep our amperage requirements lower during boot. We also added FETs to the shield base's 3V3 and 5V headers to allow it to do the same thing with shields (so it stays under 60mA during gobus enumeration). It may make sense to add that same FET to Netduino in a future "rev c" board.

Chris

#5 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 15 August 2012 - 05:27 PM

I installed the latest software yesterday (QFE2) and my USB disconnect problem seems to have gone away. My uptime is now over 24 hrs. Before, it was of the order of 1 to 2 hrs. The WinUSB Driver apparently corrected the problem. Thanks for the upgrade. Baxter

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 15 August 2012 - 05:51 PM

Hi Baxter,

I installed the latest software yesterday (QFE2) and my USB disconnect problem seems to have gone away. My uptime is now over 24 hrs. Before, it was of the order of 1 to 2 hrs. The WinUSB Driver apparently corrected the problem.

That's great news. Thank you very much for following up on this.

Chris




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.