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.

Bendage

Member Since 17 Nov 2011
Offline Last Active Sep 20 2016 11:31 PM
-----

Posts I've Made

In Topic: NeonMika.Webserver

27 December 2012 - 11:15 PM

Here is another non trivial fix. There are two threads fighting to flash the onboard LED.

 

In the static main remove the entire while loop with Thread.Sleep(Timeout.Infinite)


In Topic: Plus 2 Pins compatiability different or defective board?

27 December 2012 - 11:03 PM

LOL! Thanks


In Topic: NeonMika.Webserver

27 December 2012 - 11:02 PM

Chris,
FYI I had the same mercer problem explained here Blue screen.
I first suspected was my pc, but I tried at least 5 times and had always the same result using this web server project. After reflashing the board, I tested may other
project with no problem, as soon as I start this web server everything hangs.
Moreover, trying to detach the USB cable during VS hang, blue screen appears, while terminating VS first and then detach the board no blue screen appear, and I only have to
reflash the board.

Hope this could help you
Gerardo

Hey Gerardo,

 

Never unplug the USB cable while VS is deploying. The BSOD is sure to follow. There is an option to cancel deployment under View/Toolbars/Build

 

Always use this and DO NOT unplug the board. I realize this does not fix the issue that the 3 of us cannot reproduce but there is definitely an issue I can vouch for. Since I just got my N+2 today it will take me a bit of time to figure out whats going on.


In Topic: NeonMika.Webserver

27 December 2012 - 10:56 PM

Chris, it's difficult to share the code, because VS hangs, the board hangs, the result in th debug window exactly the same of Mercer one. I'm using N2+ with 4.2.1.2 Today i was testing even the netmftoolbox-20443 basic speaker sample, and i had the same result: VS and the board hang. VS must be terminated, and the board must be reflashed. Thank you, and I want to thank you for N2+, absolutely a great project! Gerardo

 

I had the same problem. Flashed my board twice! Daves build works plus the bug fix I posted. Runs fine.


In Topic: NeonMika.Webserver

27 December 2012 - 10:51 PM

Ok, I have successfully got this running on N+2 but there is a bug in the socket code that causes the web server to drop the client about 3 out of 5 requests.Here is where the bug is under the server.cs...

 

The problem is that when the socket connects there are not bytes yet in the buffer. If the byte count is 0 he breaks out which causes the client browser to receive a dropped connection. This can be fixed by inserting a thread.sleep(100) up a few lines. Once this sleep is placed initially before the first byte check, the buffer has enough time to start populating. I have commented where the thread.sleep needs to be Fix that and this thing purrs.

 

Very nice web server. TONS of functionality.

private void WaitingForRequest( )        {            while ( true )            {                try                {                    using ( Socket clientSocket = _ListeningSocket.Accept( ) )                    {                        // Add the Thread.Sleep(100) Here                         int availableBytes = 0;                        int newAvBytes;                        //if not all incoming bytes were received by the socket                        do                        {                                                       newAvBytes = clientSocket.Available - availableBytes;                            if ( newAvBytes == 0 )                                break;                            availableBytes += newAvBytes;                            newAvBytes = 0;                            Thread.Sleep(1);                        } while ( true );                        if ( availableBytes > 0 )                        {                            byte[] buffer = new byte[availableBytes > Settings.MAX_REQUESTSIZE ? Settings.MAX_REQUESTSIZE : availableBytes];                            byte[] header = new byte[0];                            int readByteCount = clientSocket.Receive(buffer, buffer.Length, SocketFlags.None);                            for ( int headerend = 0; headerend < buffer.Length - 3; headerend++ )                            {                                if ( buffer[headerend] == 'r' && buffer[headerend + 1] == 'n' && buffer[headerend + 2] == 'r' && buffer[headerend + 3] == 'n' )                                {                                    header = new byte[headerend + 4];                                    Array.Copy(buffer, 0, header, 0, headerend + 4);                                    break;                                }                            }                            //reqeust created, checking the response possibilities                            using ( Request tempRequest = new Request(Encoding.UTF8.GetChars(header), clientSocket) )                            {                                Debug.Print("... Client connected ... URL: " + tempRequest.URL + " ... Final byte count: " + availableBytes);                                if ( tempRequest.Method == "POST" )                                {                                    //POST was incoming, it will be saved to SD card at Settings.POST_TEMP_PATH                                    PostToSdWriter post = new PostToSdWriter(tempRequest, buffer, header.Length);                                    post.Receive( );                                }                                //Let's check if we have to take some action or if it is a file-response                                 HandleGETResponses(tempRequest);                            }                            Debug.Print("Client loop finished");                            try                            {                                //Close client, otherwise the browser / client won't work properly                                clientSocket.Close( );                            }                            catch ( Exception ex )                            {                                Debug.Print(ex.ToString( ));                            }                        }                    }                }                catch ( Exception ex )                {                    Debug.Print(ex.Message);                }            }        }

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.