jinzai - Viewing Profile: Posts - Netduino Forums
   
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.

jinzai

Member Since 29 May 2015
Offline Last Active Mar 06 2016 09:55 AM
-----

Posts I've Made

In Topic: Windows on Devices? When?

25 February 2016 - 02:35 AM

I have (had, until I killed it) a Galileo. It is(was) a great board -- well beyond most other IoT offerings. It runs Yocto Linux, which -- is just fine for that, except that Linux is a bit of a bear -- it has little in the way of vendor supplied HAL and bringing it up can be frustrating.

 

I doubt that plopping even WindowsCE on there is going to improve that situation much. I am very satisfied with SecretLabs work on the Netduino, however -- there are still areas that elude me -- I2C, for example.

 

You are simply suffering from life on the bleeding edge and why would Microsoft invest vast resources to develop this when they use their users as beta testers and have done so for over 20 years, now? So, they are a bit bogged down, that is the same everywhere in this industry. I have issues with every single development system I use -- most of them turn out to be me in the end.

 

JoopC -- pardon my observation, but -- that is a very naïve opinion about C++ -- it is still one of the most powerful languages available. In fact, most more modern languages are actually written in C/C++. Even Unix could not be written without C. What are your specific objections to a language that gives the power (as well as the responsibility!) to the programmer?


In Topic: EventHandler vs specific thread

