--
You received this message because you are subscribed to the Google Groups "cereal serialization library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cerealcpp+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cerealcpp/305fa6c9-6d01-43c7-9551-3e57fb59928bn%40googlegroups.com.
Hi Rand
Thanks for the quick response. For this set of tests, I copied the JSON file directly from the PC hard drive to the float uSD card, nothing was transmitted over the wire. The MissionDataJSONtest.crl file I attached to my help request is the file stored on the float uSD card and processed by the float code. I’ve inspected it several times and diff’ed it and it appears identical to the file generated and tested on the PC.
Given that it works on your laptop, my next step is to modify the PC code and float code so the struct being cerealized is just one scalar variable. If that works, I’ll add one variable at a time and eventually the arrays until something breaks.
And thanks for the note about _NVP. I’ll take a look at that.
Thanks again
Gene Massion
he/him/his
Ocean Engineer
P (831) 775-1922 F (831) 775-1620
Monterey Bay Aquarium Research Institute 7700 Sandholdt Road, Moss Landing CA 95039 Advancing marine science and engineering to understand our changing ocean. |
Hi Rand
Thanks for the quick response. For this set of tests, I copied the JSON file directly from the PC hard drive to the float uSD card, nothing was transmitted over the wire. The MissionDataJSONtest.crl file I attached to my help request is the file stored on the float uSD card and processed by the float code. I’ve inspected it several times and diff’ed it and it appears identical to the file generated and tested on the PC.
Given that it works on your laptop, my next step is to modify the PC code and float code so the struct being cerealized is just one scalar variable. If that works, I’ll add one variable at a time and eventually the arrays until something breaks.
And thanks for the note about _NVP. I’ll take a look at that.
Thanks again
Gene Massion
he/him/his
Ocean Engineer
P (831) 775-1922 F (831) 775-1620
<image001.gif> <image002.jpg>
I’ll check about the versions but the fact one .crl file works and it’s just the more complicated one that doesn’t suggests the libraries are compatible.
Cheers
Gene Massion
he/him/his
Ocean Engineer
P (831) 775-1922 F (831) 775-1620
Monterey Bay Aquarium Research Institute |
New clue: I think I mentioned I have 2 different structs that I decerealize. One is pretty simple, the other is just a little more complicated in that it has 2 std::vectors in it. Whichever stuct I decerealize first, works and the second one fails. Seems like I’m not disposing of something properly but I sure can’t find it.
I’ve pasted the code here. There’s a lot of it but 90% of it is just printing out the decerealized stucts. There’s actually just a few lines of cereal code. Here’s the function that gets called to decerealize the MissionDataStruct. The decerealization is done at the top with MissionData::readMissionData(). Everything below that just prints out the values in the struct.
InitPlatformState::Actions InitPlatformState::doReadMissionFile(const StateEvent event)
{
std::string comment;
char temp[64];
{
MissionData::readMissionData();
}
comment.clear();
comment.append("Park sample period (minutes): ");
snprintf(temp, sizeof(temp), "%6d", MissionData::getParkSamplePeriod_minutes());
comment.append(temp);
smLogEngLine(comment);
comment.clear();
comment.append("Max mission duration (hours): ");
snprintf(temp, sizeof(temp), "%8.4f", MissionData::getMaxMissionDuration_hours());
comment.append(temp);
smLogEngLine(comment);
comment.clear();
comment.append("Max num of profiles: ");
snprintf(temp, sizeof(temp), "%4d", MissionData::getMaxProfiles());
comment.append(temp);
smLogEngLine(comment);
comment.clear();
comment.append("Max Pressure (dBar): ");
snprintf(temp, sizeof(temp), "%7.1f", MissionData::getMaxPressure_dBar());
comment.append(temp);
smLogEngLine(comment);
comment.clear();
comment.append("Line Num \tpressure (dBar)\tplatform velocity (dBar/sec)\tparktime (hours)\tsampleList");
smLogEngLine(comment);
MissionData::DepthTable tableEntry;
std::string direction;
uint16_t numEntrys = MissionData::getSizeOfDescendTable();
for (int j = 0; j < 2; j++)
{
for (int i = 0; i < numEntrys; i++)
{
if (j == 0)
{
tableEntry = MissionData::getDescendTableEntry(i);
direction = "Descend ";
}
else
{
tableEntry = MissionData::getAscendTableEntry(i);
direction = "Ascend ";
}
comment.clear();
snprintf(temp,
sizeof(temp),
"%s%d\t%7.1f\t%6.3f\t%8.4f\t%#4X",
direction.c_str(),
i,
tableEntry.pressure_dBar,
tableEntry.platformVel_dBarPerSec,
tableEntry.parktime_hours,
tableEntry.sampleList);
comment.append(temp);
smLogEngLine(comment);
}
numEntrys = MissionData::getSizeOfAscendTable();
}
return initCTD1;
}
Here’s readMissionData().
void MissionData::readMissionData()
{
// TODO: what to do if file doesn't exist?
// should this fcn return a bool to indicate success?
std::stringstream missionFileStream;
missionFileStream = FileSys::readFile("/MissionDataJSON.crl");
cereal::JSONInputArchive iarchive(missionFileStream);
iarchive(cpfMissionData);
}
Here’s the function that gets called to decerealize the ConfigDataStruct. The decerealization is done at the top with ConfigData::readConfigData. Again, everything below ConfigData::readConfigData() is just printing out the struct.
InitPlatformState::Actions InitPlatformState::doReadConfigFile(const StateEvent event)
{
std::string comment;
char temp[8];
{
ConfigData::readConfigData();
}
comment.clear();
comment.append("Config file SN: ");
comment.append(ConfigData::getSN());
Logger::logEngLine(true, { stmchEngLogID, RTClock::getDateTimestamp().data(), stateLabel, comment });
comment.clear();
comment.append("Config file SW Ver Num: ");
comment.append(ConfigData::getSWVerNum());
Logger::logEngLine(true, { stmchEngLogID, RTClock::getDateTimestamp().data(), stateLabel, comment });
comment.clear();
comment.append("Config file Surf Ops Bel Pos (pctFull): ");
snprintf(temp, sizeof(temp), "%5.2f", ConfigData::getSurfaceOpsBelPos_pctFull());
comment.append(temp);
Logger::logEngLine(true, { stmchEngLogID, RTClock::getDateTimestamp().data(), stateLabel, comment });
comment.clear();
comment.append("Config file Recovery Bel Pos (pctFull): ");
snprintf(temp, sizeof(temp), "%5.2f", ConfigData::getRecoveryBelPos_pctFull());
comment.append(temp);
Logger::logEngLine(true, { stmchEngLogID, RTClock::getDateTimestamp().data(), stateLabel, comment });
return readMissionFile;
}
Here’s readConfigData()
void ConfigData::readConfigData()
{
// TODO: need a cpfAssert or recovery or default to safe configData file?
std::stringstream configFileStream;
configFileStream = FileSys::readFile("/ConfigDataJSON.crl");
cereal::JSONInputArchive iarchive(configFileStream);
iarchive(cpfConfigData);
std::cout << "ConfigData.SerialNum: " << getSN() << std::endl;
std::cout << "ConfigData.SWVerNum: " << getSWVerNum() << std::endl;
std::cout << "ConfigData.recoveryBelPos_ptcFull: " << getRecoveryBelPos_pctFull() << std::endl;
std::cout << "ConfigData.SurfaceOpsBelPos_pctFull: " << getSurfaceOpsBelPos_pctFull() << std::endl;
}
Thanks again for all your help.
Gene Massion
From: Gene Massion [mailto:mag...@mbari.org]
Sent: Monday, March 18, 2024 9:31 AM
To: Randolph Voorhies <rand.v...@gmail.com>
Cc: cereal serialization library <cere...@googlegroups.com>
Subject: RE: [cerealcpp] Help fixing cereal code
I’ll check about the versions but the fact one .crl file works and it’s just the more complicated one that doesn’t suggests the libraries are compatible.
Cheers
Gene Massion
he/him/his
Ocean Engineer
P (831) 775-1922 F (831) 775-1620
Monterey Bay Aquarium Research Institute |
7700 Sandholdt Road, Moss Landing CA 95039 Advancing marine science and engineering to understand our changing ocean. |
Sent: Monday, March 18, 2024 9:26 AM