Skip to content

Add functions for mutating the CAN/CANFD Structs to C API #82

@tt-MarkSchadow

Description

@tt-MarkSchadow

It is currently not possible to set the timing parameters or the iso compliance using the C-API.
So I propose to add the functions as follows:

icsneoc.h

/**
 * \brief Get a mutable CAN_SETTINGS struct for the specified device
 * \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
 * \param[in] netid The network for which the baudrate should be retrieved.
 * \param[out] can_settings_struct Address to a pointer that will hold a reference to the struct
 * \returns True if the struct could be retrieved
 *
 */
extern bool DLLExport icsneo_getMutableCANSettingsFor(const neodevice_t* device, neonetid_t netid, CAN_SETTINGS** can_settings_struct);

/**
 * \brief Get a mutable CANFD_SETTINGS struct for the specified device
 * \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
 * \param[in] netid The network for which the baudrate should be retrieved.
 * \param[out] canfd_settings_struct Address to a pointer that will hold a reference to the struct
 * \returns True if the struct could be retrieved
 *
 */
extern bool DLLExport icsneo_getMutableCANFDSettingsFor(const neodevice_t* device, neonetid_t netid, CANFD_SETTINGS** canfd_settings_struct);

icsneoc.cpp

bool icsneo_getMutableCANSettingsFor(const neodevice_t* device, neonetid_t netid, CAN_SETTINGS** can_settings_struct) {
	if(!icsneo_isValidNeoDevice(device))
		return false;
		
	*can_settings_struct = device->device->settings->getMutableCANSettingsFor(netid);

	return true;
}

bool icsneo_getMutableCANFDSettingsFor(const neodevice_t* device, neonetid_t netid, CANFD_SETTINGS** canfd_settings_struct) {
	if(!icsneo_isValidNeoDevice(device))
		return false;

	*canfd_settings_struct = device->device->settings->getMutableCANFDSettingsFor(netid);

	return true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions