Example #1
0
 public SerialDataModel(SerialDataType serialDataType, byte comd, byte[] serialDatas)
 {
     this.serialDataType = serialDataType;
     this.comd           = comd;
     if (serialDatas == null)
     {
         serialDatas = new byte[0];
     }
     this.serialDatas = serialDatas;
 }
Example #2
0
 /// <summary>
 ///     Initializes the NavX singleton
 /// </summary>
 /// <param name="serialPortId">port that the NavX is plugged into</param>
 /// <param name="dataType">sets the type of data, processed or raw</param>
 /// <param name="updateRateHz">the update rate of the NavX - default 50Hz</param>
 internal static NavX InitializeNavX(SerialPort.Port serialPortId,
                                     SerialDataType dataType = SerialDataType.KProcessedData, byte updateRateHz = 50)
 {
     if (_lazy != null)
     {
         Report.Error(
             @"A NavX instance already been created, someone other than Config is trying to create an instance.");
     }
     _lazy = new Lazy <NavX>(() => new NavX(serialPortId, dataType, updateRateHz));
     return(Instance);
 }
Example #3
0
 internal SerialDataReceivedEventArgs(SerialDataType dataType)
 {
     this.dataType = dataType;
 }
Example #4
0
 private NavX(SerialPort.Port serialPortId, SerialDataType dataType = SerialDataType.KProcessedData,
              byte updateRateHz = 50) : base(serialPortId, dataType, updateRateHz)
 {
 }
Example #5
0
 /// <summary>
 /// Constructs the AHRS class using serial communication.
 /// </summary>
 /// <remarks>
 /// This constructor should be used if communicating via either TTL UART 
 /// or USB Serial Interface.
 /// <para></para>
 /// Note that the serial interfaces can communicate either processed data, or raw data,
 /// but not both simultaneously. If simultaneous processed and raw data are needed,
 /// use one of the register-based interfaces (SPI or I2C). The default is processed data.
 /// <para></para>
 ///  The update rate may be between 4 Hz and 60 Hz, representing the number
 /// of updates per second sent by the sensor. Note that increasing the update 
 /// rate may increase the CPU utilization.
 /// </remarks>
 /// <param name="serialPortId">The <see cref="SerialPort.Port">Serial Port</see> to use.</param>
 /// <param name="dataType">Either <see cref="SerialDataType.KProcessedData"/> (Default) or <see cref="SerialDataType.KRawData"/>.</param>
 /// <param name="updateRateHz">The Update Rate (Hz) [4..60] (Default 50)</param>
 public AHRS(SerialPort.Port serialPortId, SerialDataType dataType = SerialDataType.KProcessedData, byte updateRateHz = NavxDefaultUpdateRateHz)
 {
     CommonInit(updateRateHz);
     if (RobotBase.IsSimulation)
     {
         m_io = new SimulatorIO(updateRateHz, m_ioCompleteSink, m_boardCapabilities);
     }
     else
     {
         bool processedData = (dataType == SerialDataType.KProcessedData);
         m_io = new SerialIO(serialPortId, updateRateHz, processedData, m_ioCompleteSink, m_boardCapabilities);
     }
     m_ioThread.Start();
 }