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.

SteveS123

Member Since 09 Oct 2013
Offline Last Active Apr 28 2014 08:31 PM
-----

Topics I've Started

socket.connect freezes ND

01 April 2014 - 08:22 PM

I have 7 ND+2's talking to each other over ethernet and it works pretty well most of the time but I occasionally get a controller drop out and not even be pingable(using DOS command prompt) for no reason.  The code is at a state where it is just waiting for incoming data so I can rule out the idea of the code causing the issue.  All seven controllers are running the same code for the most part.  I am controlling LED strands on a separate thread using SPI.  

 

My first problem is that the ND will just be unresponsive to a ping at any random time.  I have the socket option set to KeepAlive also.  (If I have all the controllers working before I leave work around 5pm and return at 8am I will usually have around three controllers unpingable, the number will change from day to day)  Is this a common issue with the ND+2?  I tried firmware 4.2 and now I'm using 4.3 and it acts the same.  The devices are all set to static and I have the router holding those addresses for the ND's

 

My second problem is when I try to do a socket.connect(RemoteEndpoint).  If the endpoint is not responsive(i.e. cable unplugged) then the program just sits there waiting and will never throw an exception or move on; I have to reboot the device to get past this error.  I've read some forums that this has been corrected on ver 4.3 but it did the same thing with ver 4.2.

 

Any help would be greatly appreciated,

Steve


No ACT light on startup

11 March 2014 - 01:24 PM

I have many ND+2's and there is one in particular that doesn't respond to plugging in an ethernet cable until I press the onboard button.  

This is a fresh flash of version 4.3.  I am able to execute code on the device but there is just no ethernet activity until the button is pressed.  The version 4.2 did the same thing.  

1. I'm positive the cable and switch is good.

2. I can get activity if I press the onboard button.

 

What would cause this the device to obtain an IP address only if the onboard button is pressed?

 

Thank you in advance,

Steve


Ethernet drops connection randomly

09 March 2014 - 10:03 PM

I am connecting 10 ND+2 together and they all communicate with each other via Enet.  I have all of them set static.  My problem is that at random times I can't communicate with any one of the ND+2's.  The only way I can get the device to communicate is to reset the controller by unplugging it.  

 

Is there a way to prevent this?

Is there a way to open a socket connection and try to send to it but if the connection isn't available then just ignore the connection?  (I tried putting a "try-catch" in the code but the controller still hangs if there is no endpoint)

 

 

 

I'm new to sockets so if you know of a better way to do this I would greatly appreciate the advice.

 

Here is the way I'm doing the connections:

string rawData = "";
                using (Socket commSocket = socket.Accept()) 
                {
                    while (!commSocket.Poll(10, SelectMode.SelectRead)) ;
                    led.Write(true);
                    int bytesSent = commSocket.Available;
 
                    if (bytesSent > 0)
                    {
                        byte[] bytes = new byte[bytesSent];
                        int bytesReceived = commSocket.Receive(bytes, bytesSent, SocketFlags.None);
                        if (bytesReceived == bytesSent)
                        {
                            rawData = (new string(Encoding.UTF8.GetChars(bytes)));
                        }
                    }
                    char delimiter = ' ';
                    string[] words;
                    words = rawData.Split(delimiter);
                       
                            sequence = words[0];
                            red = byte.Parse(words[1]);
                            green = byte.Parse(words[2]);
                            blue = byte.Parse(words[3]);
                            LEDChain = words[4];
                            //speednMS = int.Parse(words[5]);
                            led.Write(false);
 
 try
                                {
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork,                    SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPCanIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPFloorIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPRibsIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPRevealIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
 
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPGreenScreenIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
 
                                    using (Socket sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                                    {
                                        sendSocket.SendTimeout = 1000;
                                        sendSocket.Connect(EPWelcomeIP);
                                        sendSocket.Send(Encoding.UTF8.GetBytes("SetColorAll");
                                        sendSocket.Close();
                                    }
                                }
                                catch (Exception)
                                {
 
                                    Debug.Print("Socket did not connect");
                                }

Update program.cs via ethernet

12 February 2014 - 08:31 PM

I would like to update my ND+2 from a network connection.  I did a forum search and found an article from 2011 but didn't get any valuable information.

http://forums.netdui...thernet +upload

 

I tried to connect to my ND+2 via MFDEPLOY by setting the config to network and by setting the IP.  I tried to ping the device and it doesn't show-up in MFDEPLOY but I can ping it through a command prompt.  I can verify the ping by unplugging the ND and the ping through command prompt will fail and work when I reconnect.

 

Is there a way to send the program.cs file to the device and update it over a local network?

 

Thanks in advance,

Steve


Change clock rate in "Toolbox.NETMF.Hardware.RgbLedStrip"

05 February 2014 - 06:35 PM

I'm trying the clock rate of the Toolbox.NETMF.Hardware>RgbLedStrip library but can't seem to succeed.

The library offers no access to the clock rate.

 

Steps taken so far:

1. Try to access the RgbLedStrip library.  - no access to clock settings

2. Instantiated a new spi.config and set it to SPI_Devices.SPI1.  - The changes in the new config didn't change my output.

 

The question is, how do I change the clock speed of the SPI while using the NETMF toolbox?

 

Here is the test code.

 

public class Program
    {
        private static RgbLedStrip Chain = new RgbLedStrip(RgbLedStrip.Chipsets.WS2801, 114, SPI.SPI_module.SPI1);  //45 count on FLOOR and 150 count for CAN
 
        public static void Main()
        {
            SPI.Configuration spiDevice1 = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, false, false, 100, SPI_Devices.SPI1);
            //The line above is supposed to set the SPI1 config.  I am trying to set the clock rate to 100 but there is no change in my program.
            //I even tried instantiating the "RgbLedStrip" with the above "spiDevice1" and still no change to the clock speed.
            while (true)
            {
                for (int i = 0; i < 74; i++)
                {
                    Chain.SetColor(i, 0x34BAC6, false);
                    Thread.Sleep(1);
                }
 
                for (int i = 74; i < 114; i++)
                {
                    Chain.SetColor(i, 0xFFFFFF, false);
                    Thread.Sleep(5);
                }
                Thread.Sleep(5000);
                Chain.SetColorAll(0x000000, false);
           }
       }
   }
             

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.