added getter and setters for baudrates
parent
bac4d86c57
commit
e9b0cdae56
|
|
@ -958,6 +958,66 @@ ICSNEO_API icsneo_error_t icsneo_device_load_default_settings(icsneo_device_t* d
|
||||||
return icsneo_error_success;
|
return icsneo_error_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_get_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t* baudrate) {
|
||||||
|
if (!device || !baudrate) {
|
||||||
|
return icsneo_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
// TODO: Check if device is valid
|
||||||
|
*baudrate = device->device->settings->getBaudrateFor(Network(netid));
|
||||||
|
if (baudrate < 0) {
|
||||||
|
return icsneo_error_invalid_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return icsneo_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_set_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t baudrate, bool save) {
|
||||||
|
if (!device) {
|
||||||
|
return icsneo_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
// TODO: Check if device is valid
|
||||||
|
if (!device->device->settings->setBaudrateFor(Network(netid), baudrate)) {
|
||||||
|
return icsneo_error_set_settings_failure;
|
||||||
|
}
|
||||||
|
if (save) {
|
||||||
|
if (!device->device->settings->apply()) {
|
||||||
|
return icsneo_error_set_settings_failure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return icsneo_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_get_canfd_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t* baudrate) {
|
||||||
|
if (!device || !baudrate) {
|
||||||
|
return icsneo_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
// TODO: Check if device is valid
|
||||||
|
*baudrate = device->device->settings->getFDBaudrateFor(Network(netid));
|
||||||
|
if (baudrate < 0) {
|
||||||
|
return icsneo_error_invalid_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return icsneo_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_set_canfd_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t baudrate, bool save) {
|
||||||
|
if (!device) {
|
||||||
|
return icsneo_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
// TODO: Check if device is valid
|
||||||
|
if (!device->device->settings->setFDBaudrateFor(Network(netid), baudrate)) {
|
||||||
|
return icsneo_error_set_settings_failure;
|
||||||
|
}
|
||||||
|
if (save) {
|
||||||
|
if (!device->device->settings->apply()) {
|
||||||
|
return icsneo_error_set_settings_failure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return icsneo_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
ICSNEO_API icsneo_error_t icsneo_device_supports_tc10(icsneo_device_t* device, bool* supported) {
|
ICSNEO_API icsneo_error_t icsneo_device_supports_tc10(icsneo_device_t* device, bool* supported) {
|
||||||
if (!device || !supported) {
|
if (!device || !supported) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,23 @@ int main(int argc, char* argv[]) {
|
||||||
print_device_events(device, description);
|
print_device_events(device, description);
|
||||||
return print_error_code("Failed to open device", res);
|
return print_error_code("Failed to open device", res);
|
||||||
};
|
};
|
||||||
|
// Get/Set baudrate for HSCAN
|
||||||
|
uint64_t baudrate = 0;
|
||||||
|
res = icsneo_device_get_baudrate(device, icsneo_netid_hscan, &baudrate);
|
||||||
|
res += icsneo_device_set_baudrate(device, icsneo_netid_hscan, baudrate, true);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
print_device_events(device, description);
|
||||||
|
return print_error_code("Failed to transmit CAN messages", res);
|
||||||
|
};
|
||||||
|
printf("HSCAN baudrate: %llu\n", baudrate);
|
||||||
|
// Get/Set CAN FD baudrate for HSCAN
|
||||||
|
res = icsneo_device_get_canfd_baudrate(device, icsneo_netid_hscan, &baudrate);
|
||||||
|
res += icsneo_device_set_canfd_baudrate(device, icsneo_netid_hscan, baudrate, true);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
print_device_events(device, description);
|
||||||
|
return print_error_code("Failed to transmit CAN messages", res);
|
||||||
|
};
|
||||||
|
printf("HSCAN CANFD baudrate: %llu\n", baudrate);
|
||||||
// Transmit CAN messages
|
// Transmit CAN messages
|
||||||
res = transmit_can_messages(device);
|
res = transmit_can_messages(device);
|
||||||
if (res != icsneo_error_success) {
|
if (res != icsneo_error_success) {
|
||||||
|
|
|
||||||
|
|
@ -641,12 +641,57 @@ ICSNEO_API icsneo_error_t icsneo_device_set_rtc(icsneo_device_t* device, int64_t
|
||||||
/** @brief Load the default settings for a device
|
/** @brief Load the default settings for a device
|
||||||
*
|
*
|
||||||
* @param[in] icsneo_device_t device The device to load the settings for.
|
* @param[in] icsneo_device_t device The device to load the settings for.
|
||||||
* @param[in] bool save True to make the settings permanent, false settings will be reverted on next boot.
|
* @param[in] bool save True to make the settings permanent, false will be reverted on power cycle.
|
||||||
*
|
*
|
||||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
*/
|
*/
|
||||||
ICSNEO_API icsneo_error_t icsneo_device_load_default_settings(icsneo_device_t* device, bool save);
|
ICSNEO_API icsneo_error_t icsneo_device_load_default_settings(icsneo_device_t* device, bool save);
|
||||||
|
|
||||||
|
/** @brief Get the baudrate for a network
|
||||||
|
*
|
||||||
|
* @note @see icsneo_device_get_canfd_baudrate for CANFD.
|
||||||
|
*
|
||||||
|
* @param[in] icsneo_device_t* device The device to get the baudrate value.
|
||||||
|
* @param[in] icsneo_netid_t netid The network to get the baudrate value.
|
||||||
|
* @param[in] uint64_t* baudrate The baudrate to get the network value.
|
||||||
|
*
|
||||||
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_get_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t* baudrate);
|
||||||
|
|
||||||
|
/** @brief Set the baudrate for a network
|
||||||
|
*
|
||||||
|
* @note @see icsneo_device_set_canfd_baudrate for CANFD.
|
||||||
|
*
|
||||||
|
* @param[in] icsneo_device_t* device The device to set the baudrate for.
|
||||||
|
* @param[in] icsneo_netid_t netid The network to set the baudrate for.
|
||||||
|
* @param[in] uint64_t baudrate The baudrate to set the network to.
|
||||||
|
* @param[in] bool save True to make the settings permanent, false will be reverted on power cycle.
|
||||||
|
*
|
||||||
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_set_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t baudrate, bool save);
|
||||||
|
|
||||||
|
/** @brief Get the baudrate for a CAN FD network
|
||||||
|
*
|
||||||
|
* @param[in] icsneo_device_t* device The device to get the baudrate value.
|
||||||
|
* @param[in] icsneo_netid_t netid The network to get the baudrate value.
|
||||||
|
* @param[in] uint64_t* baudrate The baudrate to get the network value.
|
||||||
|
*
|
||||||
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_get_canfd_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t* baudrate);
|
||||||
|
|
||||||
|
/** @brief Set the baudrate for a CANFD network
|
||||||
|
*
|
||||||
|
* @param[in] icsneo_device_t* device The device to set the baudrate for.
|
||||||
|
* @param[in] icsneo_netid_t netid The network to set the baudrate for.
|
||||||
|
* @param[in] uint64_t baudrate The baudrate to set the network to.
|
||||||
|
*
|
||||||
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_device_set_canfd_baudrate(icsneo_device_t* device, icsneo_netid_t netid, uint64_t baudrate, bool save);
|
||||||
|
|
||||||
/** @brief Check if the device supports TC10.
|
/** @brief Check if the device supports TC10.
|
||||||
*
|
*
|
||||||
* @param[in] icsneo_device_t* device The device to check against.
|
* @param[in] icsneo_device_t* device The device to check against.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue