Reports with release 2014 R2-Beta1

@ rockybooth - The wireshark traces looked fine, both times an address was issued to the board. I have noticed that networking with Gadgeteer is not quite stable yet. Could you try the below NETMF-only program? Socket 1 on the Raptor, no other modules needed.


Option Explicit On
Option Strict On

Imports GHI.Networking
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports Microsoft.SPOT.Net.NetworkInformation
Imports System
Imports System.Net
Imports System.Threading

Namespace MFConsoleApplication1
    Public Module Module1
        Sub Main()
            AddHandler NetworkChange.NetworkAvailabilityChanged, Sub(a, b) Debug.Print("SPOT NAVAC " + b.IsAvailable.ToString())
            AddHandler NetworkChange.NetworkAddressChanged, Sub(a, b) Debug.Print("SPOT NADRC")

            Dim NetIf = New EthernetENC28J60(Hardware.SPI.SPI_module.SPI2, CType(37, Cpu.Pin), CType(32, Cpu.Pin), CType(7, Cpu.Pin), 4000)
            NetIf.Open()
            NetIf.EnableDhcp()
            NetIf.EnableDynamicDns()

            While NetIf.IPAddress = "0.0.0.0"
                Debug.Print("Waiting....")
                Thread.Sleep(500)
            End While

            Debug.Print(NetIf.IPAddress)

            Dim Buffer(65536 - 1) As Byte

            For i = 0 To 10
                Dim Read = 0, Total = 0, Count = 0
                Dim StartTime As DateTime, EndTime As DateTime

                Using Request = CType(HttpWebRequest.Create("http://bing.com/robots.txt"), HttpWebRequest)
                    Request.KeepAlive = False
                    StartTime = DateTime.Now

                    Using Response = CType(Request.GetResponse(), HttpWebResponse)
                        Using Stream = Response.GetResponseStream()
                            Do
                                Read = Stream.Read(Buffer, 0, Buffer.Length)
                                Total += Read
                                Count += 1

                                Thread.Sleep(20)
                            Loop While (Read <> 0)

                            EndTime = DateTime.Now
                        End Using
                    End Using
                End Using

                Dim Duration = EndTime.AddMilliseconds(-20 * Count) - StartTime
                Dim Milliseconds = Duration.Minutes * 60000 + Duration.Seconds * 1000 + Duration.Milliseconds
                Debug.Print(i.ToString() + " " + ((Total / 1024.0) / (Milliseconds / 1000.0)).ToString("N2") + "    " + Total.ToString() + "    " + Milliseconds.ToString())
            Next
        End Sub
    End Module
End Namespace

@ John:

I added a debug.print line when the program starts. After the program either appeared to stop running (printing anything), crashed (at the line Using Response = …), or I gave up waiting, I stopped and restarted the program. As you scroll down you will see each one of these instances.
I confess that I do not understand what the program is doing, perhaps you can enlighten me.
Let me know if you want any other testing.

Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 198
SPOT NAVAC True
SPOT NADRC
1 0.00 0 140
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 193
SPOT NAVAC True
SPOT NADRC
1 0.00 0 143
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 192
SPOT NAVAC True
SPOT NADRC
1 0.00 0 138
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 191
SPOT NAVAC True
SPOT NADRC
1 0.00 0 152
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 187
SPOT NAVAC True
SPOT NADRC
1 0.00 0 144
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 192
SPOT NAVAC True
SPOT NADRC
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::send [IP: 0000] ####
#### System.Net.Sockets.Socket::Send [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Write [IP: 0051] ####
#### System.Net.InputNetworkStreamWrapper::Write [IP: 000a] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 007d] ####
#### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 0092] ####
#### SocketException ErrorCode = 10053
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message:
#### System.Net.HttpWebRequest::GetResponse [IP: 00c8] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 0092] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 209
SPOT NAVAC True
SPOT NADRC
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::recv [IP: 0000] ####
#### System.Net.Sockets.Socket::Receive [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Read [IP: 0062] ####
#### System.Net.InputNetworkStreamWrapper::RefillInternalBuffer [IP: 0038] ####
#### System.Net.InputNetworkStreamWrapper::Read_HTTP_Line [IP: 004b] ####
#### System.Net.HttpWebRequest::ParseHTTPResponse [IP: 002e] ####
#### System.Net.HttpWebRequest::GetResponse [IP: 0035] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 0092] ####
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message:
#### System.Net.HttpWebRequest::GetResponse [IP: 00c8] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 0092] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
Program Starts
Waiting…0
Waiting…1
Waiting…2
Waiting…3
SPOT NADRC
SPOT NAVAC True
SPOT NADRC
Waiting…4
Waiting…5
Waiting…6
Waiting…7
Waiting…8
Waiting…9
Waiting…10
Waiting…11
Waiting…12
Waiting…13
Waiting…14
Waiting…15
Waiting…16
Waiting…17
Waiting…18
Waiting…19
Waiting…20
Waiting…21
Waiting…22
Waiting…23
Waiting…24
Waiting…25
Waiting…26
Waiting…27
Waiting…28
Waiting…29
Waiting…30
Waiting…31
Waiting…32
Waiting…33
Waiting…34
Waiting…35
Waiting…36
Waiting…37 (gave up waiting…)
Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC
0 0.00 0 185
SPOT NAVAC True
SPOT NADRC
1 0.00 0 136

All the program is doing is opening the network interface and then communicating over the network, in this case, getting a file from bing.com. Would you mind adding some spacing so I can see the different test runs clearly?

@ John: I also wanted to mention that I have not seen the mail loop where the robots.txt is retrieved execute more than once without the program stalling.

Use the line “Program Starts” to mark the start of each execution sequence.

Yeb, it is in my side :slight_smile:

I only tried to answer your questions about socket 6 and CHipworkX while we are trying to reproduce the issue.

@ John:
Here are some more results.
I added debug.print lines at the beginning and end of the code, and after the http request is finished to show the value of Total (always 0).
As you can see, sometimes it connects to dhcp…

Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 188
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::recv [IP: 0000] ####
#### System.Net.Sockets.Socket::Receive [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Read [IP: 0062] ####
#### System.Net.InputNetworkStreamWrapper::RefillInternalBuffer [IP: 0038] ####
#### System.Net.InputNetworkStreamWrapper::Read_HTTP_Line [IP: 004b] ####
#### System.Net.HttpWebRequest::ParseHTTPResponse [IP: 002e] ####
#### System.Net.HttpWebRequest::GetResponse [IP: 0035] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 00b8] ####
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10053
#### SocketException ErrorCode = 10053
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message:
#### System.Net.HttpWebRequest::GetResponse [IP: 00c8] ####
#### MFConsoleApplication1.MFConsoleApplication1.Module1::Main [IP: 00b8] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 190
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 145
Total read = 0
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 189
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 146
Total read = 0
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
Waiting…3
SPOT NAVAC True
Waiting…4
SPOT NADRC; IP 0.0.0.0
0 0.00 0 193
Total read = 0
1 0.00 0 139
Total read = 0
2 0.00 0 138
Total read = 0
3 0.00 0 136
Total read = 0
4 0.00 0 137
Total read = 0
5 0.00 0 138
Total read = 0
6 0.00 0 157
Total read = 0
7 0.00 0 137
Total read = 0
8 0.00 0 143
Total read = 0
9 0.00 0 140
Total read = 0
10 0.00 0 135
Total read = 0
!!! Program finished
Done.
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 191
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 142
Total read = 0
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
Waiting…3
SPOT NAVAC True
Waiting…4
SPOT NADRC; IP 0.0.0.0
0 0.00 0 196
Total read = 0
1 0.00 0 137
Total read = 0
2 0.00 0 137
Total read = 0
3 0.00 0 138
Total read = 0
4 0.00 0 167
Total read = 0
5 0.00 0 138
Total read = 0
6 0.00 0 138
Total read = 0
7 0.00 0 136
Total read = 0
8 0.00 0 138
Total read = 0
9 0.00 0 139
Total read = 0
10 0.00 0 139
Total read = 0
!!! Program finished
Done.
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 188
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 142
Total read = 0
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 189
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 145
Total read = 0
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
Waiting…3
SPOT NAVAC True
Waiting…4
SPOT NADRC; IP 0.0.0.0
0 0.00 0 200
Total read = 0
1 0.00 0 139
Total read = 0
2 0.00 0 137
Total read = 0
3 0.00 0 138
Total read = 0
4 0.00 0 138
Total read = 0
5 0.00 0 139
Total read = 0
6 0.00 0 138
Total read = 0
7 0.00 0 138
Total read = 0
8 0.00 0 138
Total read = 0
9 0.00 0 137
Total read = 0
10 0.00 0 139
Total read = 0
!!! Program finished
Done.
Step into: Stepping over method without symbols ‘MFConsoleApplication1.MFConsoleApplication1.Module1._Closure$__1._Closure$__1’


