Skip to content

Commit

Permalink
Add OTAG format file save/playback and simplify threading arrangements
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed May 31, 2024
1 parent f82a194 commit b9d5d26
Show file tree
Hide file tree
Showing 7 changed files with 498 additions and 120 deletions.
7 changes: 4 additions & 3 deletions Inc/cobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
extern "C" {
#endif

#define COBS_FRONTMATTER (10)
#define COBS_MAX_PACKET_LEN (4096)
#define COBS_FRONTMATTER (10)
#define COBS_MAX_PACKET_LEN (4096)
#define COBS_SYNC_CHAR (0)
#define COBS_OVERALL_MAX_PACKET_LEN (COBS_MAX_PACKET_LEN+COBS_FRONTMATTER)
#define COBS_MAX_ENC_PACKET_LEN (COBS_OVERALL_MAX_PACKET_LEN + COBS_OVERALL_MAX_PACKET_LEN / 254)
#define COBS_MAX_ENC_PACKET_LEN (COBS_OVERALL_MAX_PACKET_LEN + COBS_OVERALL_MAX_PACKET_LEN / 254)

enum COBSPumpState
{
Expand Down
68 changes: 68 additions & 0 deletions Inc/otag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* SPDX-License-Identifier: BSD-3-Clause */

/*
* OTAG Module
* ===========
*
*/

#ifndef _OTAG_
#define _OTAG_

#include <stdint.h>
#include <stdbool.h>
#include <sys/time.h>
#include "cobs.h"

#ifdef __cplusplus
extern "C" {
#endif

struct OTAGFrame
{
unsigned int len; /* Received length (after pre-processing) */
uint8_t tag; /* Tag (packet type) */
uint64_t tstamp; /* Timestamp for the packet */
uint8_t *d; /* ...pointer to the data itself */
};

struct OTAG
{
bool selfAllocated; /* Flag indicating that memory was allocated by the library */
struct COBS c;
struct OTAGFrame f;

/* Materials for callback */
void ( *cb )( struct OTAGFrame *p, void *param );
void *param;
};

#define OTAG_MAX_PACKET_LEN (COBS_MAX_PACKET_LEN)
#define OTAG_MAX_ENC_PACKET_LEN (COBS_MAX_ENC_PACKET_LEN)
#define OTAG_EOP_LEN (COBS_EOP_LEN)
#define OTAG_TS_RESOLUTION (1000000000L)

// ====================================================================================================

static inline uint64_t OTAGResolution( struct OTAG *t )
{
return OTAG_TS_RESOLUTION;
}

const uint8_t *OTAGgetFrameExtent( const uint8_t *inputEnc, int len );
bool OTAGisEOFRAME( const uint8_t *inputEnc );

void OTAGEncode( const uint8_t channel, const uint64_t tstamp, const uint8_t *inputMsg, int len, struct Frame *o );

/* Context free functions */
void OTAGPump( struct OTAG *t, uint8_t *incoming, int len,
void ( *packetRxed )( struct OTAGFrame *p, void *param ),
void *param );

void OTAGDelete( struct OTAG *t );
struct OTAG *OTAGInit( struct OTAG *t );
// ====================================================================================================
#ifdef __cplusplus
}
#endif
#endif
2 changes: 0 additions & 2 deletions Src/cobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <assert.h>
#include "cobs.h"

#define COBS_SYNC_CHAR (0)

const uint8_t cobs_eop[COBS_EOP_LEN] = { COBS_SYNC_CHAR };

// ====================================================================================================
Expand Down
Loading

0 comments on commit b9d5d26

Please sign in to comment.