System API
This page aggregates all C++ System-related public methods of the class CosmicSDK.
- group CosmicSDK System API
Constants and APIs related to System operations.
Functions
-
inline void onNotification(NotificationCallback callback)
Registers a callback to be invoked when an asynchronous notification is received.
- Parameters:
callback – Function that will receive a const reference to a Notification object.
-
bool connect(const std::string &devicePath = "")
Connects to a Binho Host Adapter device, such as Pulsar or Supernova. If no device path is provided, it will attempt to connect to the first available device.
- Parameters:
devicePath – The path to the device (e.g., COM3 on Windows or /dev/ttyUSB0 on Linux). If empty, connects to the first available device.
- Returns:
True if the connection was successful, false otherwise.
-
bool connectWithSerialNumber(const std::string &serial)
Connects to a Binho Host Adapter device using its serial number.
- Parameters:
serial – The serial number of the device to connect to.
- Returns:
True if the connection was successful, false otherwise.
-
void disconnect()
Disconnects from the currently connected Binho Host Adapter device.
-
uint16_t resetDevice()
Resets the connected device.
Sends a reset command to the device. The device will restart and the connection will be lost. After the device has rebooted, a new connection must be established before issuing further commands. Use connect or connectWithSerialNumber to reconnect.
Note
Allow sufficient time for the device to reboot before reconnecting (typically a few seconds).
- Return values:
SUCCESS – The reset command was accepted by the device.
SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.
-
uint16_t getDeviceInfo(DeviceInfo &info)
Gets the device information.
- Parameters:
info – The device information object to be filled with data
- Returns:
The status code of the operation
-
static inline std::string getVersion()
Gets the CosmicSDK library version string.
Returns a string containing the version number of the linked CosmicSDK library. This allows verification at startup that the linked library matches what they were built against.
- Returns:
A version string in the format “MAJOR.MINOR.PATCH”, e.g. “1.2.3”
-
uint16_t enterBootMode()
Puts the device into boot mode. Once the device process the request, it immediately jumps into the bootloader. After the user has flashed the device with a firmware, a new connection needs to be done to continue using the device.
- Return values:
SUCCESS – The request was successfully sent to the device.
SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.
-
uint16_t setUsbConfig(const UsbConfig &config)
Sets the USB CDC operating mode.
Note
To change the USB CDC configuration, the device must be reset to apply the new settings. This is done automatically by the device after a successful call to this function.
- Parameters:
config – The USB CDC configuration to set. See UsbConfig for supported values.
- Return values:
SUCCESS – The USB CDC configuration was successfully set (a device reset is required to take effect).
FW_INVALID_PARAMETER – The provided configuration contains invalid parameters.
FW_SETTINGS_SAVE_FAILED – The new configuration could not be saved to the device’s flash memory.
SDK_TIMEOUT – The operation timed out.
SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.
-
uint16_t getUsbConfig(UsbConfig &config)
Gets the current USB CDC configuration.
- Parameters:
config – The USB configuration to be filled with data. See UsbConfig for supported values.
- Return values:
SUCCESS – The USB configuration was successfully retrieved.
SDK_TIMEOUT – The operation timed out.
SDK_ERROR_DISCONNECT – The device was disconnected or became unavailable during the operation.
SDK_ERROR_WRONG_RESPONSE – The device returned an unexpected response.
SDK_ERROR_UNEXPECTED_RESPONSE – The device returned a response that does not match the request.
-
inline void onNotification(NotificationCallback callback)