Hades-D decoder [rookie question]

Hi all,

I’m writing for my first time a kaitai decoder -Hades-D telemetry-. I’m using the kaitai web ide, and my (maybe stupid) question is about the “object tree” section. With a sample data uploaded, I can only see the first byte elements (type and address) in this section, although I have described the rest of the elements for the frame. Does it mean that something is wrong?

Below my code:

meta:
  id: hadesd
  bit-endian: be
  endian: be

seq:
  - id: cubesat_frame
    type: cubesat_frame

types:
  cubesat_frame:
    seq:
      - id: first_header
        type: first_header
      - id: metadata
        type:
          switch-on: first_header.type
          cases:
            0b0001: power_frame
            0b0010: temp_frame
            0b0011: status_frame
            0b0100: powerstats_frame
            0b0101: tempstats_frame
  
  first_header:
    seq:
      - id: type
        type: b4
      - id: address
        type: b4
    
  power_frame:
    seq:
      - id: spa
        type: u1
      - id: spb
        type: u1
      - id: spc
        type: u1
      - id: spd
        type: u1
      - id: spe
        type: u1
      - id: spf
        type: u1
      - id: vbus1_raw
        type: b12
      - id: vbat1_raw
        type: b12
      - id: vcpu
        type: b12
      - id: vbus2_raw
        type: b16
      - id: vbus3_raw
        type: b12
      - id: vbat2
        type: b12
      - id: ibat
        type: b12
      - id: icpu
        type: b12
      - id:  ipl
        type: b12
      - id: powerdul1
        type: u1
      - id: powerdul455
        type: u1
      - id: vdac
        type: u1
      - id: checksum
        type: u2

In the object tree I can see a cubesatFrame item with a child firstHeader item, with type (1) and address (8) properties well decoded, but I’m missing all the power_frame items.

The sample data I’m using is the following: “18 3E 03 06 55 00 00 2B B6 6B 67 F9 A3 B3 3F 0F F6 01 F3 00 10 51 00 00”

Thanks all of you in advance.
Pedro Cabrera

1 Like

Hi all,

I’ve been checking the KSY file with “kaitai_struct_visualizer” tool and it worked, so could continue working on the decoder, visualizing all the frames … correcting some errors :slight_smile:

Issue closed !!

Thanks,
Pedro Cabrera

1 Like

You need to implement all custom types that are referenced before you can parse the data. Additionally it seems the checksum is not present. Try the following:

---
meta:
  id: hades_d
  title: HADES-D decoder struct
  endian: le

seq:
  - id: cubesat_frame
    type: cubesat_frame

types:
  cubesat_frame:
    seq:
      - id: first_header
        type: first_header
      - id: metadata
        type:
          switch-on: first_header.type
          cases:
            0x1: power_frame
#            0x2: temp_frame
#            0x3: status_frame
#            0x4: powerstats_frame
#            0x5: tempstats_frame
  
  first_header:
    seq:
      - id: type
        type: b4
      - id: address
        type: b4
    
  power_frame:
    seq:
      - id: spa
        type: u1
      - id: spb
        type: u1
      - id: spc
        type: u1
      - id: spd
        type: u1
      - id: spe
        type: u1
      - id: spf
        type: u1
      - id: vbus1_raw
        type: b12
      - id: vbat1_raw
        type: b12
      - id: vcpu
        type: b12
      - id: vbus2_raw
        type: b16
      - id: vbus3_raw
        type: b12
      - id: vbat2
        type: b12
      - id: ibat
        type: b12
      - id: icpu
        type: b12
      - id:  ipl
        type: b12
      - id: powerdul1
        type: u1
      - id: powerdul455
        type: u1
      - id: vdac
        type: u1
#      - id: checksum
#        type: u2

You can find some commented lines that should make the parser work. Don’t forget to generate the :field xyz: keywords using the contrib/generate_field_docstring.py. Review all the generated lines and remove everything containing binary data, as this is not JSON serialisable!

HTH and if you need help, just ping me.

3 Likes

Thank you very much for your help Patrick. I deliberately omitted the definition of the other frames to make the message clearer. Indeed I could check with ksv that the “checksum” item is not present, so I have removed it, good point !!! :wink:

I appreciate the note about the :field keywords, I was not taking it into account, I will check the code. I haven’t try the contrib/generate_field_docstring.py script yet, I imagine will be better to wait until I have the kaitai decoder code finished and, only then, run the script. I am following the instructions Adding_a_new_data_decoder

Best regards,
EA4HCF

3 Likes