Compare commits
4 Commits
360610c0ac
...
b44bf07d1b
| Author | SHA1 | Date |
|---|---|---|
|
|
b44bf07d1b | |
|
|
6ca173813e | |
|
|
6a17e98488 | |
|
|
b88f8dbb05 |
|
|
@ -1,7 +1,7 @@
|
|||
#include <icsneo/icsneo.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"
|
||||
|
|
@ -16,6 +16,7 @@ using namespace icsneo;
|
|||
typedef struct icsneo_device_t {
|
||||
std::shared_ptr<Device> device;
|
||||
std::vector<std::shared_ptr<icsneo_message_t>> messages;
|
||||
std::vector<icsneo_event_t> events;
|
||||
|
||||
icsneo_open_options_t options;
|
||||
} icsneo_device_t;
|
||||
|
|
@ -24,8 +25,13 @@ typedef struct icsneo_message_t {
|
|||
std::shared_ptr<Message> message;
|
||||
} icsneo_message_t;
|
||||
|
||||
typedef struct icsneo_event_t {
|
||||
APIEvent event;
|
||||
} icsneo_event_t;
|
||||
|
||||
|
||||
static std::vector<std::shared_ptr<icsneo_device_t>> g_devices;
|
||||
static std::vector<icsneo_event_t> g_events;
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_error_code(icsneo_error_t error_code, const char* value, uint32_t* value_length) {
|
||||
if (!value || !value_length) {
|
||||
|
|
@ -350,7 +356,7 @@ ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_me
|
|||
uint32_t min_size = std::minmax(static_cast<uint32_t>(queried_messages.size()), *messages_count).first;
|
||||
*messages_count = min_size;
|
||||
|
||||
// Copy the messages into our global message container
|
||||
// Copy the messages into our device message container
|
||||
device->messages.clear();
|
||||
for (auto& message : queried_messages) {
|
||||
auto message_t = std::make_shared<icsneo_message_t>();
|
||||
|
|
@ -406,3 +412,233 @@ ICSNEO_API icsneo_error_t icsneo_message_get_bus_type(icsneo_device_t* device, i
|
|||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_message_get_data(icsneo_device_t* device, icsneo_message_t* message, uint8_t* data, uint32_t* data_length) {
|
||||
if (!device || !message || !data || !data_length) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
// Make sure the message has the data field, internal and bus currently have this.
|
||||
if (message->message->getMsgType() != icsneo_msg_type_internal && message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
auto* data_message = dynamic_cast<InternalMessage*>(message->message.get());
|
||||
if (!data_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
auto min_length = std::minmax(static_cast<uint32_t>(data_message->data.size()), *data_length).first;
|
||||
*data_length = min_length;
|
||||
std::copy(data_message->data.begin(), data_message->data.begin() + min_length, data);
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_arbid(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->arbid;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_dlc_on_wire(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = static_cast<uint32_t>(can_message->dlcOnWire);
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_remote(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->isRemote;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_extended(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->isExtended;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_canfd(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->isCANFD;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_baudrate_switch(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->baudrateSwitch;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_error_state_indicator(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// TODO: Check if message is valid
|
||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||
if (!can_message) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
|
||||
*value = can_message->errorStateIndicator;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_get_events(icsneo_event_t** events, uint32_t* events_count) {
|
||||
if (!events || !events_count) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// Clear the device events
|
||||
g_events.clear();
|
||||
// Get the global events
|
||||
auto global_events = EventManager::GetInstance().get();
|
||||
// Get the mininum number of events
|
||||
auto min_size = std::minmax(static_cast<uint32_t>(global_events.size()), *events_count).first;
|
||||
*events_count = min_size;
|
||||
// Copy the events into the global event container
|
||||
for (uint32_t i = 0; i < min_size; i++) {
|
||||
auto e = icsneo_event_t {
|
||||
.event = global_events[i],
|
||||
};
|
||||
g_events.push_back(e);
|
||||
}
|
||||
// Copy the global events references into the events array
|
||||
for (uint32_t i = 0; i < min_size; i++) {
|
||||
events[i] = &g_events[i];
|
||||
}
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_device_get_events(icsneo_device_t* device, icsneo_event_t** events, uint32_t* events_count) {
|
||||
if (!device || !events || !events_count) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if device is valid
|
||||
// Setup the event filter
|
||||
EventFilter filter(device->device.get());
|
||||
// Clear the device events
|
||||
device->events.clear();
|
||||
// Get the mininum number of events
|
||||
auto min_size = std::minmax(static_cast<uint32_t>(icsneo::EventCount(filter)), *events_count).first;
|
||||
*events_count = min_size;
|
||||
// GetEvents uses 0 as unlimited, where the API can't allocate anything.
|
||||
if (min_size == 0) {
|
||||
return icsneo_error_success;
|
||||
}
|
||||
// Copy the events into the device event container
|
||||
auto device_events = icsneo::GetEvents(filter, min_size);
|
||||
for (uint32_t i = 0; i < min_size; i++) {
|
||||
auto e = icsneo_event_t {
|
||||
.event = device_events[i],
|
||||
};
|
||||
device->events.push_back(e);
|
||||
}
|
||||
// Copy the device events references into the events array
|
||||
for (uint32_t i = 0; i < min_size; i++) {
|
||||
events[i] = &device->events[i];
|
||||
}
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_event_get_description(icsneo_event_t* event, const char* value, uint32_t* value_length) {
|
||||
if (!event || !value || !value_length) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if event is valid
|
||||
auto ev = event->event;
|
||||
|
||||
// Get and set the length
|
||||
auto min_length = std::minmax(static_cast<uint32_t>(ev.describe().length()), *value_length).first;
|
||||
*value_length = min_length;
|
||||
// Copy the string into value
|
||||
strncpy(const_cast<char *>(value), ev.describe().c_str(), min_length);
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
/*
|
||||
Type getType() const noexcept { return Type(eventStruct.eventNumber); }
|
||||
Severity getSeverity() const noexcept { return Severity(eventStruct.severity); }
|
||||
std::string getDescription() const noexcept { return std::string(eventStruct.description); }
|
||||
const Device* getDevice() const noexcept { return device; } // Will return nullptr if this is an API-wide event
|
||||
EventTimePoint getTimestamp() const noexcept { return timepoint; }
|
||||
|
||||
void downgradeFromError() noexcept;
|
||||
|
||||
bool isForDevice(const Device* forDevice) const noexcept { return forDevice == device; }
|
||||
bool isForDevice(std::string serial) const noexcept;
|
||||
|
||||
// As opposed to getDescription, this will also add text such as "neoVI FIRE 2 CY2468 Error: " to fully describe the problem
|
||||
std::string describe() const noexcept;
|
||||
friend std::ostream& operator<<(std::ostream& os, const APIEvent& event) {
|
||||
os << event.describe();
|
||||
return os;
|
||||
}
|
||||
|
||||
static const char* DescriptionForType(Type type);
|
||||
*/
|
||||
|
|
@ -42,7 +42,7 @@ int print_error_code(const char* message, icsneo_error_t error) {
|
|||
printf("%s: Failed to get string for error code %d with error code %d\n", message, error, res);
|
||||
return res;
|
||||
}
|
||||
printf("%s: %s\n", message, error_str);
|
||||
printf("%s: \"%s\" (%u)\n", message, error_str, error);
|
||||
return (int)error;
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +61,8 @@ int print_error_code(const char* message, icsneo_error_t error) {
|
|||
*/
|
||||
int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t messages_count);
|
||||
|
||||
void print_device_events(icsneo_device_t* device, const char* device_description);
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
|
@ -74,42 +76,46 @@ int main(int argc, char* argv[]) {
|
|||
};
|
||||
|
||||
printf("Found %u devices\n", devices_count);
|
||||
|
||||
// Loop over each device
|
||||
for (uint32_t i = 0; i < devices_count; i++) {
|
||||
icsneo_device_t* device = devices[i];
|
||||
|
||||
// Get description of the device
|
||||
const char description[255] = {0};
|
||||
uint32_t description_length = 255;
|
||||
res = icsneo_device_describe(device, description, &description_length);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to get device description", res);
|
||||
};
|
||||
// Get timestamp resolution of the device
|
||||
uint32_t timestamp_resolution = 0;
|
||||
res = icsneo_get_timestamp_resolution(device, ×tamp_resolution);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to get timestamp resolution", res);
|
||||
}
|
||||
printf("%s timestamp resolution: %uns\n", description, timestamp_resolution);
|
||||
|
||||
// Get/Set open options
|
||||
icsneo_open_options_t options = icsneo_open_options_none;
|
||||
res = icsneo_get_open_options(device, &options);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to get open options", res);
|
||||
}
|
||||
// Disable Syncing RTC
|
||||
options &= ~icsneo_open_options_sync_rtc;
|
||||
res = icsneo_set_open_options(device, options);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to set open options", res);
|
||||
}
|
||||
|
||||
// Open the device
|
||||
printf("Opening device: %s...\n", description);
|
||||
res = icsneo_open(device);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to open device", res);
|
||||
};
|
||||
|
||||
// Wait for the bus to collect some messages, requires an active bus to get messages
|
||||
printf("Waiting 1 second for messages...\n");
|
||||
sleep_ms(1000);
|
||||
|
|
@ -119,23 +125,72 @@ int main(int argc, char* argv[]) {
|
|||
printf("Getting messages from device with timeout of 3000ms on %s...\n", description);
|
||||
res = icsneo_get_messages(device, messages, &message_count, 3000);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to get messages from device", res);
|
||||
};
|
||||
// Process the messages
|
||||
res = process_messages(device, messages, message_count);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to process messages", res);
|
||||
}
|
||||
|
||||
// Finally, close the device.
|
||||
printf("Closing device: %s...\n", description);
|
||||
res = icsneo_close(device);
|
||||
if (res != icsneo_error_success) {
|
||||
print_device_events(device, description);
|
||||
return print_error_code("Failed to close device", res);
|
||||
};
|
||||
// Print device events
|
||||
print_device_events(device, description);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_device_events(icsneo_device_t* device, const char* device_description) {
|
||||
// Get device events
|
||||
icsneo_event_t* events[1024] = {0};
|
||||
uint32_t events_count = 1024;
|
||||
icsneo_error_t res = icsneo_device_get_events(device, events, &events_count);
|
||||
if (res != icsneo_error_success) {
|
||||
(void)print_error_code("Failed to get device events", res);
|
||||
return;
|
||||
}
|
||||
// Loop over each event and describe it.
|
||||
for (uint32_t i = 0; i < events_count; i++) {
|
||||
const char event_description[255] = {0};
|
||||
uint32_t event_description_length = 255;
|
||||
res = icsneo_event_get_description(events[i], event_description, &event_description_length);
|
||||
if (res != icsneo_error_success) {
|
||||
print_error_code("Failed to get event description", res);
|
||||
continue;
|
||||
}
|
||||
printf("\t%s: Event %u: %s\n", device_description, i, event_description);
|
||||
}
|
||||
|
||||
// Get global events
|
||||
icsneo_event_t* global_events[1024] = {0};
|
||||
uint32_t global_events_count = 1024;
|
||||
res = icsneo_get_events(global_events, &global_events_count);
|
||||
if (res != icsneo_error_success) {
|
||||
(void)print_error_code("Failed to get global events", res);
|
||||
return;
|
||||
}
|
||||
// Loop over each event and describe it.
|
||||
for (uint32_t i = 0; i < global_events_count; i++) {
|
||||
const char event_description[255] = {0};
|
||||
uint32_t event_description_length = 255;
|
||||
res = icsneo_event_get_description(global_events[i], event_description, &event_description_length);
|
||||
if (res != icsneo_error_success) {
|
||||
print_error_code("Failed to get global event description", res);
|
||||
continue;
|
||||
}
|
||||
printf("\t%s: Global Event %u: %s\n", device_description, i, event_description);
|
||||
}
|
||||
printf("%s: Received %u events and %u global events\n", device_description, events_count, global_events_count);
|
||||
}
|
||||
|
||||
int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t messages_count) {
|
||||
printf("Received %u messages\n", messages_count);
|
||||
// Print the type and bus type of each message
|
||||
|
|
@ -151,8 +206,35 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
|
|||
if (res != icsneo_error_success) {
|
||||
return print_error_code("Failed to get message bus type", res);
|
||||
}
|
||||
printf("%d Message type: %u bus type: %u\n", i, msg_type, bus_type);
|
||||
printf("\t%d) Message type: %u bus type: %u\n", i, msg_type, bus_type);
|
||||
if (bus_type == icsneo_msg_bus_type_can) {
|
||||
uint32_t arbid = 0;
|
||||
uint32_t dlc = 0;
|
||||
bool is_remote = false;
|
||||
bool is_canfd = false;
|
||||
bool is_extended = false;
|
||||
uint8_t data[64] = {0};
|
||||
uint32_t data_length = 64;
|
||||
uint32_t result = icsneo_can_message_arbid(device, message, &arbid);
|
||||
result += icsneo_can_message_dlc_on_wire(device, message, &dlc);
|
||||
result += icsneo_can_message_is_remote(device, message, &is_remote);
|
||||
result += icsneo_can_message_is_canfd(device, message, &is_canfd);
|
||||
result += icsneo_can_message_is_extended(device, message, &is_extended);
|
||||
result += icsneo_message_get_data(device, message, data, &data_length);
|
||||
if (result != icsneo_error_success) {
|
||||
printf("\tFailed get get CAN parameters (error: %u) for index %u\n", result, i);
|
||||
continue;
|
||||
}
|
||||
printf("\t ArbID: 0x%x\t DLC: %u\t Remote: %d\t CANFD: %d\t Extended: %d\t Data length: %u\n", arbid, dlc, is_remote, is_canfd, is_extended, data_length);
|
||||
printf("\t Data: [");
|
||||
for (uint32_t x = 0; x < data_length; x++) {
|
||||
printf(" 0x%x", data[x]);
|
||||
}
|
||||
printf(" ]\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,24 @@ extern "C" {
|
|||
typedef struct icsneo_device_t icsneo_device_t;
|
||||
|
||||
|
||||
/** @brief icsneo_message_t opaque struct definition
|
||||
*
|
||||
* This object represents a single event from the device.
|
||||
*
|
||||
* @see icsneo_device_get_events
|
||||
*/
|
||||
typedef struct icsneo_message_t icsneo_message_t;
|
||||
|
||||
|
||||
/** @brief icsneo_event_t opaque struct definition
|
||||
*
|
||||
* This object represents a single event from the device.
|
||||
*
|
||||
* @see icsneo_device_get_events
|
||||
*/
|
||||
typedef struct icsneo_event_t icsneo_event_t;
|
||||
|
||||
|
||||
/** @brief Error codes for icsneo functions.
|
||||
*
|
||||
* This enum is guaranteed to be ABI stable, any new values will be appended to the end.
|
||||
|
|
@ -312,6 +327,129 @@ ICSNEO_API icsneo_error_t icsneo_message_get_type(icsneo_device_t* device, icsne
|
|||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_message_get_bus_type(icsneo_device_t* device, icsneo_message_t* message, icsneo_msg_bus_type_t* bus_type);
|
||||
|
||||
/** @brief Get the data bytes of a message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] uint8_t* data Pointer to a uint8_t to copy the data bytes into.
|
||||
* @param[out] uint32_t* data_length Pointer to a uint32_t to copy the length of the data into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_message_get_data(icsneo_device_t* device, icsneo_message_t* message, uint8_t* data, uint32_t* data_length);
|
||||
|
||||
/** @brief Get the Arbitration ID of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] uint32_t* value Pointer to a uint32_t to copy the Arbitration ID into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_arbid(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value);
|
||||
|
||||
/** @brief Get the DLC on wire of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] uint32_t* value Pointer to a uint32_t to copy the DLC on wire into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_dlc_on_wire(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value);
|
||||
|
||||
/** @brief Get the remote status of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] bool* value Pointer to a uint32_t to copy the remote status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_remote(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
/** @brief Get the extended status of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] bool* value Pointer to a uint32_t to copy the extended status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_extended(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
/** @brief Get the CANFD status of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] bool* value Pointer to a uint32_t to copy the CANFD status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_is_canfd(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
/** @brief Get the baudrate switch status of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] bool* value Pointer to a uint32_t to copy the baudrate switch status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_baudrate_switch(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
/** @brief Get the error state indicator status of a CAN message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to check.
|
||||
* @param[out] bool* value Pointer to a uint32_t to copy the error state indicator status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_can_message_error_state_indicator(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
|
||||
/*
|
||||
uint32_t arbid;
|
||||
uint8_t dlcOnWire;
|
||||
bool isRemote = false; // Not allowed if CAN FD
|
||||
bool isExtended = false;
|
||||
bool isCANFD = false;
|
||||
bool baudrateSwitch = false; // CAN FD only
|
||||
bool errorStateIndicator = false; // CAN FD only
|
||||
*/
|
||||
|
||||
/** @brief Get the global events not specifically related to a device.
|
||||
*
|
||||
* @param[out] icsneo_event_t** events Pointer to an array of icsneo_event_t to copy the events into.
|
||||
* Undefined behaviour if index is out of range of events_count.
|
||||
* @param[in,out] uint32_t* events_count Size of the events array. Modified with the number of events found.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_get_events(icsneo_event_t** events, uint32_t* events_count);
|
||||
|
||||
/** @brief Get the events of a device.
|
||||
*
|
||||
* @param[in] icsneo_device_t device The device to get the events of.
|
||||
* @param[out] icsneo_event_t** events Pointer to an array of icsneo_event_t to copy the events into.
|
||||
* Undefined behaviour if index is out of range of events_count.
|
||||
* @param[in,out] uint32_t* events_count Size of the events array. Modified with the number of events found.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_device_get_events(icsneo_device_t* device, icsneo_event_t** events, uint32_t* events_count);
|
||||
|
||||
/** @brief Get the error string for an error code.
|
||||
*
|
||||
* @param[in] icsneo_event_t* event The event to get the description of.
|
||||
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
|
||||
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_event_get_description(icsneo_event_t* event, const char* value, uint32_t* value_length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue