WindhoverLabs / xtce_generator

A tool to generate xtce files from a sqlite database.
4 stars 1 forks source link

Char Arrays in XTCE #43

Closed tstern-masten closed 2 years ago

tstern-masten commented 2 years ago

Hello,

I have a question regarding a character array field in my message and its representation in YAMCS.

I have a destination IP address in code defined by a 16 byte char array: char dest_IP[16]; which I would like to be represented in YAMCS as some sort of string.

However what I see in YAMCS is a 16 byte BaseType/int8_LE array that accepts the ASCII value of the individual characters. I have verified that it does work as intended if you do the conversion by hand, but this is obviously not ideal for an operator.

Snooping around my SQLite outputs I can see my "dest_IP" field in the tlm_cmd_merger output database maps to the 2nd symbol which is a char as intended; however, the output XTCE looks like the following:

<ArgumentList>
    <Argument name="Payload.dest_IP_0_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_1_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_2_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_3_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_4_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_5_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_6_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_7_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_8_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_9_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_10_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_11_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_12_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_13_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_14_" argumentTypeRef="BaseType/int8_LE"/>
    <Argument name="Payload.dest_IP_15_" argumentTypeRef="BaseType/int8_LE"/>
</ArgumentList>
<CommandContainer name="TO_OUTPUT_ENABLE_CC-container">
    <EntryList>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_0_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_1_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_2_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_3_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_4_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_5_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_6_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_7_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_8_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_9_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_10_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_11_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_12_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_13_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_14_"/>
        <ArgumentRefEntry argumentRef="Payload.dest_IP_15_"/>
    </EntryList>
</CommandContainer>

I am not sure if this is an example of where remapping would be needed or if I am missing some other option so any help here would be greatly appreciated.

Thank you, Tim

lorenzo-gomez-windhover commented 2 years ago

Indeed, this is an issue we came across in the past. This section in our documentation will help you out. Basically it is not a remapping it is an "override" of the type string for a particular field of a struct, like you would see in some examples in our documentation. Very much like enumerations. So you need to basically add this to your YAML file.

I should note that our tools generate XTCE strings as "null-terminated". Basically when yamcs is parsing a telemetry packet that contains a string, it will consume the entire string until it finds the null-terminator. I believe as per the XTCE standard there are ways to have a "max" size for a particular string, but since all of our strings are variable-sized, we decided to make null-termiated strings the default and only supported type of string. However, if you or your team has a need for some type max-size/fixed-size string, do let us know. If you want to dig deeper into XTCE-spec, then this is the spec we are using in our tools. It's a pretty good read.

Hope this makes sense. As always, any questions you may have don't hesitate to reach out.

lorenzo-gomez-windhover commented 2 years ago

To clarify; I know I used telemetry as an example, but just know the same applies to commands as well.

tstern-masten commented 2 years ago

Perfect! thank you so much.

I was able to reformat that database and get the desired result.