25 February 2016 - 02:18 AM

        private static void DataReceviedHandler(object sender,
                                                SerialDataReceivedEventArgs e)
        {
            try
            {
                SerialPort sp = (SerialPort)sender;
                int bytesToRead = sp.BytesToRead;

                for (int i = 0; i < bytesToRead; i++)
                {
                    byte[] theByte = new byte[1];

                    theByte[0] = (byte)sp.ReadByte();
                    if (theByte[0] == 0x0a)
                    {
                        String tempStr = BufferedString.ToString();
                        String[] NMEASentence = tempStr.Split(new char[]{','});

                        if (NMEASentence == null) { BufferedString = new StringBuilder(); break; }
                        switch (NMEASentence[0])
                        {
                            case "$GPVTG" :
                                GPVTG = tempStr.TrimEnd();
                                if (NMEASentence.Length > 8)
                                {
                                    GPS_NMEA_GPVTG.CourseTrue = Convert.ToDouble(NMEASentence[1]);
                                    GPS_NMEA_GPVTG.ReferenceTrue = Encoding.UTF8.GetBytes(NMEASentence[2])[0];
                                    if (NMEASentence[3] == "")
                                    {
                                        GPS_NMEA_GPVTG.CourseMagnetic = -0.0D;
                                    }
                                    else
                                    {
                                        GPS_NMEA_GPVTG.CourseMagnetic = Convert.ToDouble(NMEASentence[3]);
                                    }
                                    GPS_NMEA_GPVTG.ReferenceMagnetic = Encoding.UTF8.GetBytes(NMEASentence[4])[0];
                                    GPS_NMEA_GPVTG.Speed = Convert.ToDouble(NMEASentence[5]);
                                    GPS_NMEA_GPVTG.SpeedUnits = Encoding.UTF8.GetBytes(NMEASentence[6])[0];
                                    GPS_NMEA_GPVTG.Mode = (VTGMode)Convert.ToInt32(Encoding.UTF8.GetBytes(NMEASentence[7])[0].ToString());
                                    Debug.Print("Course (True) : " + GPS_NMEA_GPVTG.CourseTrue.ToString("N2") +
                                                " " + new String(Convert.ToChar(GPS_NMEA_GPVTG.ReferenceTrue), 1));
                                    Debug.Print("Course (Mag)  : " + GPS_NMEA_GPVTG.CourseMagnetic.ToString("N2") +
                                                " " + new String(Convert.ToChar(GPS_NMEA_GPVTG.ReferenceMagnetic), 1));
                                    Debug.Print("Speed : " + GPS_NMEA_GPVTG.Speed.ToString("N2") +
                                                " " + new String(Convert.ToChar(GPS_NMEA_GPVTG.SpeedUnits), 1));
                                    Debug.Print("Mode : " + GetVTGModeText(GPS_NMEA_GPVTG.Mode));
                                }
                                break;
                            case "$GPGGA":
                                GPGGA = tempStr.TrimEnd();
                                if (NMEASentence.Length > 12)
                                {
                                    GPS_NMEA_GPGGA.GPS_Time.hour = Convert.ToByte(NMEASentence[1].Substring(0, 2));
                                    GPS_NMEA_GPGGA.GPS_Time.minute = Convert.ToByte(NMEASentence[1].Substring(2, 2));
                                    GPS_NMEA_GPGGA.GPS_Time.second = Convert.ToByte(NMEASentence[1].Substring(4, 2));
                                    GPS_NMEA_GPGGA.LatitudeStr = NMEASentence[2];
                                    GPS_NMEA_GPGGA.IsLatitudeNorth = NMEASentence[3] == "N" ? true : false;
                                    GPS_NMEA_GPGGA.LongitudeStr = NMEASentence[4];
                                    GPS_NMEA_GPGGA.IsLongitudeWest = NMEASentence[5] == "W" ? true : false;
                                    GPS_NMEA_GPGGA.PositionFixIndicator = (PositionFix)Convert.ToInt32(NMEASentence[6]);
                                    GPS_NMEA_GPGGA.SatellitesUsed = Convert.ToByte(NMEASentence[7]);
                                    GPS_NMEA_GPGGA.HorizontalDilutionOfPrecision = Convert.ToDouble(NMEASentence[8]);
                                    GPS_NMEA_GPGGA.MSLAltitude = Convert.ToDouble(NMEASentence[9]);
                                    GPS_NMEA_GPGGA.MSLUnits = Encoding.UTF8.GetBytes(NMEASentence[10])[0];
                                    GPS_NMEA_GPGGA.GeoidSeparation = Convert.ToDouble(NMEASentence[11]);
                                    GPS_NMEA_GPGGA.GeoidSeparationUnits = Encoding.UTF8.GetBytes(NMEASentence[12])[0];
                                }
                                if (NMEASentence.Length > 13)
                                {
                                    //Debug.Print(NMEASentence[13]);
                                    //GPS_NMEA_GPGGA.AgeOfDifferentialCorrection = Convert.ToInt32(NMEASentence[13]);
                                    if (NMEASentence.Length >= 14)
                                    {
                                        //Debug.Print(NMEASentence[14]);
                                        //GPS_NMEA_GPGGA.DifferentialReferenceStationID = Convert.ToInt32(NMEASentence[14]);
                                    }
                                }
                                Debug.Print("GPS Time => " + GPS_NMEA_GPGGA.GPS_Time.MakeString());
                                //Debug.Print("Latitude : " + GPS_NMEA_GPGGA.Latitude().MakeString() +
                                //            (GPS_NMEA_GPGGA.IsLatitudeNorth ? "N" : "S"));
                                //Debug.Print("Longitude : " + GPS_NMEA_GPGGA.Longitude().MakeString() +
                                //            (GPS_NMEA_GPGGA.IsLongitudeWest ? "W" : "E"));
                                Debug.Print("Latitude : " + GPS_NMEA_GPGGA.LatitudeAsDecimal("N6") +
                                            (GPS_NMEA_GPGGA.IsLatitudeNorth ? "N" : "S"));
                                Debug.Print("Longitude : " + GPS_NMEA_GPGGA.LongitudeAsDecimal("N6") +
                                            (GPS_NMEA_GPGGA.IsLongitudeWest ? "W" : "E"));
                                Debug.Print("Position Fix Indicator : " + GetFixIndicatorText(GPS_NMEA_GPGGA.PositionFixIndicator));
                                Debug.Print("Satellites Used : " + GPS_NMEA_GPGGA.SatellitesUsed.ToString());
                                Debug.Print("Horizontal Dilution of Precision : " + GPS_NMEA_GPGGA.HorizontalDilutionOfPrecision.ToString("N1"));
                                Debug.Print("MSL Altitude : " + GPS_NMEA_GPGGA.MSLAltitude.ToString("N1") + " " +
                                            new String(Convert.ToChar(GPS_NMEA_GPGGA.MSLUnits), 1));
                                break;
                                //
                            case "$GPGSA":
                                GPGSA = tempStr.TrimEnd();
                                //Debug.Print(GPGSA);
                                break;
                            case "$GPRMC":
                                GPRMC = tempStr.TrimEnd();
                                if (NMEASentence.Length > 13)
                                {
                                    GPS_NMEA_GPRMC.GPSTime.hour = Convert.ToByte(NMEASentence[1].Substring(0, 2));
                                    GPS_NMEA_GPRMC.GPSTime.minute = Convert.ToByte(NMEASentence[1].Substring(2, 2));
                                    GPS_NMEA_GPRMC.GPSTime.second = Convert.ToByte(NMEASentence[1].Substring(4, 2));
                                    GPS_NMEA_GPRMC.Status = Encoding.UTF8.GetBytes(NMEASentence[2])[0];
                                    GPS_NMEA_GPRMC.LatitudeStr = NMEASentence[3];
                                    GPS_NMEA_GPRMC.NorS = Encoding.UTF8.GetBytes(NMEASentence[4])[0];
                                    GPS_NMEA_GPRMC.LatitudeStr = NMEASentence[5];
                                    GPS_NMEA_GPRMC.EorW = Encoding.UTF8.GetBytes(NMEASentence[6])[0];
                                    GPS_NMEA_GPRMC.SpeedOverGround = Convert.ToDouble(NMEASentence[7] != "" ? NMEASentence[7] : "0.0");
                                    GPS_NMEA_GPRMC.CourseOverGround = Convert.ToDouble(NMEASentence[8] != "" ? NMEASentence[8] : "0.0");
                                    GPS_NMEA_GPRMC.GPSDateStr = NMEASentence[9];
                                    Debug.Print("Speed Over Ground : " + GPS_NMEA_GPRMC.SpeedOverGround.ToString("N2") +
                                                " knots");
                                    Debug.Print("Course over ground : " + GPS_NMEA_GPRMC.CourseOverGround.ToString("N2"));
                                }
                                break;
                            default:
                                break;
                        }
                        BufferedString = new StringBuilder();
                    }
                    else
                    {
                        if (theByte[0] > 127)
                        {
                            Debug.Print("Value out of ASCII range. MSB set.");
                        }
                        else
                        {
                            try
                            {
                                BufferedString.Append(Encoding.UTF8.GetChars(theByte, 0, 1));
                            }
                            catch (Exception ex)
                            {
                                Debug.Print("Alpha Station Operations caught an exception\n" + ex.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print("Alpha Station operations caught an exception : \n" + ex.Message);
                Debug.Print(ex.StackTrace);
            }
        }

It doesn't so much create a separate thread as it places your event handler in the thread that handles the com port. It is a distinction with little difference, but...you do not need any of the normal "while(true)" type of polling, here. The event gets raised by the hardware, regardless of where the main thread of execution or any other threads are in terms of their independent execution.

 

Most serial devices use text as the transport encoding and usually they terminate a transmission with a line feed, or carriage return line feed pair. (Binary information is usually length-limited, or uses a particular character to determine end of transmission. EOT/ETX). The .NET SerialPort class is quite flexible with respect to serial comms.

 

So, just write it to take one character at a time and evaluate that. If you store them off in a buffer each time and evaluate them when necessary, it will work fine and last a long time. The StringBuilder class is your friend when the comms are ASCII style. (Actually, use UTF8 encodings).

 

This is a long snippet -- I am still writing it, but -- it uses a StringBuilder to hole the received characters and evaluates each character. I am not sure, but -- I don't think that Netduino 3 can use the line oriented capablilities of .NET SerialPort. I hope I am wrong about that, actually....


In Topic: Looking For A Netduino Techno Buddy

25 February 2016 - 01:47 AM

Greetings to you both. I actually began my career in hardware and switched to software during the era of DOS/16 bit Windows. I am quite familiar with .NET and low level programming of all sorts of devices, including a Netduino 3 that I am using alongside some other Arduino/Propeller systems

 

DiverBW -- The only bit of advice I would give you is simply to point out that most online tutorials involving breadboarding are geared toward the Arduino IDE, or perhaps Eclipse -- and as you no doubt already know -- .NET is not so linear and it can be a bear if you are not intimately familiar with threading, managed memory etc. So -- finding a breadboarding project that uses VS/.NETMF is not so easy, in my experience. Finding ones for Arduino -- is easy.

 

I am working currently with a Netduino 3 and my collection of Grove devices (You should definitely check those out, they will save you a lot of frustration in breadboarding!) and breadboards. I have some code for a GPS receiver written in .NET and in its own class -- if that sort of thing still interests you, I can provide some images and code samples to get you started at my website. (I have a domain and use my Netduino 3 as a subdomain by modifying my DNS info to point it to my router and then to the Netduino 3.)


In Topic: Discussion on the Parallax Forum regarding the boards used here

25 February 2016 - 01:17 AM

I think you might be conflating two very different types of microcontroller implementations, here. The Propeller is a microcontroller, not a microprocessor like the Netduino series is. As a microcontroller, the Propeller itself is far more powerful than most of Atmel's equivalents -- because it is designed to be.

 

Arduino is an open source microcontroller platform -- if you were to compare a Propeller with say, an Arduino Uno -- well the :Propeller is running at 80Mhz versus what -- 8, maybe 16? Plus, it has 8 times the cores. It is mature enough to have most of the important components of a system written already -- it is pretty amazing, actually. Plus, they still cost less than $10 in single quantities.

 

Netduino is a fine implementation of .NET -- that is not part of the basic Arduino platform but, rather an extension of it. I think that there is room to use both, actually -- and I am doing that now.

 

In my opinion -- right now -- the Intel Galileo and Edison are the best systems available to the hobbyist, but -- I have not used Raspberry Pi much -- although I do own one. The rest -- I have not messed with, but -- Linux based systems are probably where this will all settle down to, eventually.


In Topic: Serial LCD questions

25 February 2016 - 12:50 AM

Are you trying to use COM1? On the Netduino side...COM1 is actually the first UART (pins 0 and 1)-- the same USB port that you are using to program and debug. More advanced Arduino implementations, like the MegaADK and Netduino should use higher numbered ports. Like COM3 (pins 7 and 8) on the Netduino 3 -- which I just used to bring up an Adafruit Ultimate GPS Breakout board.

 

Once you get that all sussed, you are going to like serial comms in .NET, I think.

 

EDIT : I guess we aren't doing images anymore, but I just edited this to include the pin numbers I am referring to....


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.