Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 37 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python C++ Debugger",
"type": "pythoncpp",
"request": "launch",
"pythonLaunchName": "Python: Current File",
"cppAttachName": "(gdb) Attach"
},
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/.venv/bin/python",
"processId": "",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
13 changes: 13 additions & 0 deletions asterix/test/test_cat62error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


import unittest
import asterix


data=b" \xd4P\xb4\xe5\x00\x00#\x00'\xff\xff\x00!\x000\x06\x06\x84\x00\x00 \x0f\x01y\xa0\x11\x94\x11\x94\x03 \x03 '\x10\x11\x9b\x1f\x13\x8f\x02\x04\xd3_\xe8\x00\x00\x95\x8e\xc7\x00\x0c\x0e\xcb\xff\xff\x00\x00A\x011\xa0\x00\x00\x0e\x03\x16P\xd6\x9d\x00\x02%c\xb2\x03\x03\xb3\x02t\xf4\x80\x91\x00\xff\x0f\x00\x00!\x01\x00\x00\xa5n\x01\x01\x00\xd4\x87\xb6\xe5\x00\x00\x17\x00\x1a\x00\x00\x00\x16\x00 \x04\x04\x84\x00\x00 \x0f\x01y\xa0\x03\x84\x03\x84\x01,\x01,'\x10\x10\x9b\x1f\x13\x8f\x02\x04\xd3_\xe8\x00\x00\x99\xd0\x00\x0f\xc7\x96\x00\x1e\x00\x04a\x01q\xa0\x00\x00\r\x9do\xe0:P\x00\x00:\xbd\x00C&t\x16\x03\xf1\x9c\x02\xa6t\x80\x91\x00\xff\x07\x00\x00!\x01\x00\x00\xad\t_-;\\\xd4\xb5\\\xe5\x00\x00\x13\x00\x15\x00\x00\x00\x12\x00\x1b\x03\x03\x84\x00\x00 \x0f\x01y\xa0:f:f\x08\xfc\x08\xfc'\x10\x11\x9b\x0f\x13\x8f\x02\x04\xd3_\xe8\x00\x00\x93\xa2\x91\x00\x0f\xd5\xaf\x00\x00\x00\x00\xa9\x03\x80\xc1\x00\xff\x15\x00\x00!\x01\x00\x00\xa4f\xd1\r\xc9\x0c\x07\x14q\xd4\n\x02\xe5\x00\x00\x11\x00\x15\x00\x00\x00\x12\x00\x17\x01\x01\xc4\x04\x07\x01\x067\x86($\xffy\xe0\x00\x00\x00\x00\x00\x17\x06\x08 \x00\r\xd2,\x00\x85\x00\x00\x00\x00\x00\xfa\x00\xfa\x00\xc8\x00\xc8'\x10\x02\x8f "


class TestCat62Error(unittest.TestCase):
def test_cat62error(self):
with self.assertRaises(RuntimeError):
asterix.parse(data)
17 changes: 14 additions & 3 deletions asterix_decoder.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: asterix-decoder
Version: 0.7.4
Metadata-Version: 2.4
Name: asterix_decoder
Version: 0.7.9
Summary: ASTERIX decoder in Python
Home-page: https://github.com/CroatiaControlLtd/asterix
Download-URL: https://github.com/CroatiaControlLtd/asterix
Expand All @@ -27,6 +27,17 @@ Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
License-File: LICENSE
License-File: COPYING
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: download-url
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: platform
Dynamic: summary

asterix
=======
Expand Down
12 changes: 7 additions & 5 deletions asterix_decoder.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ asterix/config/asterix_cat004_1_12.xml
asterix/config/asterix_cat008_1_0.xml
asterix/config/asterix_cat010_1_1.xml
asterix/config/asterix_cat011_1_2.xml
asterix/config/asterix_cat019_1_2.xml
asterix/config/asterix_cat020_1_7.xml
asterix/config/asterix_cat021_2_4.xml
asterix/config/asterix_cat023_1_2.xml
asterix/config/asterix_cat025_1_2.xml
asterix/config/asterix_cat019_1_3.xml
asterix/config/asterix_cat020_1_10.xml
asterix/config/asterix_cat021_2_6.xml
asterix/config/asterix_cat023_1_3.xml
asterix/config/asterix_cat025_1_5.xml
asterix/config/asterix_cat030_6_2.xml
asterix/config/asterix_cat031_6_2.xml
asterix/config/asterix_cat032_7_0.xml
Expand Down Expand Up @@ -73,7 +73,9 @@ asterix/sample_data/cat_062_065.pcap
asterix/test/__init__.py
asterix/test/parsing_error_1.xml
asterix/test/parsing_error_2.xml
asterix/test/test_cat62error.py
asterix/test/test_init.py
asterix/test/test_memory_leak.py
asterix/test/test_parse.py
asterix/test/valgrind-python.supp.txt
asterix_decoder.egg-info/PKG-INFO
Expand Down
1 change: 1 addition & 0 deletions src/asterix/InputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ InputParser::parsePacket(const unsigned char *m_pBuffer, unsigned int m_nBufferS
// parse Asterix data
if (dataLen <= 3 || dataLen > m_nDataLength) {
Tracer::Error("Wrong Asterix data length (%d)", dataLen);
this->raisedError = true;

if (dataLen <= 3) {
// otherwise finish
Expand Down
5 changes: 4 additions & 1 deletion src/asterix/InputParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ class InputParser {
bool filterOutItem(int cat, std::string item, const char *name);

bool isFiltered(int cat, std::string item, const char *name);
bool raisedErrorFlag() { return raisedError; }
void clearErrorFlag() { raisedError = false; }


private:
AsterixDefinition *m_pDefinition; // Asterix definitions

bool raisedError = false;
};

#endif /* INPUTPARSER_H_ */
5 changes: 5 additions & 0 deletions src/python/python_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ PyObject *python_parse(const unsigned char *pBuf, Py_ssize_t len, int verbose) {

if (inputParser) {
AsterixData *pData = inputParser->parsePacket(pBuf, len, nTimestamp);
if (inputParser->raisedErrorFlag()){
PyErr_SetString(PyExc_RuntimeError, "Error parsing packet");
inputParser->clearErrorFlag();
return NULL;
}
if (pData) { // convert to Python format
PyObject *lst = pData->getData(verbose);
delete pData;
Expand Down