Problem with Hydra (Ethernet Firmware) and NETMF 4.2 (QFE2)

Hydra problems with NETMF 4.2

I explain:

1 - Download and install new version (RC2 for NETMF 4.2 QFE2). - OK
2 - Flash Hydra Ethernet Firmware. - OK
3 - Create a new project and copy the contents of the old project. - OK
4 - Deploy app to Hydra, reset and test. OK
5 - Debug and test. - OK.
6 - Play with app in the Hydra (not debug). OK.
7 - Add change to the project (add webserver functionality). OK.
8 - Deploy app to Hydra, reset and test. OK.
9 - Debug (compile, deploying, running config file, assign interrupt ports function, in the webserver function stopping the app) - Result Hydra not responding.
10 - Disconnect Hydra and reconnect - Result “USB device not recognized”.
11 - Recover Hydra via manual updating the firmware. OK.
12 - Repeat from 4 to 8. OK. (From 1 to 12 happen yesterday).
13 - Add change to the project (add webclient functionality). OK.
14 - Deploy app to Hydra, reset and test. OK.
15 - Debug (compile, deploying, running config file, assign interrupt ports function, in the webserver function stopping the app) - Result Hydra not responding.
16 - Disconnect Hydra and reconnect - Result “USB device not recognized”.

Again, many problems with NETMF 4.2 QFE 2 and Hydra.

1 - Flash Hydra Ethernet Firmware. - OK
2 - Deploy app to Hydra, reset and test. OK
3 - Play with app in the Hydra (not debug). OK.
4 - Add code to the project. OK.
5 - Debug (compile, deploying, running config file, assign interrupt ports function, exception in read a xml file) - Result Hydra not responding.
6 - Disconnect Hydra and reconnect - Result “USB device not recognized”.

As an additional comment, to debug, VS2010 sends the message that the Hydra is this resetting, but takes a long time, until I manually reset the Hydra it continues the process of debugging.

lerg98

While USB specifications say ports should provide 500mA, we rarely see a port that can actually provide 500mA. We always recommend the use of powered hubs or a power pack instead of relying on the USB power. Use a powered hub from a known brand, not a cheap hub. If your device has the option of using a power pack (for example the USB Client DP Module) then you can use a power pack instead. 9V 1A is typically recommended but check the bottom of the circuit board for printed voltage range. All power connectors on GHI products are 2.1mm with positive on the inside and negative on the outer ring.

Not using a powered hub or power pack can cause:
[ul]Unexplained behavior
Device does not function
Device functions intermittently
Device functions but network fails
Device functions but SD card fails
Device functions but firmware update fails[/ul]
(Generated by QuickReply)

Gus says power, I say it’s more likely the code you’re trying to deploy.

Show us a minimal project that you think is broken and we can troubleshoot more. There are lots of Hydra’s around but you seem to be the one with such significant issues. Not saying there isn’t something wrong in the SDK, just that we can’t jump straight there.

I get same error very often with Hydra USB driver (more often ethernet firmware, but also on non ethernet fw).
I discovered that my problem was related to USB Arbitrator service of Vmware Workstation 9. Shutting down the USB arbitrator service this doesn’t happen any more.

Another situation:

Hydra working (read rfid cards, put some events in a text file, read file via web, put information in Hydra device by the web functionality), the device is working correctly for more than 18 hours.

PowerOFF the device, extract the SDCARD, read text files in the PC, insert again the SDCARD in the device (note, none of the files were deleted or modified), powerON the Hydra, and the app not function, the ip device not responding, the web functionality not obtain answer, not read rfid cards.

No programming change or any other information, only powerOFF, remove-insert the SDCard, powerON the device and not working.

Connect Hydra to PC and obtain the message “USB device not recognized”.

lerg98

@ lerg98 -

please start a separate thread for you new problem.

Hi,

I have some trouble with the hydra ethernet firmware. I’m using VS2012 with the latest hydra firmware and tinyloader.

Without any change in code, the hydra board is able to run my code and sometimes later it reboots when deploying the same code. Code which is running in other projects and copied to a actual project is not running on the same board.

USB not recognized and reboots during debugging are very frustrating!

I tried a project with glide and got big problems in the middle of my project, so I removed glide!

