libRBR  v1.2.3
RBR instrument communication API
RBRParser.h
Go to the documentation of this file.
1 
11 #ifndef LIBRBR_RBRPARSER_H
12 #define LIBRBR_RBRPARSER_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include <inttypes.h>
19 #include <stdbool.h>
20 
21 #include "RBRInstrument.h"
22 
24 #define RBRINSTRUMENT_EVENT_AUXILIARY_DATA_MAX 4
25 
26 struct RBRParser;
27 
42  const struct RBRParser *parser,
43  const struct RBRInstrumentSample *const sample);
44 
49 {
50  RBRINSTRUMENT_EVENT_UNKNOWN_OR_UNRECOGNIZED_EVENT = 0x00,
51  RBRINSTRUMENT_EVENT_TIME_SYNCHRONIZATION_MARKER = 0x01,
52  RBRINSTRUMENT_EVENT_DISABLE_COMMAND_RECEIVED = 0x02,
53  RBRINSTRUMENT_EVENT_RUN_TIME_ERROR_ENCOUNTERED = 0x03,
54  RBRINSTRUMENT_EVENT_CPU_RESET_DETECTED = 0x04,
55  RBRINSTRUMENT_EVENT_ONE_OR_MORE_PARAMETERS_RECOVERED_AFTER_RESET = 0x05,
56  RBRINSTRUMENT_EVENT_RESTART_FAILED_RTC_CALENDAR_CONTENTS_NOT_VALID = 0x06,
57  RBRINSTRUMENT_EVENT_RESTART_FAILED_LOGGER_STATUS_NOT_VALID = 0x07,
58  RBRINSTRUMENT_EVENT_RESTART_FAILED_PRIMARY_SCHEDULE_PARAMETERS_COULD_NOT_BE_RECOVERED = 0x08,
59  RBRINSTRUMENT_EVENT_UNABLE_TO_LOAD_ALARM_TIME_FOR_NEXT_SAMPLE = 0x09,
60  RBRINSTRUMENT_EVENT_SAMPLING_RESTARTED_AFTER_RESETTING_RTC = 0x0A,
61  RBRINSTRUMENT_EVENT_PARAMETERS_RECOVERED_SAMPLING_RESTARTED_AFTER_RESETTING_RTC = 0x0B,
62  RBRINSTRUMENT_EVENT_SAMPLING_STOPPED_END_TIME_REACHED = 0x0C,
63  RBRINSTRUMENT_EVENT_START_OF_A_RECORDED_BURST = 0x0D,
64  RBRINSTRUMENT_EVENT_START_OF_A_WAVE_BURST = 0x0E,
65  RBRINSTRUMENT_EVENT_RESERVED1 = 0x0F,
66  RBRINSTRUMENT_EVENT_STREAMING_NOW_OFF_FOR_BOTH_PORTS = 0x10,
67  RBRINSTRUMENT_EVENT_STREAMING_ON_FOR_USB_OFF_FOR_SERIAL = 0x11,
68  RBRINSTRUMENT_EVENT_STREAMING_OFF_FOR_USB_ON_FOR_SERIAL = 0x12,
69  RBRINSTRUMENT_EVENT_STREAMING_NOW_ON_FOR_BOTH_PORTS = 0x13,
70  RBRINSTRUMENT_EVENT_SAMPLING_STARTED_THRESHOLD_CONDITION_SATISFIED = 0x14,
71  RBRINSTRUMENT_EVENT_SAMPLING_PAUSED_THRESHOLD_CONDITION_NOT_MET = 0x15,
72  RBRINSTRUMENT_EVENT_POWER_SOURCE_SWITCHED_TO_INTERNAL_BATTERY = 0x16,
73  RBRINSTRUMENT_EVENT_POWER_SOURCE_SWITCHED_TO_EXTERNAL_BATTERY = 0x17,
74  RBRINSTRUMENT_EVENT_TWIST_ACTIVATION_STARTED_SAMPLING = 0x18,
75  RBRINSTRUMENT_EVENT_TWIST_ACTIVATION_PAUSED_SAMPLING = 0x19,
76  RBRINSTRUMENT_EVENT_WIFI_MODULE_DETECTED_AND_ACTIVATED = 0x1A,
77  RBRINSTRUMENT_EVENT_WIFI_MODULE_DEACTIVATED_REMOVED_OR_ACTIVITY_TIMEOUT = 0x1B,
78  RBRINSTRUMENT_EVENT_REGIMES_ENABLED_BUT_NOT_YET_IN_A_REGIME = 0x1C,
79  RBRINSTRUMENT_EVENT_ENTERED_REGIME_1 = 0x1D,
80  RBRINSTRUMENT_EVENT_ENTERED_REGIME_2 = 0x1E,
81  RBRINSTRUMENT_EVENT_ENTERED_REGIME_3 = 0x1F,
82  RBRINSTRUMENT_EVENT_START_OF_REGIME_BIN = 0x20,
83  RBRINSTRUMENT_EVENT_BEGIN_PROFILING_UP_CAST = 0x21,
84  RBRINSTRUMENT_EVENT_BEGIN_PROFILING_DOWN_CAST = 0x22,
85  RBRINSTRUMENT_EVENT_END_OF_PROFILING_CAST = 0x23,
86  RBRINSTRUMENT_EVENT_BATTERY_FAILED_SCHEDULE_FINISHED = 0x24,
87  RBRINSTRUMENT_EVENT_DIRECTIONAL_DEPENDENT_SAMPLING_BEGINNING_OF_FAST_SAMPLING_MODE = 0x25,
88  RBRINSTRUMENT_EVENT_DIRECTIONAL_DEPENDENT_SAMPLING_BEGINNING_OF_SLOW_SAMPLING_MODE = 0x26,
89  RBRINSTRUMENT_EVENT_ENERGY_USED_MARKER_INTERNAL_BATTERY = 0x27,
90  RBRINSTRUMENT_EVENT_ENERGY_USED_MARKER_EXTERNAL_POWER_SOURCE = 0x28
92 
101 
108 typedef struct RBRInstrumentEvent
109 {
126 
143  const struct RBRParser *parser,
144  const struct RBRInstrumentEvent *const event);
145 
153 typedef struct RBRParserCallbacks
154 {
161 
168 
175 
183 
190 {
198  int32_t channels;
200 
204 typedef struct RBRParserConfig
205 {
208 
210  union
211  {
214  } formatConfig;
216 
228 typedef struct RBRParser
229 {
232 
235 
237  void *userData;
238 
244 } RBRParser;
245 
288  const RBRParserCallbacks *callbacks,
289  const RBRParserConfig *config,
290  void *userData);
291 
302 
316 void RBRParser_getConfig(const RBRParser *parser, RBRParserConfig *config);
317 
328 void *RBRParser_getUserData(const RBRParser *parser);
329 
337 void RBRParser_setUserData(RBRParser *parser, void *userData);
338 
366  RBRInstrumentDataset dataset,
367  const void *const data,
368  int32_t *size);
369 
370 #ifdef __cplusplus
371 }
372 #endif
373 
374 #endif /* LIBRBR_RBRPARSER_H */
RBRParser::managedAllocation
bool managedAllocation
Whether the instance memory was dynamically allocated by the constructor.
Definition: RBRParser.h:243
RBRParserCallbacks::sample
RBRParserSampleCallback sample
Called when a sample has been parsed.
Definition: RBRParser.h:160
RBRInstrumentDataset
RBRInstrumentDataset
Possible instrument datasets.
Definition: RBRInstrumentMemory.h:35
RBRInstrumentEventType
RBRInstrumentEventType
Instrument event types.
Definition: RBRParser.h:48
RBRParser_parse
RBRInstrumentError RBRParser_parse(RBRParser *parser, RBRInstrumentDataset dataset, const void *const data, int32_t *size)
Parse a chunk of data.
RBRParser::userData
void * userData
Arbitrary user data; useful in callbacks.
Definition: RBRParser.h:237
RBRInstrumentDateTime
int64_t RBRInstrumentDateTime
Definition: RBRInstrument.h:181
RBRParserConfig::formatConfig
union RBRParserConfig::@2 formatConfig
Format-specific configuration.
RBRParserEventCallback
RBRInstrumentError(* RBRParserEventCallback)(const struct RBRParser *parser, const struct RBRInstrumentEvent *const event)
Callback to provide a parsed event to user code.
Definition: RBRParser.h:142
RBRInstrumentEvent::auxiliaryData
uint32_t auxiliaryData[RBRINSTRUMENT_EVENT_AUXILIARY_DATA_MAX]
Auxiliary data for the event.
Definition: RBRParser.h:124
RBRParser_destroy
RBRInstrumentError RBRParser_destroy(RBRParser *parser)
Release any resources held by the parser.
RBRParser::callbacks
RBRParserCallbacks callbacks
The set of callbacks to be used by the parser.
Definition: RBRParser.h:234
RBRInstrumentEvent
struct RBRInstrumentEvent RBRInstrumentEvent
An instrument event.
RBRParserConfig::format
RBRInstrumentMemoryFormat format
The format of memory being parsed.
Definition: RBRParser.h:207
RBRParserCallbacks::event
RBRParserEventCallback event
Called when an event has been parsed.
Definition: RBRParser.h:174
RBRParserEasyParseConfig
struct RBRParserEasyParseConfig RBRParserEasyParseConfig
EasyParse-specific parser configuration.
RBRParser_setUserData
void RBRParser_setUserData(RBRParser *parser, void *userData)
Change the arbitrary user data pointer.
RBRInstrumentError
RBRInstrumentError
Errors which can be returned from library functions.
Definition: RBRInstrument.h:200
RBRParserCallbacks::eventBuffer
RBRInstrumentEvent * eventBuffer
Where to put event data for consumption by the event callback.
Definition: RBRParser.h:181
RBRParserCallbacks
A set of callbacks from parser to user code.
Definition: RBRParser.h:153
RBRInstrumentSample
An instrument sample.
Definition: RBRInstrumentStreaming.h:492
RBRParserCallbacks
struct RBRParserCallbacks RBRParserCallbacks
A set of callbacks from parser to user code.
RBRInstrumentEvent
An instrument event.
Definition: RBRParser.h:108
RBRInstrumentEvent::type
RBRInstrumentEventType type
The type of the event.
Definition: RBRParser.h:111
RBRParserConfig
Configuration for a RBRParser.
Definition: RBRParser.h:204
RBRParserConfig
struct RBRParserConfig RBRParserConfig
Configuration for a RBRParser.
RBRInstrumentEvent::auxiliaryDataLength
int32_t auxiliaryDataLength
The number of populated entries in RBRInstrumentEvent.auxiliaryData.
Definition: RBRParser.h:122
RBRParserSampleCallback
RBRInstrumentError(* RBRParserSampleCallback)(const struct RBRParser *parser, const struct RBRInstrumentSample *const sample)
Callback to provide a parsed sample to user code.
Definition: RBRParser.h:41
RBRParserEasyParseConfig::channels
int32_t channels
The number of instrument channels in each sample.
Definition: RBRParser.h:198
RBRParser_init
RBRInstrumentError RBRParser_init(RBRParser **parser, const RBRParserCallbacks *callbacks, const RBRParserConfig *config, void *userData)
Initialize a dataset parser.
RBRParser::config
RBRParserConfig config
The parser configuration.
Definition: RBRParser.h:231
RBRINSTRUMENT_EVENT_AUXILIARY_DATA_MAX
#define RBRINSTRUMENT_EVENT_AUXILIARY_DATA_MAX
The maximum number of pieces of auxiliary data in an event.
Definition: RBRParser.h:24
RBRInstrumentEvent::timestamp
RBRInstrumentDateTime timestamp
The timestamp of the event.
Definition: RBRParser.h:113
RBRParser
Parser context object.
Definition: RBRParser.h:228
RBRParser_getUserData
void * RBRParser_getUserData(const RBRParser *parser)
Get the pointer to arbitrary user data.
RBRInstrument.h
Interface for simplified communication with RBR instruments.
RBRParser
struct RBRParser RBRParser
Parser context object.
RBRParserCallbacks::sampleBuffer
RBRInstrumentSample * sampleBuffer
Where to put sample data for consumption by the sample callback.
Definition: RBRParser.h:167
RBRParserEasyParseConfig
EasyParse-specific parser configuration.
Definition: RBRParser.h:189
RBRInstrumentEventType_name
const char * RBRInstrumentEventType_name(RBRInstrumentEventType type)
Get a human-readable string name for an event type type.
RBRParser_getConfig
void RBRParser_getConfig(const RBRParser *parser, RBRParserConfig *config)
Get the parser configuration.
RBRInstrumentMemoryFormat
RBRInstrumentMemoryFormat
Instrument memory formats.
Definition: RBRInstrumentMemory.h:206
RBRParserConfig::easyParse
struct RBRParserEasyParseConfig easyParse
EasyParse-specific parser configuration.
Definition: RBRParser.h:213