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.

kennethone

Member Since 14 Sep 2011
Offline Last Active Oct 16 2013 11:36 PM
-----

Topics I've Started

Netduino Plus I2C just stops working ?!

04 April 2013 - 08:15 PM

Good Afternoon,

 

I've been testing I2C on two netduino plus devices and I found that on both, after a certain time, the I2C port stops outputting any data and the SDA line stays high ~ 5 V for me and the SCK line stay at around 400mV (using digital scope). I can still breakpoint and step through all of the managed I2C code without any errors, but the status of the lines does not change. 

If I leave the device plugged in, and re-deploy the application, the lines stay in the non-functional state. It is only after I unplug and power cycle the device, the lines begin working again.

 

My SDA and SCL lines are pulled up using 4.7K resistors. Device under test is PF575 and functions without problems.

 

This problem also repeats itself when I use the netduino by itself and hook up the SDA and SCL lines to 5V using 2 15K resistors. When I do this, the SDA line does not get ACK response, but the activity is still visible on the oscilloscope. For some time, after which is stops working and requires a power cycle.

 

 

 

 

Is this an issue which may have been recently fixed by a firmware update? Should I update my firmware? Thanks,

 

 

 

 

 

DeviceInfo:
  HAL build info: 4.1.2821.0, Netduino Plus by Secret Labs LLC
  OEM Product codes (vendor, model, SKU): 34, 177, 4097
  Serial Numbers (module, system):
    00000000000000000000000000000000
    0000000000000000
  Solution Build Info: 4.1.0.6, Netduino Plus by Secret Labs LLC
  AppDomains:
    default, id=1
  Assemblies:
    mscorlib,4.1.2821.0
    Microsoft.SPOT.Native,4.1.2821.0
    Microsoft.SPOT.Hardware,4.1.2821.0
    Microsoft.SPOT.Net,4.1.2821.0
    System,4.1.2821.0
    Microsoft.SPOT.IO,4.1.2821.0
    System.IO,4.1.2821.0
    Microsoft.SPOT.Hardware.SerialPort,4.1.2821.0
    Microsoft.SPOT.Hardware.Usb,4.1.2821.0
    SecretLabs.NETMF.Hardware,4.1.0.0
    SecretLabs.NETMF.Diagnostics,4.1.0.0
    I2C test,1.0.0.0
    SecretLabs.NETMF.Hardware.NetduinoPlus,4.1.0.0

Recompiling the firmware and accessing and changing register values from C#

27 March 2013 - 08:33 PM

Good afternoon,

 

Unfortunately, I was not able to find any documentation on low-level programming of the NetDuino and I have to ask a few questions in order go beyond building standard applications for the NetDuino. I fully understand that this render my device useless and I am willing to take the risk. Also I understand that NetDuino is an open source firmware and hardware platform and modifying/recompiling the firmware is allowed under the license, please correct me if I am wrong.

 

 
  • I am trying to write directly to registers from C#, but I cannot find if this functionality is available in the C# language wrapper for NetDuino. I need this for several purposes, to enable some modules on the AT91 that are not available through the Netduino firmware. Particularly, right now I am trying to enable PCK1 and PCK2 to get two additional PWM outputs (I need 6 total).

 

What is the best possible option for me to access registers directly from C#? If this functionality is not available for some reason, what is the best recommendation? modify the firmware and perform this in C++?

 

 

  • I am new to working with .net micro framework  and I wanted to ask some questions about how the compiler works

 

I understand that there are 2 components that compile into the firmware:

  • TinyBootLoader
  • C++ Device Code which is: TinyCLR, .net Micro SPOT .net micro libraries, and SecretLab.MF.Hardware libraries.

Is this correct?

 

 

  • If I wanted to recompile and re-flash the firmware for NetDuino, is this the correct procedure?
  • Build a project file in an IDE such as eclipse with an Arm7 compiler such as Yagarto using the netduino firmware with the 3 libraries above.?
  • Get .net Micro Porting kit 4.1
  • Get Microsoft SDK 7.1
  • Get .net Micro Firmware 4.1
  • Copy contents of firmware to .net PK directory
  • Run msbuild to compile for Arm 7
  • Flash it using the SAM-BA tool from Atmel  MFDeploy tool 

I'm still waiting on Windows SDK download. Does msbuild have a toolchain for ARM7? Are there any specific instructions on builidng the firmware?

 

