public bool readRecordDataPage(int index) { ushort length = 256; if (parent.traqpaq.readRecordData(dataPage, length, (ushort)index)) { // extract the data from the dataPage byte array this.utc = BetterBitConverter.ToUInt32(dataPage, Constants.RECORD_DATA_UTC) / Constants.UTC_FACTOR; this.hdop = BetterBitConverter.ToUInt16(dataPage, Constants.RECORD_DATA_HDOP) / Constants.HDOP_FACTOR; this.GPSmode = dataPage[Constants.RECORD_DATA_MODE]; this.Satellites = dataPage[Constants.RECORD_DATA_SATELLITES]; // set the array of tRecordData structs this.RecordData = new tRecordData[Constants.RECORD_DATA_PER_PAGE]; for (int i = 0; i < Constants.RECORD_DATA_PER_PAGE; i++) { this.RecordData[i].Latitude = BetterBitConverter.ToInt32(dataPage, Constants.RECORD_DATA_LATITUDE + (i * Constants.RECORD_DATA_SIZE) + 16) / Constants.LATITUDE_LONGITUDE_COORD; this.RecordData[i].Longitude = BetterBitConverter.ToInt32(dataPage, Constants.RECORD_DATA_LONGITUDE + (i * Constants.RECORD_DATA_SIZE) + 16) / Constants.LATITUDE_LONGITUDE_COORD; this.RecordData[i].lapDetected = dataPage[Constants.RECORD_DATA_LAP_DETECTED + (i * Constants.RECORD_DATA_SIZE) + 16] == 0x01; // 0x00 means lap not detected. True if lap is detected this.RecordData[i].Altitude = BetterBitConverter.ToUInt16(dataPage, Constants.RECORD_DATA_ALTITUDE + (i * Constants.RECORD_DATA_SIZE) + 16) / Constants.ALTITUDE_FACTOR; this.RecordData[i].Speed = BetterBitConverter.ToUInt16(dataPage, Constants.RECORD_DATA_SPEED + (i * Constants.RECORD_DATA_SIZE) + 16) * Constants.SPEED_FACTOR; this.RecordData[i].Heading = BetterBitConverter.ToUInt16(dataPage, Constants.RECORD_DATA_COURSE + (i * Constants.RECORD_DATA_SIZE) + 16) / Constants.COURSE_FACTOR; } return(true); } else { return(false); } }
/// <summary> /// Request battery accumulated current draw /// </summary> /// <returns>True if request was successful, false otherwise</returns> public bool reqBatteryAccumCurrent() { if (traqpaq.sendCommand(USBcommand.USB_CMD_REQ_BATTERY_ACCUM, AccumCurrentRead)) { this.CurrentAccum = BetterBitConverter.ToUInt16(AccumCurrentRead, 0) * Constants.BATT_ACCUM_CURRENT_FACTOR; return(true); } else { return(false); } }
/// <summary> /// Request battery temperature /// </summary> /// <returns>True if request was successful, false otherwise</returns> public bool reqBatteryTemp() { if (traqpaq.sendCommand(USBcommand.USB_CMD_REQ_BATTERY_TEMPERATURE, TemperatureRead)) { this.Temperature = BetterBitConverter.ToUInt16(TemperatureRead, 0) * Constants.BATT_TEMP_FACTOR; // measured in °C return(true); } else { return(false); } }
/// <summary> /// Request battery instantaneous current draw /// </summary> /// <returns>True if request was successful, false otherwise</returns> public bool reqBatteryInstCurrent() { if (traqpaq.sendCommand(USBcommand.USB_CMD_REQ_BATTERY_INSTANT, InstCurrentRead)) { this.CurrentInst = BetterBitConverter.ToInt16(InstCurrentRead, 0) * Constants.BATT_INST_CURRENT_FACTOR; return(true); } else { return(false); } }
/// <summary> /// Request current battery voltage /// </summary> /// <returns>True if request was successful, false otherwise</returns> public bool reqBatteryVoltage() { if (traqpaq.sendCommand(USBcommand.USB_CMD_REQ_BATTERY_VOLTAGE, VoltageRead)) { // convert to Volts this.Voltage = BetterBitConverter.ToUInt16(VoltageRead, 0) * Constants.BATT_VOLTAGE_FACTOR; return(true); } else { return(false); } }
/// <summary> /// Read saved track data from the device /// </summary> /// <returns>True if successful, false if there was an error</returns> public bool readTrack() { byte[] byteIndex = BetterBitConverter.GetBytes(index); if (parent.traqpaq.sendCommand(USBcommand.USB_CMD_READ_SAVED_TRACKS, trackReadBuff, byteIndex[0], byteIndex[1])) { this.trackName = Encoding.ASCII.GetString(trackReadBuff, 0, Constants.TRACKLIST_NAME_STRLEN); this.Longitute = BetterBitConverter.ToInt32(trackReadBuff, Constants.TRACKLIST_LONGITUDE) / Constants.LATITUDE_LONGITUDE_COORD; this.Latitude = BetterBitConverter.ToInt32(trackReadBuff, Constants.TRACKLIST_LATITUDE) / Constants.LATITUDE_LONGITUDE_COORD; this.Heading = BetterBitConverter.ToUInt16(trackReadBuff, Constants.TRACKLIST_COURSE); this.isEmpty = (trackReadBuff[Constants.TRACKLIST_ISEMPTY] == 0xFF); // true if empty return(true); } else { return(false); } }
public bool readRecordTable(byte index) { if (parent.traqpaq.sendCommand(USBcommand.USB_CMD_READ_RECORDTABLE, readBuffer, (byte)Constants.RECORD_TABLE_SIZE, index)) { this.RecordEmpty = readBuffer[Constants.RECORD_EMPTY] == 0xFF; // true if empty this.TrackID = readBuffer[Constants.RECORD_TRACK_ID]; this.DateStamp = BetterBitConverter.ToUInt32(readBuffer, Constants.RECORD_DATESTAMP); this.StartAddress = BetterBitConverter.ToUInt32(readBuffer, Constants.RECORD_START_ADDRESS); this.EndAddress = BetterBitConverter.ToUInt32(readBuffer, Constants.RECORD_END_ADDRESS); this.StartPage = (StartAddress - Constants.ADDR_RECORD_DATA_START) / Constants.MEMORY_PAGE_SIZE; this.EndPage = (EndAddress - Constants.ADDR_RECORD_DATA_START) / Constants.MEMORY_PAGE_SIZE; return(true); } else { return(false); } }
/// <summary> /// Gets the GPS Serial Number /// </summary> /// <returns>The SN as an unsigned int, 0 if the command fails or if the SN is invalid</returns> public uint getGPS_SerialNo() { byte[] readBuff = new byte[5]; if (sendCommand(USBcommand.USB_DBG_GPS_INFO_SN, readBuff)) { // check if SN is valid if (readBuff[0] > 0) { return(BetterBitConverter.ToUInt32(readBuff, 1)); } else { return(0); } } else { return(0); } }
public AccelerometerSelfTest(byte[] readBuff) { SelfTest_X = BetterBitConverter.ToInt16(readBuff, 0); SelfTest_Y = BetterBitConverter.ToInt16(readBuff, 2); SelfTest_Z = BetterBitConverter.ToInt16(readBuff, 4); }
public AccelerometerNormalized(byte[] readBuff) { Normalized_X = BetterBitConverter.ToInt16(readBuff, 0); Normalized_Y = BetterBitConverter.ToInt16(readBuff, 2); Normalized_Z = BetterBitConverter.ToInt16(readBuff, 4); }
public AccelerometerFiltered(byte[] readBuff) { Filtered_X = BetterBitConverter.ToInt16(readBuff, 0); Filtered_Y = BetterBitConverter.ToInt16(readBuff, 2); Filtered_Z = BetterBitConverter.ToInt16(readBuff, 4); }
public Position(byte[] readBuff) { latitude = BetterBitConverter.ToInt32(readBuff, 0) / Constants.LATITUDE_LONGITUDE_COORD; longitude = BetterBitConverter.ToInt32(readBuff, 4) / Constants.LATITUDE_LONGITUDE_COORD; heading = BetterBitConverter.ToInt16(readBuff, 8) / Constants.COURSE_FACTOR; }