ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
packet_utils.h File Reference
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdatomic.h>
#include "esp_log.h"
#include "esp_err.h"

Go to the source code of this file.

Data Structures

union  category_t
 
union  type_t
 
struct  header_t
 

Macros

#define PACKET_BYTES   (109)
 

Typedefs

typedef struct packet packet_t
 
typedef struct pkt_enc_pool pkt_enc_pool_t
 
typedef struct pkt_dec_pool pkt_dec_pool_t
 

Enumerations

enum  domain_t : uint8_t { DOMAIN_TM = 0x00 , DOMAIN_TC = 0x01 , DOMAIN_TEST = 0x02 }
 
enum  tm_category_t : uint8_t { TM_SDATA = 0x00 , TM_BDATA = 0x01 , TM_EVENT = 0x02 }
 
enum  tm_sdata_type_t : uint8_t { TM_SDATA_SENSORS = 0x00 , TM_SDATA_STATUS = 0x01 }
 
enum  tm_bdata_type_t : uint8_t { TM_BDATA_IMAGE = 0x00 , TM_BDATA_VIDEO = 0x01 }
 
enum  tm_event_type_t : uint8_t { TM_EVENT_LOG = 0x00 , TM_EVENT_ERROR = 0x01 , TM_EVENT_CRASH = 0x02 }
 
enum  tc_category_t : uint8_t { TC_CTRL = 0x00 , TC_REQ = 0x01 }
 
enum  tc_req_type_t : uint8_t {
  TC_REQ_SENSORS = 0x00 , TC_REQ_STATUS = 0x01 , TC_REQ_IMAGE = 0x02 , TC_REQ_VIDEO = 0x03 ,
  TC_REQ_LOG = 0x04 , TC_REQ_ERROR = 0x05 , TC_REQ_CRASH = 0x06
}
 
enum  tc_ctrl_type_t : uint8_t { TC_CTRL_REBOOT = 0x00 }
 
enum  test_category_t : uint8_t { TEST_WIMG = 0x00 , TEST_FRM = 0x01 }
 
enum  pkt_err_t { PKT_OK , PKT_FAIL , PKT_ERR_INVALID_ARG , PKT_ERR_SYNC }
 

Functions

packet_tpkt_create (void)
 
void pkt_destroy (packet_t *restrict pkt)
 
pkt_enc_pool_tpkt_enc_pool_create (void)
 
void pkt_enc_pool_destroy (pkt_enc_pool_t *restrict pool)
 
pkt_dec_pool_tpkt_dec_pool_create (void)
 
void pkt_dec_pool_destroy (pkt_dec_pool_t *restrict pool)
 
pkt_err_t pkt_encode (packet_t *restrict pkt, pkt_enc_pool_t *restrict pool)
 
pkt_err_t pkt_decode (const packet_t *restrict pkt, pkt_dec_pool_t *restrict pool)
 
pkt_err_t pkt_get_id (const packet_t *restrict pkt, uint16_t *id)
 
pkt_err_t pkt_get_header (const packet_t *restrict pkt, header_t *header)
 
pkt_err_t pkt_set_header (packet_t *restrict pkt, const header_t *restrict header)
 
pkt_err_t pkt_get_payload (const packet_t *restrict pkt, uint8_t *payload, size_t len)
 
pkt_err_t pkt_set_payload (packet_t *restrict pkt, const uint8_t *restrict payload, size_t len)
 

Data Structure Documentation

◆ category_t

union category_t
Data Fields
tc_category_t tc
test_category_t test
tm_category_t tm
uint8_t u8

◆ type_t

union type_t
Data Fields
tm_bdata_type_t bdata
tc_ctrl_type_t ctrl
tm_event_type_t event
tc_req_type_t req
tm_sdata_type_t sdata
uint8_t u8

◆ header_t

struct header_t
Data Fields
category_t category
domain_t domain
uint16_t index
uint16_t total
type_t type

Macro Definition Documentation

◆ PACKET_BYTES

