private void BmpUpdater() { var dataIndex = _metaDataCount; var time = BitConverter.GetBytes(Clock.Instance.ElapsedMilliseconds); _dataArray[dataIndex++] = time[0]; _dataArray[dataIndex++] = time[1]; _dataArray[dataIndex++] = time[2]; var pressure = _bmpSensor.GetPressure(); var temp = _bmpSensor.GetTemperature() * _precision; //precision because 4 sig figs go into decimals. var altitude = Bmp180.PressureToAltitude(Bmp180.SensorsPressureSealevelhpa, pressure, temp); //add pressure to data array (8 bytes) var pressureBytes = BitConverter.GetBytes(pressure); for (int i = 0; i < 8; i++) { _dataArray[dataIndex++] = pressureBytes[i]; } //add temp data (needs sign) to data (3 bytes) _dataArray[dataIndex++] = (temp < 0 ? (byte)1 : (byte)0); temp = (float)Math.Abs(temp); _dataArray[dataIndex++] = (byte)(((short)temp >> 8) & 0xFF); _dataArray[dataIndex++] = (byte)((short)temp & 0xFF); //add altitude data (can be unsigned, less than 65536) (2 bytes) altitude = (ushort)altitude; _dataArray[dataIndex++] = (byte)(((short)altitude >> 8) & 0xFF); _dataArray[dataIndex] = (byte)((short)altitude & 0xFF); Array.Copy(_dataArray, _workItem.PacketData, _dataArray.Length); Thread.Sleep(_delay); }