Skip to content

Commit

Permalink
Issue #178 Explicit items with more elements then in definition shoul…
Browse files Browse the repository at this point in the history
…d be put to list
  • Loading branch information
dsalantic committed Feb 12, 2021
1 parent ff719c4 commit 2bb1a92
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion HISTORY
Expand Up @@ -239,7 +239,7 @@ Issue #169 Problem decoding BDS 4,5 reserved bits
Issue #171 Hexdata presentation is not correct for multiple records in block
RE item added to CAT010

Not versioned yet
2.8.0 (python_v0.7.0)
Issue #175 Cat021 Ed2.4 SelH is not reasonable
Issue #174 Warning: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated
Issue #122 glibc version 2.1 behaves diffrently than glibc 2.0.6
Expand Down
2 changes: 1 addition & 1 deletion asterix/version.py
@@ -1 +1 @@
__version__ = '0.6.1'
__version__ = '0.7.0'
56 changes: 41 additions & 15 deletions src/asterix/DataItemFormatExplicit.cpp
Expand Up @@ -206,24 +206,50 @@ fulliautomatix_data* DataItemFormatExplicit::getData(unsigned char* pData, long,

PyObject* DataItemFormatExplicit::getObject(unsigned char* pData, long nLength, int verbose)
{
PyObject* p = PyDict_New();
insertToDict(p, pData, nLength, verbose);
return p;
std::list<DataItemFormat *>::iterator it;
int bodyLength = 0;

pData++; // skip explicit length byte (it is already in nLength)

// calculate the size of all sub items
for (it = m_lSubItems.begin(); it != m_lSubItems.end(); it++) {
DataItemFormat *di = (DataItemFormat *) (*it);
bodyLength += di->getLength(pData + bodyLength); // calculate length of body
}

int nFullLength = nLength - 1; // calculate full length

// full length must be multiple of body length
if (bodyLength == 0 || nFullLength % bodyLength != 0) {
//TODO Tracer::Error("Wrong data length in Explicit. Needed=%d and there is %d bytes.", bodyLength, nFullLength);
return NULL;
}

if (nFullLength == bodyLength) {
PyObject* p = PyDict_New();
DataItemFormat *di = m_lSubItems.size() ? (DataItemFormatFixed*)m_lSubItems.front() : NULL;
if (di != NULL) {
di->insertToDict(p, pData, bodyLength, verbose);
}
return p;
}
else {
PyObject* p = PyList_New(0);
for (int i = 0; i < nFullLength; i += bodyLength) {
for (it = m_lSubItems.begin(); it != m_lSubItems.end(); it++) {
DataItemFormat *di = (DataItemFormat *) (*it);
PyObject* p1 = di->getObject(pData, bodyLength, verbose);
PyList_Append(p, p1);
Py_DECREF(p1);
pData += bodyLength;
}
}
return p;
}
}

void DataItemFormatExplicit::insertToDict(PyObject* p, unsigned char* pData, long nLength, int verbose)
{
DataItemFormatFixed* pFixed = m_lSubItems.size() ? (DataItemFormatFixed*)m_lSubItems.front() : NULL;
if (pFixed == NULL)
{
//TODO Tracer::Error("Wrong format of explicit item");
return;
}

int fixedLength = pFixed->getLength(pData);
//unsigned char nFullLength = *pData;
pData++;

pFixed->insertToDict(p, pData, fixedLength, verbose);
// Not supported
}
#endif
4 changes: 2 additions & 2 deletions src/main/version.h
Expand Up @@ -26,7 +26,7 @@
#ifndef VERSION_H
#define VERSION_H

#define _VERSION 2.7.1
#define _VERSION_STR "2.7.1"
#define _VERSION 2.8.0
#define _VERSION_STR "2.8.0"

#endif

0 comments on commit 2bb1a92

Please sign in to comment.