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.

Nerdiator's Content

There have been 3 items by Nerdiator (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#65238 How to communicate to your PC using the serial port?

Posted by Nerdiator on 22 June 2016 - 02:34 PM in Netduino 3

I can't seem to get Serial Communication with USB working. To clarify my problem, here is the code on my netduino 3

 

public class Program
    {
        static SerialPort _serial;
        private static Lcd _lcd;
        public static void Main()
        {
            _serial = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
            _serial.Open();
            _serial.DataReceived += _serial_DataReceived;


            var lcdProvider = new GpioLcdTransferProvider(Pins.GPIO_PIN_D12,    // RS
                                                        Pins.GPIO_PIN_D11,    // ENABLE
                                                        Pins.GPIO_PIN_D5,     // DB4
                                                        Pins.GPIO_PIN_D4,     // DB5
                                                        Pins.GPIO_PIN_D3,     // DB6
                                                        Pins.GPIO_PIN_D2);    // DB7


            _lcd = new Lcd(lcdProvider);


            _lcd.Begin(20, 2);
            
            Thread.Sleep(100);
            _lcd.Clear();
            _lcd.SetCursorPosition(0, 1);


            Thread.Sleep(100);
            _lcd.Write("Initing...");
            Thread.Sleep(100);
            _lcd.Clear();
            _lcd.SetCursorPosition(0, 1);
            _lcd.Write("Waiting...");


            Thread.Sleep(500);
            while (true)
            {
                _lcd.SetCursorPosition(0, 0);
                _lcd.Clear();
                _lcd.Write(_serial.IsOpen.ToString());
                Thread.Sleep(1000);
            }
            //Thread.Sleep(Timeout.Infinite);




        }


        private static void _serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {


            _lcd.Clear();
            _lcd.Write("Connected");
            // create a single byte array
            byte[] bytes = new byte[1];


            // as long as there is data waiting to be read
            while (_serial.BytesToRead > 0)
            {
                // read a single byte
                _serial.Read(bytes, 0, bytes.Length);
                // send the same byte back


                _serial.Write(bytes, 0, bytes.Length);


                string data = Convert.ToBase64String(bytes);
                _lcd.Write(data);


            }


        }
    }

and this is the code on the PC application that's running:

 

public partial class MainWindow : Window
    {
        private SerialPort serial;


        public MainWindow()
        {
            InitializeComponent();
            AssettoCorsa assettoCorsa = new AssettoCorsa();
            assettoCorsa.PhysicsUpdated += AssettoCorsa_PhysicsUpdated;




            serial = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
            serial.DataReceived += Serial_DataReceived;
            serial.Open();


            assettoCorsa.Start();
        }




        private void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            // wait a little for the buffer to fill
            System.Threading.Thread.Sleep(100);


            // create an array for the incoming bytes
            byte[] bytes = new byte[serial.BytesToRead];
            // read the bytes
            serial.Read(bytes, 0, bytes.Length);
            // convert the bytes into a string
            string line = System.Text.Encoding.UTF8.GetString(bytes);


            // write the received bytes, as a string, to the console
            System.Console.WriteLine("echo: " + line);
            System.Console.WriteLine();
        }


        private void AssettoCorsa_PhysicsUpdated(object sender, PhysicsEventArgs e)
        {
            Console.WriteLine(e.Physics.Gear + @"-------" + e.Physics.SpeedKmh);
            if (serial.IsOpen)
            {
                serial.WriteLine(e.Physics.SpeedKmh.ToString(CultureInfo.InvariantCulture));
            }
           
        }
    }


But when I send data, nothing happens on the Netduino. The ports are open though

 




#64347 No response from device

Posted by Nerdiator on 21 October 2015 - 09:36 AM in Netduino Mini

I'm trying to update my Netduino Mini to the latest firmware but I think the topic is quite outdated.

?The link on how to "Flash TinyBooterDecompressor.bin using SAM-BA v2.12+" does not work anymore, and when I do something with MFDeploy all I get is that my device is not responding. I can connect, but can't get my Device Capabilities, or deploy the tiny clr files.

 

?Is there an updated tutorial on how to upgrade?




#63817 A few questions about the Netduino 3 Wifi

Posted by Nerdiator on 07 August 2015 - 07:14 PM in Netduino 3

Hello, I recently bought the Netduino 3 Wifi and I have a few questions about it. This is my first Netduino device so please excuse me if my questions sound a bit noobish.
 
 
 
1. Is it possible to do P2P communication using Wifi? I'd like to send commands directly to it with my phone.

2. How do I make it connect to my Wifi network at home (WPA and AES). I tried using MFDeploy but for some reason it cannot get a correct IP address. I think there must be something wrong with my settings. I chose WPA and PEAP (Im not sure about that one).

3. Is there a site where I can find a bunch of samples? I looked a bit on the forum but I couldn't find any specifically for the 3 Wifi version.




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.