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.

R.Ganesh's Content

There have been 12 items by R.Ganesh (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#27159 HttpListener does not respond

Posted by R.Ganesh on 13 April 2012 - 03:43 PM in General Discussion

Hi Glen, I tried using the multi-threaded variant, but no luck.. seems like a low level socket exception brings down the connectivity and is not recovered until a reset is done.. Cheers! Ganesh



#24920 HttpListener does not respond

Posted by R.Ganesh on 01 March 2012 - 06:20 PM in General Discussion

Hi all,

I have a web server running on an Netduino plus using the HttpListener listening for client requests and responding with a simple html. I am investigating a problem at a project installation, where the web server stops responding after few days of working (client requests are not so often, once in a day or even longer). I tried to reproduce the problem but did not succeed. However, during testing I noticed that one way to make the web server non-responsive is to send a burst of requests - i did this by keeping F5 key pressed in the internet explorer (continously refereshes). After this, the web server stops responding. First, the code (simplified):
internal static void RunServer()
        {
            HttpListener listener = new HttpListener("http", -1);
            listener.Start();

            while (true)
            {
                try
                {
                    Debug.Print("Listening..");
                    HttpListenerContext context = null;
                    context = listener.GetContext();
                    Debug.Print("Received request from " +  context.Request.UserHostAddress.ToString());
                    context.Response.ContentType = "text/html";
                    string html = "<html><p>Hello World " + DateTime.Now.ToString() + "</p></html>";
                    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                    byte[] messageBody = encoding.GetBytes(html);
                    context.Response.OutputStream.Write(messageBody, 0, messageBody.Length);

                    if (context.Response != null)
                        context.Response.Close();
                }
                catch (Exception e)
                {
                    Debug.Print("Exception occured! " + e.Message);

                    PowerState.RebootDevice(true, 1000);
                }
            }
        }
Next, the version information:

.NetMF v4.1.2821.0
NetduinoPlus, Build Date:Mar 26 2011 02:15:31
ARM Compiler version 400902
TinyCLR (Build 4.1.2821.0)

Finally, the exception (as seen on MF Deploy console)

Listening..
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (5) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::accept [IP: 0000] ####
#### System.Net.Sockets.Socket::Accept [IP: 001c] ####
#### System.Net.HttpListener::AcceptThreadFunc [IP: 0020] ####
#### SocketException ErrorCode = 10056
Received request from 4.0.0.0
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (4) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::send [IP: 0000] ####
#### System.Net.Sockets.Socket::Send [IP: 0018] ####
#### System.Net.Sockets.NetworkStream::Write [IP: 0051] ####
#### System.Net.OutputNetworkStreamWrapper::Write [IP: 0017] ####
#### System.Net.HttpListenerResponse::SendHeaders [IP: 0021] ####
#### System.Net.OutputNetworkStreamWrapper::Write [IP: 000d] ####
#### NetduinoTest.WebServer::RunServer [IP: 0074] ####
#### SocketException ErrorCode = 10056
Exception occured! Exception was thrown: System.Net.Sockets.SocketException

Any pointers on this would be really helpful to me! Thank you!

Ganesh



#16140 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 01 August 2011 - 07:02 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Jason, I had done only some cosmetic changes to the code, but not really towards refining it. Since the functions were working fine, I have been too lazy to work on it (thats the curse of prototype code, remains a prototype). If you just need the basic functio of transmit/recieve and you are happy to set the parameters in the library code then you could put it to use wihtout much worries. The trouble with creating a generic library is that it needs to be tested out. Cheers Ganesh



#14631 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 23 June 2011 - 01:12 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi James, It should work with the jeelabs node (it is basically the RFM12B on a nice board). I have not tried it, but my gut feeling is that it should work without problems. Let me know how it went if you try it out. Cheers Ganesh



#12898 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 06 May 2011 - 02:32 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Mike, I have attached the current library. It is not finished - at the moment i am trying to find the settings for highest speed and also for highest range. With the configuration set now, you can achieve 5388 bps and range of approx 25m in a normal home enviroment (incl. a wall in between). So far, I am happy with it. I would have loved to see higher speeds working but then the limitation is the SPI module in netduino (not the spi clock rate, but the lag between two consequetive write operations - the RFM expects all bytes to be clocked in within the net baudrate period. you can have higher speeds but with smaller payload. Since the overhead bytes of preamble, sync and crc is already 9 bytes, it does not make sense to transmit less that 16 bytes just to achieve speeds higher than 5338 bps). I will refine the library with some property accessors etc. and then post the final version again. Meanwhile if you have any suggestions or comments please let me know. There is a nice tool to calculate the commands: http://www.kewlit.com/RFM12B/ Regards Ganesh

Attached Files




#12738 Energy meter

Posted by R.Ganesh on 01 May 2011 - 07:04 PM in Netduino 2 (and Netduino 1)

Hi all, I ported the current & voltage measure code written for Arduino in the Open Energy Monitor project (http://openenergymonitor.org/emon/). Hope you will find it useful. Cheers Ganesh

Attached Files




#12720 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 01 May 2011 - 07:20 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Corey, Yes..C# lulled me into coding irresponsibly :rolleyes: I changed the code so that a pre-defined string[] was used in the loop. This of course solved the problem. Cheers Ganesh



#12663 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 30 April 2011 - 06:51 AM in Netduino Plus 2 (and Netduino Plus 1)

Success at last!

The problem was in the receive routine - and all because of some string operation for debug message.

for (int i = 0; i < 16; i++)
{
data[i] = (byte)RF12_RECV();
//dbg += data[i].ToString() + " ";
ChkSum += data[i];
}

The line dbg += data[i].ToString() + " "; takes 1.35 ms to execute!! This delays clearing up of the fifo buffer and gets overwritten by the next transmit.

Now need to look into why string operation takes such a long time. Any ideas here..?

Cheers



#12610 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 28 April 2011 - 07:21 PM in Netduino Plus 2 (and Netduino Plus 1)

I could get further deep into the problem - the rate at which I can send the bytes via SPI seems to be limited - i.e. between two spi.WriteRead(..), it takes at least 350uS - which means that the maximum rate at which I can send multibyte packets to RFM is about 22857 bps. I presume that if I can reduce the lag between two spi writes then I can send data at higher rate... I will work on this further. Any pointers would be very helpful at this stage :) Cheers

Attached Thumbnails

  • netduino_spi.JPG



#12521 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 27 April 2011 - 05:55 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, I agree, the example code is too high level to determine anything. I am going to dig deeper to determine the cause - I will post the update. I got the RFM module from http://www.watterott...-S2-Transceiver (In the U.S, I guess www.sparkfun.com would be easier). I got the module and soldered wires to a set of header pins. Also Jeelabs has a board: http://jeelabs.com/p...ts/rfm12b-board Testing with just 2400bps, I think the RFM12B is a very nice hardware to achieve wireless (bidirectional) communication. Cheers Ganesh



#12503 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 26 April 2011 - 04:56 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Chris, Stefan, First, the "Netduino Plus(Tx) --------> Netduino Plus (Rx) = Max 2400 bps" was supposed to mean the RFM module on two netduinos (the dotted line indicating the RF link). Sorry, that was not clear. I have attached the RFM library (it is still very prototype, I intend to to evolve it into a proper lib). The code is as follows: 1. On the Tranmitting Netduino, the library function transmit is called with 16 byte payload: <code> RFM12B rfmModule = new RFM12B(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D0, Pins.ONBOARD_LED); while (true) rfmModule.Transmit(new byte[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F }); </code> 2. On the Recieving Netduino, the code is as follows: <code> RFM12B rfmModule = new RFM12B(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D0, Pins.ONBOARD_LED); while (true) rfmModule.Recieve(); </code> 3. In the library, the SPI port is inited like: SPI.Configuration spiConfig = new SPI.Configuration(spiSelectPin, false, 0, 0, false, true, 1000, spiModule); _spiPort = new SPI(spiConfig); (Note: I have tried different clock speeds: from 50khz to 10000khz) 4. What I noticed using a logic analyzer is that the SPI clock freq is around 200Khz. And, the time taken to do the read of the RFM Int input (digital input) is around 1.5ms. 5. I am using firmware 4.1.1 beta. Thanks a lot for your interest and infos. It is a pleasure working with a group that is so alive! Cheers Ganesh

Attached Files




#12494 RFM12B Wireless module with Netduino Plus

Posted by R.Ganesh on 26 April 2011 - 08:12 AM in Netduino Plus 2 (and Netduino Plus 1)

Hello all, This is my first project with Netduino platform (using netduino plus variant) - I am trying to integrate the Hope RF's RFM12B module to netduino plus (there is are existing examples for Arduino, AVR etc.). I wrote my own .net mf library for this purpose so that it is easier to debug and change the low level functions. Everything works fine, except that the max baud rate achievable with Netduino plus is 2400 bps. The same code when tested on FEZ Cobra works fine for baud rate upto 115.2 kbps. My test setup: Trying to send 16 bytes. Netduino Plus (Tx) ------> FEZ (Rx) = Max 2400 bps FEZ (Tx) ----------> Netduino Plus (Rx) = Max 2400 bps Netduino Plus(Tx) --------> Netduino Plus (Rx) = Max 2400 bps FEZ (Tx) -----------> FEZ (Rx) = Max 115.2 Kbps. I tried to find out the difference between the two platforms and what seems to be a possible cause is that the netduino plus is slower when it comes to SPI clock frequency (200 kHz, as compared to 20 MHz of FEZ Cobra) and also the time required to accomplish an input port read (to check the RFM ready state) is appox 1.5 ms in netduino plus (as compared to 200 uS in FEZ). The slower read of the RFM's ready state results in longer time required to send the data payload. When only one or two bytes is the length of the payload, the netduino plus is able to send the packets at baud rate of 4800 bps max. Can this issue be really due to slower processing on Netduino? Thanks a lot for any help or pointers! Cheers Ganesh




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.