Problem with the network adapter using version 4.2

Hi,

I have updated my Cobra board and my development environment.
I am experiencing some problem with my project.
I have a WebServer (using HttpListener) and it freezes randomly.
When this happens the system is hanging( I have to hard reset the board).
(Needless to say that the same code with 4.1 was running perfectly)

Is there a problem with the HttpListener?

I also tried to get time using NTP: hanging every time
Code:
try
{
TimeServiceSettings NTPTime = new TimeServiceSettings();
NTPTime.AutoDayLightSavings = true;
NTPTime.ForceSyncAtWakeUp = true;
NTPTime.RefreshTime = 3600;

            NTPTime.PrimaryServer = Dns.GetHostEntry("uk.pool.ntp.org").AddressList[0].GetAddressBytes();
           
            TimeService.Settings = NTPTime;
            TimeService.SetTimeZoneOffset(60 * 2); 
            TimeService.Start();
            Thread.Sleep(500);
            TimeService.UpdateNow(0);
           
            Debug.Print("It is : " + DateTime.Now.ToString());

            DateTime time = DateTime.Now;
            //RealTimeClock.SetTime(time);
            Utility.SetLocalTime(time);
            TimeService.Stop();
        }
        catch
        {
            //Debug.Print("RTC-Time : " + RealTimeClock.GetTime().ToString());
        }

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

Thank you


 try
            {
                TimeServiceSettings NTPTime = new TimeServiceSettings();
                NTPTime.AutoDayLightSavings = true;
                NTPTime.ForceSyncAtWakeUp = true;
                NTPTime.RefreshTime = 3600;

                NTPTime.PrimaryServer = Dns.GetHostEntry("uk.pool.ntp.org").AddressList[0].GetAddressBytes();
                //NTPTime.AlternateServer = Dns.GetHostEntry("il.pool.ntp.org").AddressList[0].GetAddressBytes();

                TimeService.Settings = NTPTime;
                TimeService.SetTimeZoneOffset(60 * 3); // Israel Summer Time zone : GMT+3
                TimeService.Start();
                Thread.Sleep(500);
                TimeService.UpdateNow(0);
                //Thread.Sleep(9000);
                Debug.Print("It is : " + DateTime.Now.ToString());

                DateTime time = DateTime.Now;
                //RealTimeClock.SetTime(time);
                Utility.SetLocalTime(time);
                TimeService.Stop();
            }
            catch
            {
                //Debug.Print("RTC-Time : " + RealTimeClock.GetTime().ToString());
            }

Your question is missing one or more of these details:[ul]
The name of the product.
The code you’re trying to run.
Details on your setup.[/ul]

I don’t believe the TimeService stuff is supported, at least not on any of the Cerberus family boards.

He’s using a Cobra.

Thank you for your replies

I am using a Cobra board and this code runs perfectly using 4.1 sdk

Ah, duh, yeah, he said that. Thanks. Is TimeService supported on any 4.2 boards?

Don’t know. But if it works fine in 4.1 but not in 4.2 then this sounds like one for Gus & crew.

Hi,

After a few trial of running my application; it seems like the IP stack is faster, but unfortunately not stable. Meaning that when a problem occurs the the system hangs. and only a hard reset should be applied before deploying a new version.
So, sadly, my question is is it safe to roll back to 4.1?
If the answer is yes, then how should proceed?

Thanks

4.1 is currently still included in 4.2 SDK package. just load 4.1 firmware.

Thank you Gus,

Every thing is working now

Thank you again

I hope it will be fixed in the next version
I was looking forward to use the SQLite feature …

@ AniDavid - We must use lwip instead of RTIP so if there are problems then we need to fix them or report them to Microsoft to get them fixed.
Could you please give has simple code that isolate and show the problem? It should use plain .NET Sockets (no Http class or other higher level classes. Because those classes are the same no matter the TCP/IP stack).

Hi Joe,

I did not get to use plain .NET Sockets. So maybe I was wrong blaming the IP stack. As I mentioned before I use an HttpListener class for the WebServer, and the system hangs after a few minutes. I did some Debug.Prints and found out that there is no consistancy, the system would hang randomly while serving the page. I managed to make it more stable by adding delays between reading the files from the SD card and sending them over context.Response.OutputStream, which bought me a few minutes more but that’s it.
However there is a piece of code that would reproduce a system hang each time:

static private void UpdateTime(Object state)
        {
            try
            {
                TimeServiceSettings NTPTime = new TimeServiceSettings();
                NTPTime.AutoDayLightSavings = true;
                NTPTime.ForceSyncAtWakeUp = true;
                NTPTime.RefreshTime = 3600;
                Thread.Sleep(1500);
                NTPTime.PrimaryServer = Dns.GetHostEntry("uk.pool.ntp.org").AddressList[0].GetAddressBytes();
                //NTPTime.AlternateServer = Dns.GetHostEntry("il.pool.ntp.org").AddressList[0].GetAddressBytes();
                Thread.Sleep(1500);
                TimeService.Settings = NTPTime;
                TimeService.SetTimeZoneOffset(60 * 3); // Israel Summer Time zone : GMT+3
                TimeService.Start();
                Thread.Sleep(500);
                TimeService.UpdateNow(0);
                //Thread.Sleep(9000);
                Debug.Print("It is : " + DateTime.Now.ToString());

                DateTime time = DateTime.Now;
                RealTimeClock.SetTime(time);
                Utility.SetLocalTime(time);
                TimeService.Stop();
            }
            catch
            {
                Debug.Print("RTC-Time : " + RealTimeClock.GetTime().ToString());
            }
        }

The system will hang at “TimeService.Start();” every time (work fine using 4.1).

P.S. If you plan to run the function at the beginning of your code, I recommend to have a 15 seconds delay before calling this function: it will give time to deploy the next time…

Thank you

Hi everyone,

I wanted to bump this thread… I think I’m suffering from the same problem (hang) that is described in this thread. I’m using 4.2 and .NET Spider. The hang seems to occur after TimeService.Start(); using the same basic code as documented in this article. Did anyone find a workaround besides falling back to 4.1?

Thanks,

Jeff

A new SDK release is targeted for today. The release notes say the time service is fixed in the release.

Hi Mike,

This is a bit embarassing, but where do I find the new SDK?

Thanks!

Thanks Andre! Is that the same package that is mentioned here: http://www.tinyclr.com/forum/topic?id=10651? The posting I linked has a link to www.ghielectronics.com/download/ghi-software-package-v4.2-Q1-02012013.

I’m looking for the SDK that includes the TimeService fix.

Sorry for the confusion…

I downloaded and installed the package at: www.ghielectronics.com/download/ghi-software-package-v4.2-Q1-02012013; flashed my Spider at the end of the installation process.

Then, I went on and created a new .NET MF 4.2 project. Added the ethernet_j11d module. Wired it up (physically and virtually). Wrote a little code to enable the module (DHCP). Added an event handler to the Network Address Changed event; caught the assigment of my IP and tried configure and start the time service. But I still get a hang. Maybe I need to let it spin longer, but I thought this was fixed. By time service, I mean Microsoft.SPOT.Time.TimeService.

Am I using the wrong class?

Thanks again!