Program Starts
Waiting…0
Waiting…1
Waiting…2
SPOT NADRC; IP 0.0.0.0
0 0.00 0 189
Total read = 0
SPOT NAVAC True
SPOT NADRC; IP 192.168.250.67
1 0.00 0 143
Total read = 0

@ rockybooth - Do you just restart debugging between each run without removing power?

Yes

@ John, @ Dat:
Any progress on resolving this DHCP issue, or status you can share?
If you would like me to test hotfixes just let me know, Dat has my private email.
Rocky

Our team focus on network now. After we see that it perfects in our side, we may need your help on your issue. It will be soon. Your issue is on our top priority, so don’t worry.

I have another issue with the beta install. This is a multiproject solution that has run fine under the 4.2 version.
After installing the 4.3beta, and keeping this project still in 4.2, I find that to compile I have to remove some references to microsoft dlls that show up as version 0.0.0.0 and reinstall them. Most of the other dlls still show up in the proper version. I have added an image of the impacted dlls.

The second problem is the following error:

[quote]Error 59 Could not copy the file “D:\FIRMWARE\NetMF\NET Working Micro 131216\NET Working Micro\NET Library\CommonGadgets\bin\Debug\LE\GTM.GHIElectronics.LED_Strip.pe” because it was not found. Library
[/quote]

This also shows up for SDCard.pe, but not for the rest of the modules that are installed.

Can anyone suggest a workaround. I tried manually placing the files in that directory, but this does not work at the clean at the start of the build removes them.

Thanks

Ok, I see for my second issue, that these errors refer to the modules WITH the UNDERSCORE, while they have been renamed in 4.3 to delete the underscore. So, LED_strip becomes LEDstrip.
The Program.gadgeteer uses the names without underscore, as does
The References, call for the NoUnderscore names of the dlls, which do exist for both 4.2 and 4.3.
I get a similar error for the file SDCard.pe, listed WITHOUT the underscore.

I SOLVED the problem by searching the references of each project in my solution and removing and readding these two dlls. I have no idea why the other modules did not cause the same issues,

And, in the release notes there was a warning about the underscores being removed in some names. I just did not know the implication.

Just sharing… ???

Where did EthernetENC28J60.CableConnectivityChanged event go?! :open_mouth:

@ Simon from Vilnius - CableConnectivityChanged was just a wrapper around NetworkChange.NetworkAvailabilityChanged so to it was removed to reduce duplication. It wasn’t in the last beta either.

Oh! Ok then.

Documentation glitch: GHI.Processor.Configuration.Display.Save() says “Saves the startup [em]logo [/em]configuration to the device.”. I believe it was copy-pasted from somewhere else…

2014 R2B2 and R2B1:

FezConfig crashes when updating friendly name. (Cerberus, G400. Windows 8.1)

1 Like

A few notes on RTC class.

[ul].[em]Date[/em], .[em]Time [/em]and .[em]Now [/em]properties should be methods (.[em]GetDate/em, .[em]GetTime/em, .[em]GetNow/em, because every time they are called, they return different value, although no parameters are changed (Framework Design Guidelines, section 5.1.3). Those three fields are very dynamic, and I feel nouns misleading here. By the time I read them, they are outdated. When I first typed-in the RTC class, I was simply staring at those three properties, thinking of what to do next. I think [em]GetTime/em, [em]GetDate/em, [em]GetNow/em, [em]SetTime/em, [em]SetDate/em, [em]SetNow/em would work better. [/ul]
[ul]Consider changing .[em]Now [/em]to .[em]DateTime[/em]. When property .Now is all alone in the class, it may be tolerated, but when there’s also .[em]Date [/em]and .[em]Time[/em], it just looks awkward. If .[em]Now [/em]is now, then .[em]Date [/em]is when? Yesterday?..[/ul]
[ul]What is the difference between .[em]Now [/em]and .[em]Date[/em]? They both return DateTime object.[/ul]
[ul]What does .[em]Time [/em]property do? Docs say “The current RTC time”, but it’s clearly not, because it return a TimeSpan object, which a [em]duration[/em]. Duration since when? Since the Big Bang? :)[/ul]