Thanks,

 

 

  • What exactly is the TinyBooterDecompressor? How is this different from TinyBootLoader?

 

 

Thank you all for your responses. If there is an easier way to achieve what I need without modifying the firmware, that would be great, but I am still very interested in learning how to work with ARM devices and expanding my understanding beyond what is provided for general use of the Netduino platform.

 

 

Thank you,


Need help determining if socket connection exists

04 September 2012 - 08:19 PM

Good afternoon,

My objective:

1. Open socket connection with Socket clientSocket = socket.Accept()
2. Listen, read data, send data,
3. Check if socket is still open
4. If yes, continue listening, if no go back to step 1

This needs to be reliable so that if the PC program is closed or terminated, it should be able to restart and resume sending and receiving messages


My issue:
1. I have to run a double loop, if the inside loop is taken out, the client(PC)/server(Netduino Plus) exchange 1 set of messages, then the client receives around 18 blank messages, then I get an error "Unable to write data to the transport connection: An established connection was aborted by the software in your host machine."
Same error happens if I stop the program on the PC and restart it again.


2. I cannot find a method to check if the socket is still connected. I read that in .Net framework, there is a method System.Net.Sockets.Connected(), but it's missing in the .Net Micro framework. I tried using .Available, but this method just seems to check how much data is available in the buffer, doesn't check if the socket is open


Can someone help me verify that I am doing this correctly,

Server (Netduino Plus) code
public WebServer()
        {
            Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp();
            //Initialize Socket class
            Thread.Sleep(2000);
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //Request and bind to an IP from DHCP server
            
            socket.Bind(new IPEndPoint(IPAddress.Any, 80));
            //Debug print our IP address
            Debug.Print(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);
            //Start listen for web requests
            socket.Listen(10);
            ListenForRequest();
        }
        public void ListenForRequest()
        {
            while (true)
            {
                using (Socket clientSocket = socket.Accept())
                {
                    //while (clientSocket.Available == 0) //Must have this if sending repeated messages
                    while(sw.Read() == true)
                    {
                        //Get clients IP
                        IPEndPoint clientIP = clientSocket.RemoteEndPoint as IPEndPoint;
                        EndPoint clientEndPoint = clientSocket.RemoteEndPoint;
                        //int byteCount = cSocket.Available;
                        int bytesReceived = clientSocket.Available;
                        if (bytesReceived > 0)
                        {
                            //Get request
                            byte[] buffer = new byte[bytesReceived];
                            int byteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None);
                            string request = new string(Encoding.UTF8.GetChars(buffer));
                            Debug.Print(request);
                            //Compose a response
                            string response = "Hello World";
                            string header = "HTTP/1.0 200 OK\r\nContent-Type: text; charset=utf-8\r\nContent-Length: " + response.Length.ToString() + "\r\nConnection: close\r\n\r\n";
                            clientSocket.Send(Encoding.UTF8.GetBytes(header), header.Length, SocketFlags.None);
                            clientSocket.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None);
                            //Blink the onboard LED
                            //led.Write(true);
                            Thread.Sleep(150);
                            //led.Write(false);
                        }
                    }
                }
            }
        }



Client (PC) code


            byte[] data = new byte[1024];
            string input, stringData;
            TcpClient server;
            try
            {
                server = new TcpClient("169.254.226.240", 80);
            }
            catch (SocketException)
            {
                label1.Text = "Unable to connect to server";
                return;
            }
            
            NetworkStream clientStream = server.GetStream();
            ASCIIEncoding encoder = new ASCIIEncoding();
            byte[] buffer = encoder.GetBytes("Hello Client!");
            while (true)
            {

                if (clientStream.CanWrite)
                {
                    clientStream.Write(buffer, 0, buffer.Length);
                    clientStream.Flush();
                }
                if (clientStream.CanRead)
                {
                    byte[] myReadBuffer = new byte[1024];
                    StringBuilder myCompleteMessage = new StringBuilder();
                    int numberOfBytesRead = 0;

                    // Incoming message may be larger than the buffer size. 
                    do
                    {
                        numberOfBytesRead = clientStream.Read(myReadBuffer, 0, myReadBuffer.Length);

                        myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));

                    }
                    while (clientStream.DataAvailable);

                    // Print out the received message to the console.
                    Console.WriteLine("You received the following message : " +
                                                 myCompleteMessage);
                }
                Thread.Sleep(1000);
                //break;
            }

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.