Exemplo n.º 1
0
        public static void parseData(mscl.InertialNode node)
        {
            //endless loop of reading in data
            while (true)
            {
                //get all of the next data packet from the node, with a timeout of 500 milliseconds
                mscl.MipDataPackets packets = node.getDataPackets(500);

                foreach (mscl.MipDataPacket packet in packets)
                {
                    //print out the data
                    Console.Write("Packet Received: ");

                    //iterate over all the data points in the packet
                    foreach (mscl.MipDataPoint dataPoint in packet.data())
                    {
                        Console.Write(dataPoint.channelName() + ":");

                        //print out the channel data
                        //Note: The as_string() function is being used here for simplicity.
                        //      Other methods (ie. as_float, as_uint16, as_Vector) are also available.
                        //      To determine the format that a dataPoint is stored in, use dataPoint.storedAs().
                        Console.Write(dataPoint.as_string() + " ");

                        //if the dataPoint is invalid
                        if (!dataPoint.valid())
                        {
                            //print out that it is invalid
                            Console.Write("[Invalid] ");
                        }
                    }
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                //create a Serial Connection with the specified COM Port, default baud rate of 921600
                mscl.Connection connection = mscl.Connection.Serial(COM_PORT);

                //create an InertialNode with the connection
                mscl.InertialNode node = new mscl.InertialNode(connection);

                //endless loop of reading in data
                while (true)
                {
                    //get all of the next data packet from the node, with a timeout of 500 milliseconds
                    mscl.MipDataPackets packets = node.getDataPackets(500);

                    foreach (mscl.MipDataPacket in packets)
                    {
                        //print out the data
                        Console.Write("Packet Received: ");

                        //iterate over all the data points in the packet
                        foreach (mscl.MipDataPoint dataPoint in packet.data())
                        {
                            //print out the channel data
                            Console.Write(dataPoint.as_string() + " "); //Just printing this out as a string. Other methods (ie. as_float, as_uint16, as_Vector) are also available.

                            //if the dataPoint is invalid
                            if (!dataPoint.valid())
                            {
                                //print out that it is invalid
                                Console.Write("[Invalid] ");
                            }
                        }
                        Console.WriteLine();
                    }
                }
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }