Beispiel #1
0
        public Logger(string comPort, int baud, int maxBuffer = 512) {

            _maxBufferSize = maxBuffer;
            Debug.Print("Initializing serial port...");
            _openLogger = new SerialPort(comPort, baud, Parity.None, 8, StopBits.One);
            Debug.Print("Serial port initialized... opening serial port.");
            _openLogger.Open();
            Debug.Print("Serial port opened.");

            Debug.Print("Creating logger thread and adding to pool...");
            var unused = new byte[] {};
            _workItem = new WorkItem(LogWorker, ref unused, persistent: true, pauseable: false);
           
        }
        public SerialBNOUpdater(int sigFigs = 4) {
            _bnoSensor = new SerialBNO(SerialPorts.COM3,5000,5000,SerialBNO.Bno055OpMode.Operation_Mode_Ndof);
            _bnoData = new BNOData();


            _newData = new byte[_dataSize + _metaDataCount]; 
            _newData[0] = (byte)PacketType.StartByte; // start bit = 0xff
            _newData[1] = (byte)PacketType.BNODump;
            _newData[2] = (byte)((_dataSize >> 8) & 0xFF);
            _newData[3] = (byte)(_dataSize & 0xFF);

            _precision = (int)Math.Pow(10, sigFigs - 1);
            //_precision = 1;
            //for (int i = 0; i < sigFigs-1; i++)
            //{
            //    _precision *= 10;
            //}


            _workItem = new WorkItem(GyroUpdater, ref _newData, EventType.BNOUpdate, _bnoData, true, true);

            _bnoSensor.begin();
        }
 public void Execute(WorkItem workItem) {
     ThreadPool.QueueWorkItem(workItem);
 }