Closed seh-dev closed 6 months ago
In order to apply a transformation, you need to provide it in the form of C (or Ada) code.
Given this grammar:
TC ::= SEQUENCE {
payload OCTET STRING (SIZE (1..65535))
}
You can write this ACN
model:
TC [] {
len INTEGER [encoding pos-int, size 16, mapping-function ccsds-length],
payload [size len]
}
And if you provide these 2 C functions:
asn1SccSint ccsds_length_encode(asn1SccSint val)
{
return val - 1;
}
asn1SccSint ccsds_length_decode(asn1SccSint val)
{
return val + 1;
}
The ASN.1 compiler will generate a call to these functions automatically.
We did consider in the past the inclusion of arithmetic functions but we soon realized that they could not easily cover a variety of cases, for which the value is transformed in more complex ways.
There is an example in the documentation for the MILBUS 1553 packets, where the transformation is the following: length determinants of size (1..32) arrays are encoded using 5 bits and the size 32 is encoded with value 0 (i.e. 0 means 32 elements). This is easy to write in C ( val == 32 ? 0 : val
) but as you see, even such a simple case cannot be addressed with only basic arithmetic.
I would like to be able to apply basic arithmetic operations to the values in size determinants for ACN encoding
As an example, the CCSDS Space Packet specification defines the packet data length field as the number of octets trailing the primary header, minus 1.
So I would like to define the data field as, e.g.:
Is something like this possible?