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 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 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 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); } }