I tried VS2012 and VS2010 under Windows 8.1 and Windows 7. The Hydra Board is powered with a external power supply.

Using Streamreader to access the sd card with VS2010 is not running. The same code is running with VS2012.

A functional smtp client code running in a old project makes the hydra board rebooting when adding it to a actual project, without any call of smtp functions from the main program. The code should not be compiled, because there is no implementation in the main program. Just adding it to the project and I’m unable to deploy this project.

After many reboots and deploying simple projects, the firmware is finally able to run the code without any changes…

I consider to switch to the raptor board or using other stuff for further projects…

plus, it seems to me that you’ve got multiple machines and probably with old projects with old references from previous SDKs, a sure recipe for disaster. You need to clean the solutions properly or copy code over into new projects, and rebuild fresh. A methodical approach will give you a stable solution/outcome.

Hi,

Brett thanks for your replay. I set up the machine new from Windows to VS2012 and SDK, so I don’t believe its the system. I made a new project in VS and copied the code to this project with the same problems.

Adding new code like:

void SendMail()
{
Debug.Print(“Test”);
}

makes the system instable without a call of this code. Just adding it to the project. When changing VS from Debug to Release, it look better. I have seen there is the code optimization active in Release. So I tried to activate it in Release and the same code is running without change. It seems to be a issue with VS2012…

At the moment I think the problems are the two threads which are running in my code. I changed the threads to classic timers and it looks better at the moment. When using the Timers instead of threads I can deploy code in Debug and Release option. Working for the moment…

ok, I debugged a little more.

The problem with the hydra board is the smtp connection. The code below was running, but I’m not able to deploy it any more to the hydra board. The board reboots and says press CRTL+Shift+F5 to continue debugging.

The while (SmtpConnection.Poll(-1, SelectMode.SelectRead)) makes the problem. When removing this line, the board boots well…

So I trieb the Netmf Toolbox in a new project. The SNTP client is running well, but the SMTP client has the same behavior as the code below.

any idea???

using System;
using Microsoft.SPOT;
using System.Text;
using System.Net;
using System.Net.Sockets;
using Microsoft.SPOT.Net.NetworkInformation;
using Gadgeteer.Modules.GHIElectronics;
using System.Threading;

namespace Heizung
{
    public class SmtpClient
    {
        private string _SmtpServerName = null;
        private int _Port = 0;
        private enum SmtpState
        {
            NotConnected,
            DomainAccepting,
            MailFromAccepting,
            RecipientAccepting,
            DataCommandAccepting,
            MessageAccepting,
            ConnectionClosing
        };

        SmtpState state;

    public SmtpClient(string SmtpServerName, Int32 Port)
    {
        if (Port < 0)
            throw new ArgumentOutOfRangeException();
        _SmtpServerName = SmtpServerName;
        _Port = Port;
    }


    public void Send(string from, string recipient, string subject, string body, bool authenticate, string username = "", string password = "")
    {
        if (username != "" && password != "")
        {
            System.Text.Encoding encoding = new System.Text.UTF8Encoding();
            username = Convert.ToBase64String(encoding.GetBytes(username));
            password = Convert.ToBase64String(encoding.GetBytes(password));
        }
        state = SmtpState.NotConnected;
        /* Connect to the Server*/
        // Figure out the Server IP Address
        IPHostEntry SmtpServerHostEntry = Dns.GetHostEntry(_SmtpServerName);
        IPEndPoint SmtpServerEndPoint = new IPEndPoint(SmtpServerHostEntry.AddressList[0],
        _Port);
        // Establish the connection with SMTP Server
        Socket SmtpConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
        ProtocolType.Tcp);
        SmtpConnection.Connect(SmtpServerEndPoint);
        String ResponseStr = null;
        
        while (SmtpConnection.Poll(-1, SelectMode.SelectRead))
        {
            byte[] ReceiveBuffer = new byte[SmtpConnection.Available];
            SmtpConnection.Receive(ReceiveBuffer, ReceiveBuffer.Length, SocketFlags.None);
            // The first 3 bytes hold the message number which is enough for us.
            ResponseStr = new String(Encoding.UTF8.GetChars(ReceiveBuffer), 0, 3);
            int Response = Int16.Parse(ResponseStr);
            Debug.Print("Response: " + ResponseStr);
            switch (state)
            {
                case SmtpState.NotConnected:
                    if (Response == 220) // Domain service ready.
                    {
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("HELO " +
                            from.Split(new char[] { '@ ' })[1] + "\r\n"));
                        if (authenticate && username != "" && password != "")
                        {
                            Thread.Sleep(300);
                            SmtpConnection.Send(Encoding.UTF8.GetBytes("AUTH LOGIN\r\n"));
                            Thread.Sleep(300);
                            SmtpConnection.Send(Encoding.UTF8.GetBytes(username + "\r\n"));
                            Thread.Sleep(300);
                            SmtpConnection.Send(Encoding.UTF8.GetBytes(password + "\r\n"));
                            Thread.Sleep(300);
                        }
                        state = SmtpState.DomainAccepting;
                    }
                    break;
                case SmtpState.DomainAccepting:
                    if (Response == 250) // auth successful (if authentication enabled).
                    {
                        Debug.Print("Domain Accepting");
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("MAIL FROM:<" + from +
                        ">\r\n"));
                        state = SmtpState.MailFromAccepting;
                    }
                    break;
                case SmtpState.MailFromAccepting:
                    if (Response == 250) // Requested mail action okay, completed.
                    {
                        Debug.Print("MailFrom Accepting");
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("RCPT TO:<" + recipient
                        + ">\r\n"));
                        state = SmtpState.RecipientAccepting;
                    }
                    break;
                case SmtpState.RecipientAccepting:
                    if (Response == 250) // Requested mail action okay, completed.
                    {
                        Debug.Print("MailRecipient Accepting");
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("DATA\r\n"));
                        state = SmtpState.DataCommandAccepting;
                    }
                    break;
                case SmtpState.DataCommandAccepting:
                    if (Response == 354) //Start mail input; end with <CRLF>.<CRLF>.
                    {
                        Debug.Print("MailDataCommand Accepting");
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("Subject: " + subject +
                        "\r\n"));
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("From: " + from +
                        "\r\n"));
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("To: " + recipient +
                        "\r\n\r\n"));
                        SmtpConnection.Send(Encoding.UTF8.GetBytes(body + "\r\n"));
                        SmtpConnection.Send(Encoding.UTF8.GetBytes(".\r\n"));
                        state = SmtpState.MessageAccepting;
                    }
                    break;
                case SmtpState.MessageAccepting:
                    if (Response == 250) // Requested mail action okay, completed.
                    {
                        Debug.Print("Mail Message Accepting");
                        SmtpConnection.Send(Encoding.UTF8.GetBytes("QUIT\r\n"));
                        state = SmtpState.ConnectionClosing;
                    }
                    break;
                case SmtpState.ConnectionClosing:
                    if (Response == 221) // Requested mail action okay, completed.
                    {
                        Debug.Print("MailClosed");
                        SmtpConnection.Close();
                        return;
                    }
                    break;
            }
        }
        SmtpConnection.Close();
        throw new Exception("SMTP connection Timeout");
    }







    }
}

Hello,

I did something new. I downloaded the NETMF and Gadgeteer Package 2014 R2 Beta-1 and updatet the hydra board to TinyBooter v4.3.1.0 and Firmware 4.2.6.2 out of this package.

The smtp client from my last posting is now running and I can send e-mail with this code. The test code is the same, the only thing is the new TinyBooter which seems to be more stable!
:smiley: :smiley: :smiley: :smiley: :smiley: :smiley:

For testing I flashed the 4.3 Firmware, but there is a bug with the network. I got no network connection over the ENZ28. With the FEZ Config tool I can read and set values, but this has no influence on the network settings…

:-[ :-[ :-[ :-[ :-[

Hello,

good news I found the problem in the code. I have rewrtitten the smtp code and during debugging I got again reboots when deploying the code. Adding a new Debug.Print line caused a reboot of a running code. So I removed some Debug.Print line in my project and the same code is running now with smtp and sntp client.

I don’t know why and what exactly is happening when compiling the code in VS2012, but to many Debug.Print lines will cause debugging problems and makes the system rebooting.

Nice effect costs me three day’s but know the system is running

:stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: