G4lile0 / tinyGS

📡 Open Ground Station Network 🛰
GNU General Public License v3.0
925 stars 178 forks source link

Norbi payload decoding test #49

Closed f4goh closed 3 years ago

f4goh commented 3 years ago
/*
test decoding norbi payload frame in arduino
May be it will be use in the Fossa-GroundStation project
f4goh @
Location: [47.89,0.27] (https://www.google.es/maps/place/47.89,0.27/@47.89,0.27,7.5z)
Location: 55.14,0.384 (https://www.google.es/maps/place/55.14,0.384/@55.14,0.384,7.5z)
Distance: 806.2 km
Time: 22 Oct 2020 12:27:23.0Z
RSSI: -123 SNR: -6 Freq Err: 6419.382Hz
Data: 8effffffff0a0601c9071d00000000f10f00001d07febf010042524b204d57205645523a30325f31320000000000000e0000c80500000007180000d30a94007c0100000000200a0000000000eea4f90196df03002a674e27000000000000000000000000000014040c8f8f8f8f8f8f000f12b7089260025b370e0c000c00005a0bee173b0f12140f03601088207248
from 
https://www.qsl.net/k/k4kdr//files/norby-specs-translated-english.pdf
and
  https://doc.kaitai.io/lang_cpp_stl.html
   type  C++ type
  no type std::string
  u1 uint8_t
  u2 uint16_t
  u4 uint32_t
  u8 uint64_t
  s1 int8_t
  s2 int16_t
  s4 int32_t
  s8 int64_t
  str,0x strz std::string
*/
typedef struct
{
  uint8_t  length;
  uint32_t receiver_address;
  uint32_t transmitter_address;
  uint16_t transaction_number;
  uint16_t reserved;
  int16_t msg_type_id;
} strHeader;

typedef struct
{
  uint16_t frame_start_mark; //contents: [0xf1,0x0f]
  uint16_t frame_definition;
  uint16_t frame_number;
  uint32_t frame_generation_time;
  char brk_title[24];  //encoding: windows-1251
  uint8_t brk_number_active;
  uint32_t brk_restarts_count_active;
  uint8_t brk_current_mode_id;
  int8_t brk_transmitter_power_active;
  int8_t brk_temp_active;
  uint8_t brk_module_state_active[2];
  uint16_t brk_voltage_offset_amplifier_active;
  int8_t brk_last_received_packet_rssi_active;
  int8_t brk_last_received_packet_snr_active;
  uint16_t brk_archive_record_pointer;
  int8_t brk_last_received_packed_snr_inactive;
  uint8_t ms_module_state[2];
  uint8_t ms_payload_state[2];
  int8_t ms_temp;
  uint8_t ms_payload_power_state;
  int32_t sop_altitude_glonass;
  int32_t sop_latitude_glonass;
  int32_t sop_longitude_glonass;
  uint32_t sop_date_time_glonass;
  uint16_t sop_magnetic_induction_module;
  uint8_t sop_angular_velocity_vector[6];
  uint16_t sop_angle_priority1;
  uint16_t sop_angle_priority2;
  int8_t sop_median_temperature1;
  int8_t sop_median_temperature6;
  int8_t sop_board_temp;
  uint8_t sop_state[2];
  uint8_t sop_state_dsg[6];
  uint8_t sop_orientation_number;
  int8_t ses_median_panel_x_temp_positive;
  int8_t ses_median_panel_x_temp_negative;
  uint8_t ses_solar_panels_state[5];
  uint16_t ses_charge_level;
  uint8_t ses_battery_state[3];
  uint8_t ses_charging_keys_state[2];
  uint8_t ses_power_line_state;
  int16_t ses_total_charging_power;
  uint16_t ses_total_generated_power;
  uint16_t ses_total_power_load;
  int8_t ses_median_pmm_temp;
  int8_t ses_median_pam_temp;
  int8_t ses_median_pdm_temp;
  uint8_t ses_module_state[5];
  uint16_t crc16;
} strPayload;

typedef struct
{
  strHeader header;
  strPayload payload;
} strSeq;

uint8_t data[] = {0x8e, 0xff, 0xff, 0xff, 0xff, 0x0a, 0x06, 0x01, 0xc9, 0x07, 0x1d, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x0f, 0x00, 0x00, 0x1d, 0x07, 0xfe, 0xbf, 0x01, 0x00, 0x42, 0x52, 0x4b, 0x20, 0x4d, 0x57, 0x20, 0x56, 0x45, 0x52, 0x3a, 0x30, 0x32, 0x5f, 0x31, 0x32,
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0xc8, 0x05, 0x00, 0x00, 0x00, 0x07, 0x18, 0x00, 0x00, 0xd3, 0x0a, 0x94, 0x00, 0x7c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xee, 0xa4, 0xf9, 0x01, 0x96, 0xdf,
                  0x03, 0x00, 0x2a, 0x67, 0x4e, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x04, 0x0c, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x00, 0x0f, 0x12, 0xb7, 0x08, 0x92, 0x60, 0x02, 0x5b, 0x37, 0x0e, 0x0c,
                  0x00, 0x0c, 0x00, 0x00, 0x5a, 0x0b, 0xee, 0x17, 0x3b, 0x0f, 0x12, 0x14, 0x0f, 0x03, 0x60, 0x10, 0x88, 0x20, 0x72, 0x48
                 };

strSeq seq;

void setup() {
  Serial.begin(115200);
  Serial.println(sizeof(strSeq));  //check data and struct has same size
  Serial.println(sizeof(data));
  memcpy(&seq, data, sizeof(data)); //cpy data into struct
  Serial.println(seq.payload.frame_start_mark, HEX);    //print some values
  Serial.println(seq.payload.frame_number);
  Serial.println(seq.payload.brk_temp_active);
  Serial.println(seq.payload.brk_transmitter_power_active);
  Serial.println(seq.payload.brk_last_received_packet_rssi_active);
  Serial.println(seq.payload.ses_total_power_load);
  Serial.println(seq.payload.ses_median_pmm_temp);
  Serial.println(seq.payload.ses_median_pam_temp);
  Serial.println(seq.payload.ses_median_pdm_temp);

}

void loop() {

}
4m1g0 commented 3 years ago

Thanks!

The Norbi decoder was implemented on the Server. For reference you can check the implementation here: https://github.com/4m1g0/tinygs-decoders