nasa / CCDD

CFS Command and Data Dictionary Tool (CCDDT)
81 stars 31 forks source link

Table import failed to complete while importing ccsds.h #90

Closed NijaShi closed 3 years ago

NijaShi commented 3 years ago

I was trying to import ccsds.h using the CCDD GUI application, but the process failed with the following error and exception:

Parsing error; cause 'Macro name 'CFE_MAKE_BIG16(n)' invalid'

Macro values or formulae for a variable's array size or bit length are converted to CCDD macros. However, the value of these macros is set to "2" - the user may edit the CSV file to update the macro values (or edit them in CCDD after importing). Note that the default macro value can lead to import errors if a macro formula used as an array size evaluates to less than 2 (array size must be >= 2). java.lang.ArrayIndexOutOfBoundsException: 1 at CCDD.CcddFileIOHandler.processCSVConversionFile(CcddFileIOHandler.java:3926) at CCDD.CcddFileIOHandler.prepareJSONOrCSVImport(CcddFileIOHandler.java:320) at CCDD.CcddFileIOHandler$3.execute(CcddFileIOHandler.java:1417) at CCDD.CcddBackgroundCommand$1.doInBackground(CcddBackgroundCommand.java:148) at CCDD.CcddBackgroundCommand$1.doInBackground(CcddBackgroundCommand.java:1) at javax.swing.SwingWorker$1.call(SwingWorker.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at javax.swing.SwingWorker.run(SwingWorker.java:334) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

Here's where/how the macro is defined: / Macro to convert 16/32 bit types from platform "endianness" to Big Endian /

ifdef SOFTWARE_BIG_BIT_ORDER

define CFE_MAKE_BIG16(n) (n)

define CFE_MAKE_BIG32(n) (n)

else

define CFE_MAKE_BIG16(n) ( (((n) << 8) & 0xFF00) | (((n) >> 8) & 0x00FF) )

define CFE_MAKE_BIG32(n) ( (((n) << 24) & 0xFF000000) | (((n) << 8) & 0x00FF0000) | (((n) >> 8) & 0x0000FF00) | (((n) >> 24) & 0x000000FF) )

endif

I'm using CCDD version 2.0.26 and ccsds.h from cFS Bootes RC2

NijaShi commented 3 years ago

I was able to successfully import the csv version of ccsds.h by converting the header file using c_struct_to_csv_convert.jar. However, the csv file does not have CFE_MAKE_BIG16 defined in it.

bawillisJSC commented 3 years ago

About to release an update to CCDD v2 that will allow you to import the file you provided.

bawillisJSC commented 3 years ago

On further inspection I have come across an issue. Although I can code CCDD to allow formulas for Macros that does not take care of the issue. Currently you have 2 defines each for 'CFE_MAKE_BIG16(n)' and 'CFE_MAKE_BIG32(n)'. I understand that the correct one is selected using the preprocessor commands, but CCDD does not allow you to store two macros with the same name. CCDD is also really only interested in macros represented by constants and these 'CFE_MAKE_X' macros are not really the type of data normally stored in a database as they are only used for byteswapping. One solution to this issue would be for you to include this text in one of your scripts that auto-generates your files meaning it will not be stored in CCDD at all. I am going to release an update either today or tomorrow that will allow you to import this file without error, but it will just skip over the 'CFE_MAKE_X' macros so that it does not stop the import entirely.