BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 127 forks source link

stacking/cascading processing of packets #374

Closed crumgary closed 7 years ago

crumgary commented 7 years ago

Is there a way I can conditionally stack or cascade the processing of packets?

For example, I have a subsystem (target_B) that generates CCSDS telemetry packets and then hands them off to another system (target_A) that puts another header on it. It's not always connected to target_A and I can get it's data when testing independent of target_B.

When it is connected to target_B I need to parse target_A telemetry as usual and if the ID_ITEM is a specified value, I would like to process it's payload as defined by the telemetry database in target_B.

I currently hacked a solution using ERB in the database and conditionally modifying the header of target_B. If it's going thought target_A, then I include the header that target_A adds and identify the ID_ITEM as well as the CCSDS header STREAM_ID/ID_TEM from target_B. This works, but it feels ugly and not portable. I would like to be able to easily move target_B around and get it's telemetry without knowledge of any headers that could be stripped off (like with or without target_A or some other target in the future)

Example telemetry from target_B

TELEMETRY ADC ADC_TEMPDATAPKT LITTLE_ENDIAN   
    <%= render "../../SYSTEM/_ceres_telem_packet_header.txt", locals: {STREAM_ID: 0x0A22} %>   
    APPEND_ARRAY_ITEM Temperatures 16 UINT 240

_ceres_telem_packet_header.txt file:

#conditionally include the bridge header
# this requires enviroment var: 'CERES_USE_BRIDGE' to be set as needed

<% if ENV["CERES_USE_BRIDGE"] %>
    <%= render "../../SYSTEM/_bridge_header.txt", locals: {MSG_ID: 0x5ff}%>
<% end %>
<%= render "../../SYSTEM/_cfs_ccsds_tlm_header.txt"%>

_cfs_ccsds_tlm_header.txt file:

APPEND_ID_ITEM    CCSDS_STREAMID    16 UINT <%= STREAM_ID %> "CCSDS Packet Identification"            BIG_ENDIAN
    FORMAT_STRING "0x%04X"
APPEND_ITEM       CCSDS_SEQUENCE    16 UINT "CCSDS Packet Sequence Control"                 BIG_ENDIAN
APPEND_ITEM       CCSDS_LENGTH      16 UINT "CCSDS Packet Length"                           BIG_ENDIAN
APPEND_ITEM       CCSDS_SECONDS     32 UINT "CCSDS Telemetry Secondary Header - Seconds"    LITTLE_ENDIAN
    FORMAT_STRING "0x%04X"
APPEND_ITEM       CCSDS_SUBSECONDS  16 UINT "CCSDS Telemetry Secondary Header - Subseconds" LITTLE_ENDIAN
    FORMAT_STRING "0x%04X

_bridge_header.txt file:

ITEM              SYNC             0   64 UINT "Sync Pattern" BIG_ENDIAN
  FORMAT_STRING "0x%08X"
ID_ITEM           MSG_ID            64  32 UINT <%= MSG_ID %> "Message ID" BIG_ENDIAN
FORMAT_STRING "0x%04X"
ITEM              LEN               96  32 UINT "Length (bytes)" BIG_ENDIAN

I see you have #356, could this help here?

ghost commented 7 years ago

If you don't care about the values in the bridge header, then it would be pretty easy to create a custom interface that just dropped that header if present. If you do care about the values, and they are only there sometimes, then there really isn't a good solution short of having multiple different COSMOS configurations based on how you are using your hardware (similar to what you are doing with the environment variable now). Some how you have to be able to tell the system what to expect.

jmthomas commented 7 years ago

Closing due to no further comments.