 |
libRBR
v1.2.3
RBR instrument communication API
|
Go to the documentation of this file.
16 #ifndef LIBRBR_RBRINSTRUMENT_H
17 #define LIBRBR_RBRINSTRUMENT_H
62 #ifndef RBRINSTRUMENT_COMMAND_BUFFER_MAX
63 #define RBRINSTRUMENT_COMMAND_BUFFER_MAX 120
78 #ifndef RBRINSTRUMENT_RESPONSE_BUFFER_MAX
79 #define RBRINSTRUMENT_RESPONSE_BUFFER_MAX 1024
92 #ifndef RBRINSTRUMENT_CHANNEL_MAX
93 #define RBRINSTRUMENT_CHANNEL_MAX 32
97 #define xstr(s) str(s)
101 #define RBRINSTRUMENT_CHANNEL_MAX_LEN sizeof(xstr(RBRINSTRUMENT_CHANNEL_MAX))
109 #define RBRINSTRUMENT_CHANNEL_NAME_MAX 31
116 #define RBRINSTRUMENT_CHANNEL_TYPE_MAX 11
123 #define RBRINSTRUMENT_CHANNEL_UNIT_MAX 7
131 #define RBRINSTRUMENT_CHANNEL_LABEL_MAX 31
139 #define RBRINSTRUMENT_DATETIME_MIN 946684800000LL
147 #define RBRINSTRUMENT_DATETIME_MAX 4102444799000LL
154 #define RBRINSTRUMENT_ID_MODEL_MAX 14
161 #define RBRINSTRUMENT_ID_VERSION_MAX 7
168 #define RBRINSTRUMENT_ID_MODE_MAX 10
444 const void *
const data,
RBRInstrumentError(* RBRInstrumentSleepCallback)(const struct RBRInstrument *instrument, RBRInstrumentDateTime time)
Callback to suspend instrument activity for a fixed amount of time.
Definition: RBRInstrument.h:365
@ RBRINSTRUMENT_MISSING_CALLBACK
Definition: RBRInstrument.h:209
struct RBRInstrument RBRInstrument
Core library context object.
uint8_t responseBuffer[RBRINSTRUMENT_RESPONSE_BUFFER_MAX]
Data received from the instrument.
Definition: RBRInstrument.h:660
@ RBRINSTRUMENT_UNKNOWN_GENERATION
Definition: RBRInstrument.h:306
RBRInstrumentCallbacks callbacks
The set of callbacks to be used by the connection.
Definition: RBRInstrument.h:608
RBRInstrumentResponseType type
The type of this response: informational, warning, or error.
Definition: RBRInstrument.h:561
char * response
The response, if available.
Definition: RBRInstrument.h:577
void * userData
Arbitrary user data; useful in callbacks.
Definition: RBRInstrument.h:619
const char * RBRInstrument_getLastHardwareErrorMessage(const RBRInstrument *instrument)
Get the error message which resulted from the last instrument command, if applicable.
A command response returned by the instrument.
Definition: RBRInstrument.h:543
RBRInstrumentHardwareError
Errors which can be returned by the instrument.
Definition: RBRInstrumentHardwareErrors.h:23
@ RBRINSTRUMENT_LOGGER3
Definition: RBRInstrument.h:302
bool managedAllocation
Whether the instance memory was dynamically allocated by the constructor.
Definition: RBRInstrument.h:675
@ RBRINSTRUMENT_ERROR_COUNT
Definition: RBRInstrument.h:236
@ RBRINSTRUMENT_RESPONSE_INFO
Definition: RBRInstrument.h:520
RBRInstrumentGeneration
Generations of RBR instruments.
Definition: RBRInstrument.h:295
uint32_t serial
Definition: RBRInstrument.h:287
RBRInstrumentError RBRInstrument_open(RBRInstrument **instrument, const RBRInstrumentCallbacks *callbacks, RBRInstrumentDateTime commandTimeout, void *userData)
Establish a connection with an instrument and initialize the context.
int64_t RBRInstrumentDateTime
Definition: RBRInstrument.h:181
const char * RBRINSTRUMENT_LIB_NAME
The library name.
const char * RBRInstrumentGeneration_name(RBRInstrumentGeneration generation)
Get a human-readable string name for a generation.
char mode[RBRINSTRUMENT_ID_MODE_MAX+1]
Definition: RBRInstrument.h:291
#define RBRINSTRUMENT_ID_MODE_MAX
The maximum number of characters in the instrument mode.
Definition: RBRInstrument.h:168
RBRInstrumentTimeCallback time
Callback to get the current platform time in milliseconds.
Definition: RBRInstrument.h:485
void RBRInstrument_setCommandTimeout(RBRInstrument *instrument, RBRInstrumentDateTime commandTimeout)
Set the command timeout.
@ RBRINSTRUMENT_TIMEOUT
Definition: RBRInstrument.h:213
int32_t responseBufferLength
The number of used bytes in the response buffer.
Definition: RBRInstrument.h:625
Instrument hardware errors.
struct RBRInstrumentId RBRInstrumentId
Instrument id command parameters.
Instrument id command parameters.
Definition: RBRInstrument.h:280
int32_t RBRInstrumentPeriod
A periodic parameter.
Definition: RBRInstrument.h:191
struct RBRInstrumentResponse RBRInstrumentResponse
A command response returned by the instrument.
const char * RBRINSTRUMENT_LIB_VERSION
The library version.
@ RBRINSTRUMENT_RESPONSE_WARNING
Definition: RBRInstrument.h:522
struct RBRInstrumentCallbacks RBRInstrumentCallbacks
A set of callbacks from library to user code.
RBRInstrumentWriteCallback write
Called to write data to the physical instrument.
Definition: RBRInstrument.h:494
@ RBRINSTRUMENT_RESPONSE_ERROR
Definition: RBRInstrument.h:524
RBRInstrumentResponse response
The most recent response received from the instrument.
Definition: RBRInstrument.h:669
char model[RBRINSTRUMENT_ID_MODEL_MAX+1]
Definition: RBRInstrument.h:283
RBRInstrumentDateTime commandTimeout
The command timeout in milliseconds.
Definition: RBRInstrument.h:616
@ RBRINSTRUMENT_LOGGER1
Definition: RBRInstrument.h:298
A set of callbacks from library to user code.
Definition: RBRInstrument.h:482
@ RBRINSTRUMENT_HARDWARE_ERROR
Definition: RBRInstrument.h:221
@ RBRINSTRUMENT_RESPONSE_TYPE_COUNT
Definition: RBRInstrument.h:526
RBRInstrumentResponseType
The types of responses returned by the instrument.
Definition: RBRInstrument.h:517
RBRInstrumentError RBRInstrument_close(RBRInstrument *instrument)
Terminate the instrument connection and release any held resources.
RBRInstrumentError(* RBRInstrumentSampleCallback)(const struct RBRInstrument *instrument, const struct RBRInstrumentSample *const sample)
Callback to feed streaming sample data into user code.
Definition: RBRInstrument.h:472
RBRInstrumentError
Errors which can be returned from library functions.
Definition: RBRInstrument.h:200
RBRInstrumentError(* RBRInstrumentWriteCallback)(const struct RBRInstrument *instrument, const void *const data, int32_t size)
Callback to write data to the physical instrument.
Definition: RBRInstrument.h:442
uint16_t fwtype
Definition: RBRInstrument.h:289
uint8_t commandBuffer[RBRINSTRUMENT_COMMAND_BUFFER_MAX]
The next command to be sent to the instrument.
Definition: RBRInstrument.h:650
@ RBRINSTRUMENT_RESPONSE_UNKNOWN_TYPE
Definition: RBRInstrument.h:528
An instrument sample.
Definition: RBRInstrumentStreaming.h:492
RBRInstrumentGeneration RBRInstrument_getGeneration(const RBRInstrument *instrument)
Get the generation of an instrument.
char version[RBRINSTRUMENT_ID_VERSION_MAX+1]
Definition: RBRInstrument.h:285
@ RBRINSTRUMENT_CALLBACK_ERROR
Definition: RBRInstrument.h:211
#define RBRINSTRUMENT_ID_VERSION_MAX
The maximum number of characters in the instrument firmware version.
Definition: RBRInstrument.h:161
void * RBRInstrument_getUserData(const RBRInstrument *instrument)
Get the pointer to arbitrary user data.
const char * RBRINSTRUMENT_LIB_BUILD_DATE
The library build date.
@ RBRINSTRUMENT_ALLOCATION_FAILURE
Definition: RBRInstrument.h:205
RBRInstrumentDateTime lastActivityTime
The time at which instrument communication last occurred.
Definition: RBRInstrument.h:633
RBRInstrumentHardwareError error
The instrument warning or error number, if applicable.
Definition: RBRInstrument.h:570
int32_t commandBufferLength
The number of used bytes in the command buffer.
Definition: RBRInstrument.h:622
@ RBRINSTRUMENT_COMMUNICATION_ERROR
Definition: RBRInstrument.h:234
RBRInstrumentSleepCallback sleep
Callback to suspend activity for a fixed amount of time.
Definition: RBRInstrument.h:488
RBRInstrumentReadCallback read
Called to read data from the physical instrument.
Definition: RBRInstrument.h:491
@ RBRINSTRUMENT_SUCCESS
Definition: RBRInstrument.h:203
struct RBRInstrumentId id
The instrument identifier.
Definition: RBRInstrument.h:598
#define RBRINSTRUMENT_ID_MODEL_MAX
The maximum number of characters in the instrument model name.
Definition: RBRInstrument.h:154
const char * RBRInstrumentResponseType_name(RBRInstrumentResponseType type)
Get a human-readable string name for a response type.
@ RBRINSTRUMENT_SAMPLE
Definition: RBRInstrument.h:232
void RBRInstrument_setUserData(RBRInstrument *instrument, void *userData)
Change the arbitrary user data pointer.
struct RBRInstrumentSample * sampleBuffer
Where to put sample data for consumption by the sample callback.
Definition: RBRInstrument.h:509
int32_t lastResponseLength
The length in bytes of the most recent response.
Definition: RBRInstrument.h:641
#define RBRINSTRUMENT_COMMAND_BUFFER_MAX
The size of the buffer storing commands destined for the instrument.
Definition: RBRInstrument.h:63
RBRInstrumentError(* RBRInstrumentReadCallback)(const struct RBRInstrument *instrument, void *data, int32_t *size)
Callback to read data from the physical instrument.
Definition: RBRInstrument.h:411
@ RBRINSTRUMENT_BUFFER_TOO_SMALL
Definition: RBRInstrument.h:207
@ RBRINSTRUMENT_UNKNOWN_ERROR
Definition: RBRInstrument.h:238
RBRInstrumentDateTime RBRInstrument_getCommandTimeout(const RBRInstrument *instrument)
Get the command timeout.
@ RBRINSTRUMENT_INVALID_PARAMETER_VALUE
Definition: RBRInstrument.h:225
RBRInstrumentHardwareError RBRInstrument_getLastHardwareError(const RBRInstrument *instrument)
Get the error which resulted from the last instrument command, if applicable.
RBRInstrumentGeneration generation
The generation of the instrument.
Definition: RBRInstrument.h:605
RBRInstrumentSampleCallback sample
Called when streaming sample data has been received.
Definition: RBRInstrument.h:502
Core library context object.
Definition: RBRInstrument.h:591
#define RBRINSTRUMENT_RESPONSE_BUFFER_MAX
The size of the buffer storing instrument responses.
Definition: RBRInstrument.h:79
@ RBRINSTRUMENT_CHECKSUM_ERROR
Definition: RBRInstrument.h:223
Entry point for instrument command declarations.
@ RBRINSTRUMENT_UNSUPPORTED
Definition: RBRInstrument.h:215
@ RBRINSTRUMENT_LOGGER2
Definition: RBRInstrument.h:300
@ RBRINSTRUMENT_GENERATION_COUNT
Definition: RBRInstrument.h:304
const char * RBRInstrumentError_name(RBRInstrumentError error)
Get a human-readable string name for a library error.
RBRInstrumentError(* RBRInstrumentTimeCallback)(const struct RBRInstrument *instrument, RBRInstrumentDateTime *time)
Callback to get the current platform time in milliseconds.
Definition: RBRInstrument.h:345