#define PACKET_BYTES   (109)

Typedef Documentation

◆ packet_t

typedef struct packet packet_t

◆ pkt_dec_pool_t

typedef struct pkt_dec_pool pkt_dec_pool_t

◆ pkt_enc_pool_t

typedef struct pkt_enc_pool pkt_enc_pool_t

Enumeration Type Documentation

◆ domain_t

enum domain_t : uint8_t
Enumerator
DOMAIN_TM 

Telemetry domain (CubeSat to Ground).

DOMAIN_TC 

Telecommand domain (Ground to CubeSat).

DOMAIN_TEST 

Test domain (Ground to CubeSat, for tests only).

◆ pkt_err_t

enum pkt_err_t
Enumerator
PKT_OK 
PKT_FAIL 
PKT_ERR_INVALID_ARG 
PKT_ERR_SYNC 

◆ tc_category_t

enum tc_category_t : uint8_t
Enumerator
TC_CTRL 
TC_REQ 

◆ tc_ctrl_type_t

enum tc_ctrl_type_t : uint8_t
Enumerator
TC_CTRL_REBOOT 

◆ tc_req_type_t

enum tc_req_type_t : uint8_t
Enumerator
TC_REQ_SENSORS 
TC_REQ_STATUS 
TC_REQ_IMAGE 
TC_REQ_VIDEO 
TC_REQ_LOG 
TC_REQ_ERROR 
TC_REQ_CRASH 

◆ test_category_t

enum test_category_t : uint8_t
Enumerator
TEST_WIMG 

Write an image to OBC memory.

TEST_FRM 

Remove a file from OBC file system.

◆ tm_bdata_type_t

enum tm_bdata_type_t : uint8_t
Enumerator
TM_BDATA_IMAGE 
TM_BDATA_VIDEO 

◆ tm_category_t

enum tm_category_t : uint8_t
Enumerator
TM_SDATA 
TM_BDATA 
TM_EVENT 

◆ tm_event_type_t

enum tm_event_type_t : uint8_t
Enumerator
TM_EVENT_LOG 
TM_EVENT_ERROR 
TM_EVENT_CRASH 

◆ tm_sdata_type_t

enum tm_sdata_type_t : uint8_t
Enumerator
TM_SDATA_SENSORS 
TM_SDATA_STATUS 

Function Documentation

◆ pkt_create()

packet_t * pkt_create ( void )

◆ pkt_dec_pool_create()

pkt_dec_pool_t * pkt_dec_pool_create ( void )

◆ pkt_dec_pool_destroy()

void pkt_dec_pool_destroy ( pkt_dec_pool_t *restrict pool)

◆ pkt_decode()

pkt_err_t pkt_decode ( const packet_t *restrict pkt,
pkt_dec_pool_t *restrict pool )

◆ pkt_destroy()

void pkt_destroy ( packet_t *restrict pkt)

◆ pkt_enc_pool_create()

pkt_enc_pool_t * pkt_enc_pool_create ( void )

◆ pkt_enc_pool_destroy()

void pkt_enc_pool_destroy ( pkt_enc_pool_t *restrict pool)

◆ pkt_encode()

pkt_err_t pkt_encode ( packet_t *restrict pkt,
pkt_enc_pool_t *restrict pool )

◆ pkt_get_header()

pkt_err_t pkt_get_header ( const packet_t *restrict pkt,
header_t * header )

◆ pkt_get_id()

pkt_err_t pkt_get_id ( const packet_t *restrict pkt,
uint16_t * id )

◆ pkt_get_payload()

pkt_err_t pkt_get_payload ( const packet_t *restrict pkt,
uint8_t * payload,
size_t len )

◆ pkt_set_header()

pkt_err_t pkt_set_header ( packet_t *restrict pkt,
const header_t *restrict header )

◆ pkt_set_payload()

pkt_err_t pkt_set_payload ( packet_t *restrict pkt,
const uint8_t *restrict payload,
size_t len )