The more I write, the less I understanf this class :slight_smile: Why not just leaving one property (.[em]Alarm[/em]) and two methods (.[em]SetDateTime/em and .[em]GetDateTime/em)? :slight_smile: I believe I do not want anything else from it…

By the way, if anyone thinks of DateTime.Now as an example here, note that it was a mistake that is too widespread to fix. It should have been a method, not a property (Framework Design Guidelines, page 136).

3 Likes

Also MS recognized that it was a bad idea to make DateTime.Now a property, a while after they introduced .NET. But they didn’t want to change it later.

If .Time returns a TimeSpan, I would assume it’s the time since the beginning of the day.

The difference between .Date and .Now should be that the ‘time’ in .Date should be ‘zero’ (beginning of current day).

I haven’t tried 4.3 so far, but that is what the names imply to me.

Watchdog time!

1. There’s .MaxTimeoutPeriod and .TimeoutPeriod properties. In which units? Not indicated in the documentation. It took me a few recoveries from crashed G400 to understand it is probably in milliseconds.

2.I tried setting maximum timeout, and I was very surprised the following line throwed an exception:


It looks like the correct way is:

```cs]GHI.Processor.Watchdog.TimeoutPeriod = GHI.Processor.Watchdog.MaxTimeoutPeriod-1;[/code

I find it counter-intuitive and totally pointless. Unnecessary extra calculation and documentation reading. I think .TimeoutPeriod should be less or [em]equal [/em]to .MaxTimeoutPeriod.

[b]3.[/b]If Watchdog is not enabled, .ResetCounter() throws an exception. Suggestion: silently return instead. This is an embedded application, so the smaller the number of throwed exceptions, the better — especially when every exception is printed to debug output, and we already know what kinds of weird troubles that may cause. So, if watchdog is enabled, ResetCoutner() reset the counter, and if not — simply returns. I think hurts nobody.

[b]4. [/b]Suggestion: add all the possible MaxTimeoutPeriods of all devices to the description of .MaxTimeoutPeriod. Would be handy. I already know (experimentally) that maximum period is (15.995-0.001) for G400, but I have no idea about G120 and EMX.

[b]5.[/b] .TimeouPeriod docs tell it can only be set once, but it is not true: 

```cs
  Debug.Print(GHI.Processor.Watchdog.TimeoutPeriod.ToString()); //Prints 0
            GHI.Processor.Watchdog.TimeoutPeriod = GHI.Processor.Watchdog.MaxTimeoutPeriod - 1;
            Debug.Print(GHI.Processor.Watchdog.TimeoutPeriod.ToString()); //Prints 15994
            GHI.Processor.Watchdog.TimeoutPeriod = GHI.Processor.Watchdog.MaxTimeoutPeriod - 1000;
            Debug.Print(GHI.Processor.Watchdog.TimeoutPeriod.ToString()); //Prints 14995

6. System dies if setting Enable property more than once — could we please survive? Maybe a silent return?

7. Suggestion: summing a few points above, I suggest a remake. a) make .TimeoutPeriod property read-only. b) make .Enabled property also read-only c) create method Enable(int timeoutPeriod). Then, usage of the Watchdog will be less tricky, easier to use and will reflect the actual behaviour better (at least for G400):

Debug.Print(Watchdog.TimeoutPeriod.ToString()); //prints 0
Watchdog.Enable(Watchdog.MaxTimeoutPeriod); //enables watchdog and sets the 
period
Debug.Print(Watchdog.TimeoutPeriod.ToString()); //prints 15995
while(true)
{
    if (Watchdog.Enabled) Watchdog.ResetCounter();
    Thread.Sleep(1000)
}
2 Likes