Hello, I am trying to generate a Fit File from an already existing CSV file from some vehicle data.
I am able to get most fields working such as engine speed, however, engine RPM refuses to display in Virb.
I've mostly followed the C++ example code, and I set a constant value for the RPM For the time being but nothing seems to work.
#include <cstdlib> #include <fstream> #include <iostream> #include "csv.h" #include "fit_date_time.hpp" #include "fit_encode.hpp" #include "fit_file_id_mesg.hpp" #include "fit_mesg_broadcaster.hpp" int EncodeActivityFile() { fit::Encode encode(fit::ProtocolVersion::V20); std::fstream file; file.open("ExampleActivity.fit", std::ios::in | std::ios::out | std::ios::binary | std::ios::trunc); if (!file.is_open()) { printf("Error opening file ExampleActivity.fit\n"); return -1; } fit::FileIdMesg fileIdMesg; // Every FIT file requires a File ID message fileIdMesg.SetType(FIT_FILE_ACTIVITY); fileIdMesg.SetManufacturer(FIT_MANUFACTURER_DYNASTREAM); fileIdMesg.SetProduct(1231); fileIdMesg.SetSerialNumber(12345); fit::DeveloperDataIdMesg devIdMesg; /* 16-byte identifier. */ for (FIT_UINT8 i = 0; i < 16; i++) { devIdMesg.SetApplicationId(i, i); } /* Developer index that maps to DataIdMsg. */ devIdMesg.SetDeveloperDataIndex(0); fit::FieldDescriptionMesg fieldDescMesg; /* Developer index source. */ fieldDescMesg.SetDeveloperDataIndex(0); fieldDescMesg.SetFieldDefinitionNumber(0); fieldDescMesg.SetFitBaseTypeId(FIT_BASE_TYPE_UINT16); fieldDescMesg.SetFieldName(0, L"motor_speed"); fieldDescMesg.SetUnits(0, L"rpm"); /* TEST = VIRB_22 */ io::CSVReader<3> in("test.csv"); in.read_header(io::ignore_extra_column, "Time", "Vehicle Speed (km/h) *OBD", "Engine Speed (RPM) *OBD"); double time; /* Engine data */ double speed; double rpm; std::list<fit::Mesg> records; while (in.read_row(time, speed, rpm)) { fit::ObdiiDataMesg rpmb; rpmb.SetLocalNum(8); rpmb.SetTimestamp(time); rpmb.SetSystemTime(0, time); rpmb.SetPid(12); // RPM rpmb.SetRawData(0, 0xFF); rpmb.SetRawData(1, 0x00); records.push_back(rpmb); } encode.Open(file); encode.Write(fileIdMesg); encode.Write(devIdMesg); //encode.Write(fieldDescMesg); for (auto record : records) { encode.Write(record); } if (!encode.Close()) { printf("Error closing encode.\n"); return -1; } file.close(); printf("Encoded FIT file ExampleActivity.fit.\n"); return 0; } int main() { printf("FIT Encode Example Application\n"); int returnValue = 0; returnValue += EncodeActivityFile(); return returnValue; }