MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / ReadEverythingButData

Method ReadEverythingButData

lib/mdflib/mdflib/src/hd4block.cpp:210–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210void Hd4Block::ReadEverythingButData(std::streambuf& buffer) {
211 // We assume that ReadMeasurementInfo have been called earlier
212 for (auto& dg4 : dg_list_) {
213 if (!dg4) {
214 continue;
215 }
216 for (auto& cg4 : dg4->Cg4()) {
217 if (!cg4) {
218 continue;
219 }
220 cg4->ReadCnList(buffer);
221 cg4->ReadSrList(buffer);
222
223 // Update the VLSD record id reference on all channels
224 // and fix the MSLD channel as well
225 // Update the storage type for the CG block.
226 MdfStorageType storage_type = MdfStorageType::FixedLengthStorage;
227 uint64_t max_length = 8;
228 const auto channel_list = cg4->Channels();
229 for (auto *channel : channel_list) {
230 const auto *cn4 = dynamic_cast<const Cn4Block *>(channel);
231 if (cn4 == nullptr || cn4->DataLink() == 0) {
232 // Nothing to more of interest
233 continue;
234 }
235 // Search for the block within the DG block
236 const auto *block = Find(cn4->DataLink());
237 if (block != nullptr && block->BlockType() == "CG"
238 && cn4->Type() == ChannelType::VariableLength) {
239 // VLSD CG Storage
240 const auto *ref_cg = dynamic_cast<const Cg4Block *>(block);
241 cn4->VlsdRecordId(ref_cg == nullptr ? 0 : ref_cg->RecordId());
242 if (cn4->VlsdRecordId() > 0) {
243 storage_type = MdfStorageType::VlsdStorage;
244 max_length = 8;
245 }
246 } else if (block != nullptr && block->BlockType() == "CN") {
247 // Point to the length of byte array channel
248 if (const auto *mlsd_channel = dynamic_cast<const Cn4Block *>(block);
249 mlsd_channel != nullptr) {
250 // Check if the MLSD channel is valid. It must be of data type 0..3
251 // and number of data bytes > 0.
252 bool mlsd_valid = mlsd_channel->DataBytes() > 0;
253 switch (mlsd_channel->DataType()) {
254 case ChannelDataType::UnsignedIntegerLe:
255 case ChannelDataType::UnsignedIntegerBe:
256 case ChannelDataType::SignedIntegerLe:
257 case ChannelDataType::SignedIntegerBe:
258 break;
259
260 default:
261 mlsd_valid = false;
262 break;
263 }
264 if (!mlsd_valid) {
265
266 // Try to recover with data length channel
267 if (const auto* data_length_channel = cg4->GetChannel(".DataLength");

Callers

nothing calls this directly

Calls 15

DataLinkMethod · 0.80
VlsdRecordIdMethod · 0.80
MlsdChannelMethod · 0.80
ReadCnListMethod · 0.45
ReadSrListMethod · 0.45
ChannelsMethod · 0.45
BlockTypeMethod · 0.45
TypeMethod · 0.45
RecordIdMethod · 0.45
DataBytesMethod · 0.45
DataTypeMethod · 0.45
GetChannelMethod · 0.45

Tested by

no test coverage detected