C API
This page describes the basic functions of the C API interface. For each specific protocol APIs, please refer to the corresponding sections.
- group CosmicSDK C binding blocking API.
C bindings for the CosmicSDK blocking API.
This module exposes a C API suitable for C applications.
Typedefs
-
typedef struct CosmicSDK_Handle CosmicSDK_Handle
Opaque handle for CosmicSDK instance.
Functions
-
CosmicSDK_Handle *CosmicSDK_Create(int timeout_ms)
Creates a new CosmicSDK instance.
- Parameters:
timeout_ms – Timeout in milliseconds for operations.
- Returns:
Handle to the created instance
-
void CosmicSDK_Destroy(CosmicSDK_Handle *handle)
Destroys a CosmicSDK instance and frees associated resources.
- Parameters:
handle – Handle to the instance to destroy
-
struct C_DeviceInfo
- #include <CosmicSDK_API_c.h>
Structure to hold device information from C API.
Public Members
-
char *manufacturer
Null-terminated manufacturer string.
-
size_t manufacturerLength
Manufacturer string length, excluding null terminator.
-
char *productName
Null-terminated product name string.
-
size_t productNameLength
Product name string length, excluding null terminator.
-
char *serialNumber
Null-terminated device serial number string.
-
size_t serialNumberLength
Serial number string length, excluding null terminator.
-
char *fwVersion
Null-terminated firmware version string.
-
size_t fwVersionLength
Firmware version string length, excluding null terminator.
-
char *hwVersion
Null-terminated hardware version string.
-
size_t hwVersionLength
Hardware version string length, excluding null terminator.
-
char *manufacturer
-
struct CosmicSDK_BulkGroup
- #include <CosmicSDK_API_c.h>
One command group’s bulk-transfer support, as reported by the connected device.
One entry per protocol group (I2C, SPI, I3C, …) the connected device knows about. Filled in by CosmicSDK_GetBulkCapabilities.
Public Members
-
uint8_t group
Protocol group id the entry describes (e.g. I2C = 2, SPI = 3; see the
GROUP_*constants in definitions.h).
-
uint16_t maxPayloadLength
Largest payload, in bytes, this device accepts for a single bulk command in the group. 0 if the group is not supported.
-
uint32_t commandMask
Bit N set when the command whose 7-bit value field equals N is implemented for this group.
-
uint8_t group
-
typedef struct CosmicSDK_Handle CosmicSDK_Handle