Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excplicit item fix #179

Merged
merged 3 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Issue #178 Explicit items with more elements then in definition shoul…
…d be put to list
  • Loading branch information
dsalantic committed Feb 12, 2021
commit 2bb1a929254da6cdae2089bde0aefd2bb06fa516
2 changes: 1 addition & 1 deletion HISTORY
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.1'
__version__ = '0.7.0'
56 changes: 41 additions & 15 deletions src/asterix/DataItemFormatExplicit.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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