Skip to content

Commit

Permalink
Merge pull request #12 from tanagraspace/issue_9_nmf_attribute_tag_wo…
Browse files Browse the repository at this point in the history
…rkaround

Issue #9 implement nmf attribute tag issue workaround
  • Loading branch information
georgeslabreche authored Aug 31, 2021
2 parents 928a6b3 + 6ebb971 commit e0557d6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions malattributes/include/mal_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,33 @@
extern "C" {
#endif

// See comments in mal_attributes.h for a description of what this is all about
#ifndef MAL_ATTRIBUTES_NMF_TAG_HOTFIX
#define MAL_ATTRIBUTES_NMF_TAG_HOTFIX 0
#endif

#if MAL_ATTRIBUTES_NMF_TAG_HOTFIX

#define MAL_BLOB_ATTRIBUTE_TAG 1
#define MAL_BOOLEAN_ATTRIBUTE_TAG 2
#define MAL_DURATION_ATTRIBUTE_TAG 3
#define MAL_FLOAT_ATTRIBUTE_TAG 4
#define MAL_DOUBLE_ATTRIBUTE_TAG 5
#define MAL_IDENTIFIER_ATTRIBUTE_TAG 6
#define MAL_OCTET_ATTRIBUTE_TAG 7
#define MAL_UOCTET_ATTRIBUTE_TAG 8
#define MAL_SHORT_ATTRIBUTE_TAG 9
#define MAL_USHORT_ATTRIBUTE_TAG 10
#define MAL_INTEGER_ATTRIBUTE_TAG 11
#define MAL_UINTEGER_ATTRIBUTE_TAG 12
#define MAL_LONG_ATTRIBUTE_TAG 13
#define MAL_ULONG_ATTRIBUTE_TAG 14
#define MAL_STRING_ATTRIBUTE_TAG 15
#define MAL_TIME_ATTRIBUTE_TAG 16
#define MAL_FINETIME_ATTRIBUTE_TAG 17
#define MAL_URI_ATTRIBUTE_TAG 18

#else

#define MAL_BLOB_ATTRIBUTE_TAG 0
#define MAL_BOOLEAN_ATTRIBUTE_TAG 1
Expand All @@ -49,6 +76,8 @@ extern "C" {
#define MAL_FINETIME_ATTRIBUTE_TAG 16
#define MAL_URI_ATTRIBUTE_TAG 17

#endif

union mal_attribute_t {
mal_blob_t *blob_value;
mal_boolean_t boolean_value;
Expand Down
10 changes: 10 additions & 0 deletions malattributes/include/malattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ typedef double mal_duration_t;
#define MAL_FINETIME_LIST_SHORT_FORM 0x1000001FFFFEFL
#define MAL_URI_LIST_SHORT_FORM 0x1000001FFFFEEL

// There's a difference between attribute short form values and tag values that seems to be mixed up in the NanoSat MO Framework (NMF).
// Some responses to a request interaction includes the attribute types' short form values which are then decoded as if they were tag values.
// The decoding in question happens in the malbinary project's malbinary_decoder_decode_attribute function.
// It could be that NMF is MAL response messages includes the attribute short form values instead of the tag values.
// As a workaround, defining this macro name will increment all tag values by one thus decoding them as short form values instead of tags.
//
// See section 5.2.1. of document CCSDS 524.2-R-1 or the GitHub Issue discussed here: https://github.com/CNES/ccsdsmo-malc/issues/56
// This is a workaround and by no means a permanent fix.
#define MAL_ATTRIBUTES_NMF_TAG_HOTFIX 1

// Public API classes
#include "mal_blob.h"
#include "mal_string.h"
Expand Down

0 comments on commit e0557d6

Please sign in to comment.