mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
API: Add icsneoc2
This commit is contained in:
committed by
Kyle Schwarz
parent
294e707924
commit
682299cb8c
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,53 @@
|
||||
// This header is for internal icsneoc2 use only, it should not be included by users of the API.
|
||||
#pragma once
|
||||
|
||||
#include "icsneo/icsneoc2.h"
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include "icsneo/communication/message/scriptstatusmessage.h"
|
||||
#include "icsneo/api/event.h"
|
||||
#include "icsneo/disk/diskdetails.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
typedef struct icsneoc2_message_t {
|
||||
std::shared_ptr<Message> message;
|
||||
} icsneoc2_message_t;
|
||||
|
||||
typedef struct icsneoc2_event_t {
|
||||
APIEvent event;
|
||||
} icsneoc2_event_t;
|
||||
|
||||
typedef struct icsneoc2_device_info_t {
|
||||
std::shared_ptr<Device> device;
|
||||
icsneoc2_device_info_t* next;
|
||||
} icsneoc2_device_info_t;
|
||||
|
||||
typedef struct icsneoc2_device_t {
|
||||
std::shared_ptr<Device> device;
|
||||
} icsneoc2_device_t;
|
||||
|
||||
typedef struct icsneoc2_disk_details_t {
|
||||
std::shared_ptr<DiskDetails> details;
|
||||
} icsneoc2_disk_details_t;
|
||||
|
||||
typedef struct icsneoc2_script_status_t {
|
||||
std::shared_ptr<ScriptStatusMessage> status;
|
||||
} icsneoc2_script_status_t;
|
||||
|
||||
/**
|
||||
* Safely copies a std::string to a char array.
|
||||
*
|
||||
* @param dest The buffer to copy the string into
|
||||
* @param dest_size* The size of the buffer. Will be modified to the length of the string without the null terminator.
|
||||
* @param src The string to copy
|
||||
*
|
||||
* @return true if the string was successfully copied, false otherwise
|
||||
*
|
||||
* @note This function always null terminates the buffer, even if the string is too long.
|
||||
* In the case of truncation, dest_size will reflect the truncated length (not including the null terminator).
|
||||
*/
|
||||
bool safe_str_copy(char* dest, size_t* dest_size, std::string_view src);
|
||||
@@ -0,0 +1,218 @@
|
||||
#include "icsneo/icsneoc2messages.h" // TODO: Remove this after the complete refactor
|
||||
|
||||
#include "icsneo/icsneoc2.h"
|
||||
#include "icsneoc2_internal.h"
|
||||
|
||||
#include "icsneo/icsneocpp.h"
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include "icsneo/communication/message/canmessage.h"
|
||||
#include "icsneo/communication/message/linmessage.h"
|
||||
#include "icsneo/communication/message/ethernetmessage.h"
|
||||
#include "icsneo/communication/packet/canpacket.h"
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_is_valid(icsneoc2_message_t* message, bool* is_valid) {
|
||||
if(!message || !is_valid) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
|
||||
*is_valid = (bool)message->message;
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_is_transmit(icsneoc2_message_t* message, bool* value) {
|
||||
if(!message || !value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// We can static cast here because we are relying on the type being correct at this point
|
||||
auto frame = std::dynamic_pointer_cast<Frame>(message->message);
|
||||
if(!frame) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
*value = frame->transmitted;
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_netid_get(icsneoc2_message_t* message, icsneoc2_netid_t* netid) {
|
||||
if(!message || !netid) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
|
||||
if(!raw) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
*netid = static_cast<icsneoc2_netid_t>(raw->network.getNetID());
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, char* value, size_t* value_length) {
|
||||
if(!value || !value_length) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto netid_str = std::string(Network::GetNetIDString(static_cast<Network::NetID>(netid), true));
|
||||
// Copy the string into value
|
||||
return safe_str_copy(value, value_length, netid_str) ? icsneoc2_error_success : icsneoc2_error_string_copy_failed;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_message_t* message, icsneoc2_netid_t netid) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
|
||||
if(!raw) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
raw->network = Network(static_cast<neonetid_t>(netid), true);
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_data_set(icsneoc2_message_t* message, uint8_t* data, size_t data_length) {
|
||||
if(!message || !data) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the message has the data field (RawMessage or Frame)
|
||||
auto raw_message = std::dynamic_pointer_cast<RawMessage>(message->message);
|
||||
if(!raw_message) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
raw_message->data.resize(data_length);
|
||||
std::copy(data, data + data_length, raw_message->data.begin());
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_data_get(icsneoc2_message_t* message, uint8_t* data, size_t* data_length) {
|
||||
if(!message || !data_length) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the message has the data field (RawMessage or Frame)
|
||||
auto raw_message = std::dynamic_pointer_cast<RawMessage>(message->message);
|
||||
if(!raw_message) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
if(!data) {
|
||||
*data_length = raw_message->data.size();
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
if(*data_length < raw_message->data.size()) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
std::copy(raw_message->data.begin(), raw_message->data.begin() + raw_message->data.size(), data);
|
||||
*data_length = raw_message->data.size();
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_can_create(icsneoc2_message_t** message) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
try {
|
||||
*message = new icsneoc2_message_t;
|
||||
// Initialize the internal message as a CANMessage so that all icsneoc2_message_can_*_set
|
||||
// functions work correctly on user-created transmit messages.
|
||||
(*message)->message = std::make_shared<CANMessage>();
|
||||
} catch(const std::bad_alloc&) {
|
||||
return icsneoc2_error_out_of_memory;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_free(icsneoc2_message_t* message) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
delete message;
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_can_props_set(icsneoc2_message_t* message, const uint64_t* arb_id, const uint64_t* flags) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto can_msg = std::dynamic_pointer_cast<CANMessage>(message->message);
|
||||
if(!can_msg) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
if(arb_id) {
|
||||
can_msg->arbid = static_cast<uint32_t>(*arb_id);
|
||||
}
|
||||
if(flags) {
|
||||
can_msg->isRemote = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_RTR);
|
||||
can_msg->isExtended = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_IDE);
|
||||
can_msg->isCANFD = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_FDF);
|
||||
can_msg->baudrateSwitch = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_BRS);
|
||||
can_msg->errorStateIndicator = (*flags & ICSNEOC2_MESSAGE_CAN_FLAGS_ESI);
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_can_props_get(icsneoc2_message_t* message, uint64_t* arb_id, uint64_t* flags) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto can_msg = std::dynamic_pointer_cast<CANMessage>(message->message);
|
||||
if(!can_msg) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
if(arb_id) {
|
||||
*arb_id = can_msg->arbid;
|
||||
}
|
||||
if(flags) {
|
||||
*flags = 0;
|
||||
if(can_msg->isRemote) {
|
||||
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_RTR;
|
||||
}
|
||||
if(can_msg->isExtended) {
|
||||
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_IDE;
|
||||
}
|
||||
if(can_msg->isCANFD) {
|
||||
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_FDF;
|
||||
}
|
||||
if(can_msg->baudrateSwitch) {
|
||||
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_BRS;
|
||||
}
|
||||
if(can_msg->errorStateIndicator) {
|
||||
*flags |= ICSNEOC2_MESSAGE_CAN_FLAGS_ESI;
|
||||
}
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_network_type_get(icsneoc2_message_t* message, icsneoc2_network_type_t* network_type) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto raw = std::dynamic_pointer_cast<RawMessage>(message->message);
|
||||
if(!raw) {
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
*network_type = (icsneoc2_network_type_t)raw->network.getType();
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_is_raw(icsneoc2_message_t* message, bool* is_raw) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*is_raw = std::dynamic_pointer_cast<RawMessage>(message->message) != nullptr;
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_is_frame(icsneoc2_message_t* message, bool* is_frame) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*is_frame = std::dynamic_pointer_cast<Frame>(message->message) != nullptr;
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_message_is_can(icsneoc2_message_t* message, bool* is_can) {
|
||||
if(!message) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*is_can = std::dynamic_pointer_cast<CANMessage>(message->message) != nullptr;
|
||||
return icsneoc2_error_success;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,684 @@
|
||||
#include "icsneo/icsneoc2.h"
|
||||
#include "icsneo/icsneoc2settings.h"
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicefinder.h"
|
||||
#include "icsneo/icsneocpp.h"
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include "icsneo/communication/message/canmessage.h"
|
||||
#include "icsneo/communication/message/linmessage.h"
|
||||
#include "icsneo/communication/message/ethernetmessage.h"
|
||||
#include "icsneo/communication/packet/canpacket.h"
|
||||
#include "icsneo/communication/io.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
#include "icsneoc2_internal.h"
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_apply_defaults(icsneoc2_device_t* device, bool save) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->applyDefaults(!save)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_apply(icsneoc2_device_t* device) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->apply()) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_refresh(icsneoc2_device_t* device) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->refresh()) {
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate) {
|
||||
if(!baudrate) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto baudrate_value = device->device->settings->getBaudrateFor(Network(netid));
|
||||
if(baudrate_value < 0) {
|
||||
*baudrate = 0;
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
*baudrate = baudrate_value;
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setBaudrateFor(Network(netid), baudrate)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t* baudrate) {
|
||||
if(!baudrate) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
*baudrate = device->device->settings->getFDBaudrateFor(Network(netid));
|
||||
if(*baudrate < 0) {
|
||||
*baudrate = 0;
|
||||
return icsneoc2_error_invalid_type;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_canfd_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, int64_t baudrate) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setFDBaudrateFor(Network(netid), baudrate)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_termination_is_supported(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* supported) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!supported) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*supported = device->device->settings->isTerminationSupportedFor(Network(static_cast<Network::NetID>(netid)));
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_termination_can_enable(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* can_enable) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!can_enable) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*can_enable = device->device->settings->canTerminationBeEnabledFor(Network(static_cast<Network::NetID>(netid)));
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_termination_is_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!enabled) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*enabled = device->device->settings->isTerminationEnabledFor(Network(static_cast<Network::NetID>(netid))).value_or(false);
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_termination_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setTerminationFor(Network(static_cast<Network::NetID>(netid)), enable)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_commander_resistor_enabled(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* enabled) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!enabled) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
*enabled = device->device->settings->isCommanderResistorEnabledFor(Network(static_cast<Network::NetID>(netid))).value_or(false);
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_commander_resistor_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool enable) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setCommanderResistorFor(Network(static_cast<Network::NetID>(netid)), enable)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_lin_mode_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getLINModeFor(network); result.has_value()) {
|
||||
*value = static_cast<icsneoc2_lin_mode_t>(result.value());
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_lin_mode_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_lin_mode_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setLINModeFor(network, static_cast<LINMode>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getLINCommanderResponseTimeFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_lin_commander_response_time_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setLINCommanderResponseTimeFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_enable_get(icsneoc2_device_t* device, uint8_t index, bool* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
if(auto result = device->device->settings->getPhyEnable(index); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = false;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_enable_set(icsneoc2_device_t* device, uint8_t index, bool value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setPhyEnable(index, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_mode_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
if(auto result = device->device->settings->getPhyMode(index); result.has_value()) {
|
||||
*value = static_cast<icsneoc2_ae_link_mode_t>(result.value());
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_mode_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_ae_link_mode_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setPhyMode(index, static_cast<AELinkMode>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_speed_get(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
if(auto result = device->device->settings->getPhySpeed(index); result.has_value()) {
|
||||
*value = static_cast<icsneoc2_eth_phy_link_mode_t>(result.value());
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
icsneoc2_error_t icsneoc2_settings_phy_speed_set(icsneoc2_device_t* device, uint8_t index, icsneoc2_eth_phy_link_mode_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setPhySpeed(index, static_cast<EthPhyLinkMode>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_role_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getPhyRoleFor(network); result.has_value()) {
|
||||
*value = static_cast<icsneoc2_ae_link_mode_t>(result.value());
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_role_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_ae_link_mode_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setPhyRoleFor(network, static_cast<AELinkMode>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getPhyLinkModeFor(network); result.has_value()) {
|
||||
*value = static_cast<icsneoc2_eth_phy_link_mode_t>(result.value());
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_link_mode_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setPhyLinkModeFor(network, static_cast<EthPhyLinkMode>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_enable_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getPhyEnableFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = false;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_phy_enable_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setPhyEnableFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_supported_phy_link_modes_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, icsneoc2_eth_phy_link_mode_t** link_modes, size_t* link_modes_count) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!link_modes || !link_modes_count) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
auto modes = device->device->settings->getSupportedPhyLinkModesFor(network);
|
||||
*link_modes_count = std::minmax(modes.size(), *link_modes_count).first;
|
||||
memcpy(*link_modes, modes.data(), *link_modes_count * sizeof(icsneoc2_eth_phy_link_mode_t));
|
||||
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_is_plca_enabled_for(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->isT1SPLCAEnabledFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = false;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_plca_enabled_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, bool value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setT1SPLCAFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_local_id_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value){
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getT1SLocalIDFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_local_id_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value){
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setT1SLocalIDFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getT1SMaxNodesFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_max_nodes_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setT1SMaxNodesFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getT1STxOppTimerFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_tx_opp_timer_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setT1STxOppTimerFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t* value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(auto result = device->device->settings->getT1SMaxBurstFor(network); result.has_value()) {
|
||||
*value = result.value();
|
||||
return icsneoc2_error_success;
|
||||
} else {
|
||||
*value = 0;
|
||||
return icsneoc2_error_get_settings_failure;
|
||||
}
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_t1s_max_burst_timer_for_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint8_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
auto network = Network(static_cast<Network::NetID>(netid));
|
||||
if(!device->device->settings->setT1SMaxBurstFor(network, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_enabled_set(icsneoc2_device_t* device, uint8_t pin, uint8_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setMiscIOAnalogOutputEnabled(pin, value)) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_misc_io_analog_output_set(icsneoc2_device_t* device, uint8_t pin, icsneoc2_misc_io_analog_voltage_t value) {
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
if(!device->device->settings->setMiscIOAnalogOutput(pin, static_cast<MiscIOAnalogVoltage>(value))) {
|
||||
return icsneoc2_error_set_settings_failure;
|
||||
}
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_disabled_get(icsneoc2_device_t* device, bool* value) {
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
*value = device->device->settings->disabled;
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
|
||||
icsneoc2_error_t icsneoc2_settings_readonly_get(icsneoc2_device_t* device, bool* value) {
|
||||
if(!value) {
|
||||
return icsneoc2_error_invalid_parameters;
|
||||
}
|
||||
// Make sure the device is valid
|
||||
auto res = icsneoc2_device_is_valid(device);
|
||||
if(res != icsneoc2_error_success) {
|
||||
return res;
|
||||
}
|
||||
*value = device->device->settings->readonly;
|
||||
return icsneoc2_error_success;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#define VER_FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@
|
||||
#define VER_FILEVERSION_STR "v@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@@BUILD_METADATA_PLUS@ @BUILD_GIT_INFO@"
|
||||
|
||||
#define VER_PRODUCTVERSION VER_FILEVERSION
|
||||
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
|
||||
|
||||
#ifndef DEBUG
|
||||
#define VER_DEBUG 0
|
||||
#else
|
||||
#define VER_DEBUG VS_FF_DEBUG
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_FILEVERSION
|
||||
PRODUCTVERSION VER_PRODUCTVERSION
|
||||
FILEFLAGSMASK (VS_FF_DEBUG)
|
||||
FILEFLAGS (VER_DEBUG)
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Intrepid Control Systems, Inc."
|
||||
VALUE "FileDescription", "Intrepid Control Systems Open Device Communication C API"
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "InternalName", "icsneoc2.dll"
|
||||
VALUE "LegalCopyright", "Intrepid Control Systems, Inc. (C) 2018-2026"
|
||||
VALUE "OriginalFilename", "icsneoc2.dll"
|
||||
VALUE "ProductName", "libicsneo"
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
/* The following line should only be modified for localized versions. */
|
||||
/* It consists of any number of WORD,WORD pairs, with each pair */
|
||||
/* describing a language,codepage combination supported by the file. */
|
||||
/* */
|
||||
/* For example, a file might have values "0x409,1252" indicating that it */
|
||||
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
|
||||
|
||||
VALUE "Translation", 0x409, 1252
|
||||
|
||||
END
|
||||
END
|
||||
Reference in New Issue
Block a user