Compare commits

...

11 Commits

Author SHA1 Message Date
David Rebbe 7e4c0cdc43 commonize the naming of the functions 2024-12-05 16:19:32 -05:00
David Rebbe a2feff5dbd rename icsneo_error_code 2024-12-05 16:11:53 -05:00
David Rebbe 9acd669feb add icsneo_is_online_supported 2024-12-05 16:10:32 -05:00
David Rebbe 82502db319 fixed naming 2024-12-05 15:14:32 -05:00
David Rebbe 36065fab05 python bindings build now. 2024-12-05 14:59:05 -05:00
David Rebbe 721c8b22d3 removed static_assert for now 2024-12-05 14:44:25 -05:00
David Rebbe dafcbac251 icsneopy fixes 2024-12-05 13:59:28 -05:00
David Rebbe 86992b2612 revert c++20 feature 2024-12-05 13:59:10 -05:00
David Rebbe 4308958f66 more renaming 2024-12-05 13:07:42 -05:00
David Rebbe d3c7a92f57 fixed some naming issues. 2024-12-05 12:01:39 -05:00
David Rebbe 3cdf9a341f memory optimizations 2024-12-05 11:42:55 -05:00
33 changed files with 312 additions and 305 deletions

View File

@ -33,7 +33,7 @@ typedef struct 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) {
ICSNEO_API icsneo_error_t icsneo_get_error_code(icsneo_error_t error_code, const char* value, uint32_t* value_length) {
if (!value || !value_length) {
return icsneo_error_invalid_parameters;
}
@ -90,7 +90,7 @@ ICSNEO_API icsneo_error_t icsneo_device_type_from_type(icsneo_devicetype_t devic
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_find(icsneo_device_t** devices, uint32_t* devices_count, void* reserved) {
ICSNEO_API icsneo_error_t icsneo_device_find_all(icsneo_device_t** devices, uint32_t* devices_count, void* reserved) {
if (!devices || !devices_count) {
return icsneo_error_invalid_parameters;
}
@ -136,7 +136,7 @@ ICSNEO_API icsneo_error_t icsneo_device_is_valid(icsneo_device_t* device) {
return !device->device ? icsneo_error_invalid_parameters : icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_get_open_options(icsneo_device_t* device, icsneo_open_options_t* options) {
ICSNEO_API icsneo_error_t icsneo_device_get_open_options(icsneo_device_t* device, icsneo_open_options_t* options) {
if (!device || !options) {
return icsneo_error_invalid_parameters;
}
@ -145,7 +145,7 @@ ICSNEO_API icsneo_error_t icsneo_get_open_options(icsneo_device_t* device, icsne
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_set_open_options(icsneo_device_t* device, icsneo_open_options_t options) {
ICSNEO_API icsneo_error_t icsneo_device_set_open_options(icsneo_device_t* device, icsneo_open_options_t options) {
if (!device) {
return icsneo_error_invalid_parameters;
}
@ -155,7 +155,7 @@ ICSNEO_API icsneo_error_t icsneo_set_open_options(icsneo_device_t* device, icsne
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_open(icsneo_device_t* device) {
ICSNEO_API icsneo_error_t icsneo_device_open(icsneo_device_t* device) {
if (!device || !device->device) {
return icsneo_error_invalid_parameters;
}
@ -188,7 +188,7 @@ ICSNEO_API icsneo_error_t icsneo_open(icsneo_device_t* device) {
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_close(icsneo_device_t* device) {
ICSNEO_API icsneo_error_t icsneo_device_close(icsneo_device_t* device) {
if (!device || !device->device) {
return icsneo_error_invalid_parameters;
}
@ -197,12 +197,15 @@ ICSNEO_API icsneo_error_t icsneo_close(icsneo_device_t* device) {
return icsneo_error_success;
}
dev->close();
// Clear out old messages
// Clear out old messages and events
device->messages.clear();
device->messages.shrink_to_fit();
device->events.clear();
device->events.shrink_to_fit();
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_device_describe(icsneo_device_t* device, const char* value, uint32_t* value_length) {
ICSNEO_API icsneo_error_t icsneo_device_get_description(icsneo_device_t* device, const char* value, uint32_t* value_length) {
if (!device || !device->device) {
return icsneo_error_invalid_parameters;
}
@ -216,7 +219,7 @@ ICSNEO_API icsneo_error_t icsneo_device_describe(icsneo_device_t* device, const
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_device_type(icsneo_device_t* device, icsneo_devicetype_t* value) {
ICSNEO_API icsneo_error_t icsneo_device_get_type(icsneo_device_t* device, icsneo_devicetype_t* value) {
if (!device || !device->device) {
return icsneo_error_invalid_parameters;
}
@ -226,7 +229,7 @@ ICSNEO_API icsneo_error_t icsneo_device_type(icsneo_device_t* device, icsneo_dev
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_device_serial(icsneo_device_t* device, const char* value, uint32_t* value_length) {
ICSNEO_API icsneo_error_t icsneo_device_get_serial(icsneo_device_t* device, const char* value, uint32_t* value_length) {
if (!device || !device->device) {
return icsneo_error_invalid_parameters;
}
@ -241,7 +244,7 @@ ICSNEO_API icsneo_error_t icsneo_device_serial(icsneo_device_t* device, const ch
}
ICSNEO_API icsneo_error_t icsneo_go_online(icsneo_device_t* device, bool go_online) {
ICSNEO_API icsneo_error_t icsneo_device_go_online(icsneo_device_t* device, bool go_online) {
if (!device) {
return icsneo_error_invalid_parameters;
}
@ -258,7 +261,7 @@ ICSNEO_API icsneo_error_t icsneo_go_online(icsneo_device_t* device, bool go_onli
return icsneo_error_go_online_failed;
}
ICSNEO_API icsneo_error_t icsneo_is_online(icsneo_device_t* device, bool* is_online) {
ICSNEO_API icsneo_error_t icsneo_device_is_online(icsneo_device_t* device, bool* is_online) {
if (!device || !is_online) {
return icsneo_error_invalid_parameters;
}
@ -268,7 +271,17 @@ ICSNEO_API icsneo_error_t icsneo_is_online(icsneo_device_t* device, bool* is_onl
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_set_message_polling(icsneo_device_t* device, bool enable) {
ICSNEO_API icsneo_error_t icsneo_device_is_online_supported(icsneo_device_t* device, bool* is_online_supported) {
if (!device || !is_online_supported) {
return icsneo_error_invalid_parameters;
}
auto dev = device->device;
*is_online_supported = dev->isOnlineSupported();
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_device_set_message_polling(icsneo_device_t* device, bool enable) {
if (!device) {
return icsneo_error_invalid_parameters;
}
@ -285,7 +298,7 @@ ICSNEO_API icsneo_error_t icsneo_set_message_polling(icsneo_device_t* device, bo
return icsneo_error_enable_message_polling_failed;
}
ICSNEO_API icsneo_error_t icsneo_get_message_polling(icsneo_device_t* device, bool* is_enabled) {
ICSNEO_API icsneo_error_t icsneo_device_get_message_polling(icsneo_device_t* device, bool* is_enabled) {
if (!device || !is_enabled) {
return icsneo_error_invalid_parameters;
}
@ -295,7 +308,7 @@ ICSNEO_API icsneo_error_t icsneo_get_message_polling(icsneo_device_t* device, bo
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_set_message_polling_limit(icsneo_device_t* device, uint32_t limit) {
ICSNEO_API icsneo_error_t icsneo_device_set_message_polling_limit(icsneo_device_t* device, uint32_t limit) {
if (!device) {
return icsneo_error_invalid_parameters;
}
@ -305,7 +318,7 @@ ICSNEO_API icsneo_error_t icsneo_set_message_polling_limit(icsneo_device_t* devi
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_get_message_polling_limit(icsneo_device_t* device, uint32_t* limit) {
ICSNEO_API icsneo_error_t icsneo_device_get_message_polling_limit(icsneo_device_t* device, uint32_t* limit) {
if (!device || !limit) {
return icsneo_error_invalid_parameters;
}
@ -315,7 +328,7 @@ ICSNEO_API icsneo_error_t icsneo_get_message_polling_limit(icsneo_device_t* devi
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_get_message_count(icsneo_device_t* device, uint32_t* count) {
ICSNEO_API icsneo_error_t icsneo_device_get_message_count(icsneo_device_t* device, uint32_t* count) {
if (!device || !count) {
return icsneo_error_invalid_parameters;
}
@ -325,7 +338,7 @@ ICSNEO_API icsneo_error_t icsneo_get_message_count(icsneo_device_t* device, uint
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_get_timestamp_resolution(icsneo_device_t* device, uint32_t* resolution) {
ICSNEO_API icsneo_error_t icsneo_device_get_timestamp_resolution(icsneo_device_t* device, uint32_t* resolution) {
if (!device || !resolution) {
return icsneo_error_invalid_parameters;
}
@ -335,7 +348,7 @@ ICSNEO_API icsneo_error_t icsneo_get_timestamp_resolution(icsneo_device_t* devic
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t* messages_count, uint32_t timeout_ms) {
ICSNEO_API icsneo_error_t icsneo_device_get_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t* messages_count, uint32_t timeout_ms) {
if (!device || !messages || !messages_count) {
return icsneo_error_invalid_parameters;
}
@ -369,7 +382,7 @@ ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_me
message_t->message = message;
device->messages.push_back(message_t);
}
device->messages.shrink_to_fit();
// Copy the messages into the output array
for (uint32_t i = 0; i < min_size; i++) {
messages[i] = device->messages[i].get();
@ -378,7 +391,7 @@ ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_me
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_is_message_valid(icsneo_device_t* device, icsneo_message_t* message, bool* is_valid) {
ICSNEO_API icsneo_error_t icsneo_message_is_valid(icsneo_device_t* device, icsneo_message_t* message, bool* is_valid) {
if (!device || !message || !is_valid) {
return icsneo_error_invalid_parameters;
}
@ -441,7 +454,7 @@ ICSNEO_API icsneo_error_t icsneo_message_get_data(icsneo_device_t* device, icsne
}
ICSNEO_API icsneo_error_t icsneo_can_message_arbid(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value) {
ICSNEO_API icsneo_error_t icsneo_can_message_get_arbid(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value) {
if (!device || !message || !value) {
return icsneo_error_invalid_parameters;
}
@ -457,7 +470,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_arbid(icsneo_device_t* device, icsn
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) {
ICSNEO_API icsneo_error_t icsneo_can_message_get_dlc_on_wire(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value) {
if (!device || !message || !value) {
return icsneo_error_invalid_parameters;
}
@ -521,7 +534,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_is_canfd(icsneo_device_t* device, i
return icsneo_error_success;
}
ICSNEO_API icsneo_error_t icsneo_can_message_baudrate_switch(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
ICSNEO_API icsneo_error_t icsneo_can_message_get_baudrate_switch(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
if (!device || !message || !value) {
return icsneo_error_invalid_parameters;
}
@ -537,7 +550,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_baudrate_switch(icsneo_device_t* de
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) {
ICSNEO_API icsneo_error_t icsneo_can_message_get_error_state_indicator(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
if (!device || !message || !value) {
return icsneo_error_invalid_parameters;
}
@ -567,10 +580,11 @@ ICSNEO_API icsneo_error_t icsneo_get_events(icsneo_event_t** events, uint32_t* e
// 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],
global_events[i],
};
g_events.push_back(e);
}
g_events.shrink_to_fit();
// Copy the global events references into the events array
for (uint32_t i = 0; i < min_size; i++) {
events[i] = &g_events[i];
@ -599,10 +613,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_events(icsneo_device_t* device, icsn
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[i],
};
device->events.push_back(e);
}
device->events.shrink_to_fit();
// Copy the device events references into the events array
for (uint32_t i = 0; i < min_size; i++) {
events[i] = &device->events[i];

View File

@ -83,21 +83,21 @@ static bool NeoMessageToSpyMessage(const neodevice_t* device, const neomessage_t
switch (Network::Type(frame.type))
{
case Network::Type::CAN:
case Network::Type::SWCAN:
case Network::Type::LSFTCAN:
case icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_lsftcan:
oldmsg.Protocol = frame.status.canfdFDF ? SPY_PROTOCOL_CANFD : SPY_PROTOCOL_CAN;
oldmsg.NumberBytesData = static_cast<uint8_t>(std::min(frame.length, (size_t)255));
oldmsg.NumberBytesHeader = 4;
copyFrameData();
break;
case Network::Type::Ethernet:
case icsneo_msg_bus_type_ethernet:
oldmsg.Protocol = SPY_PROTOCOL_ETHERNET;
oldmsg.NumberBytesData = static_cast<uint8_t>(frame.length & 0xFF);
oldmsg.NumberBytesHeader = static_cast<uint8_t>(frame.length >> 8);
copyFrameData();
break;
case Network::Type::LIN:
case icsneo_msg_bus_type_lin:
{
const neomessage_lin_t& linFrame = *reinterpret_cast<const neomessage_lin_t*>(&frame);
icsSpyMessageJ1850& linSpyMsg = *reinterpret_cast<icsSpyMessageJ1850*>(&oldmsg);

View File

@ -7,7 +7,7 @@
namespace icsneo {
void init_canmessage(pybind11::module_& m) {
pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, Frame>(m, "CANMessage")
pybind11::class_<CANMessage, std::shared_ptr<CANMessage>, BusMessage>(m, "CANMessage")
.def(pybind11::init())
.def_readwrite("arbid", &CANMessage::arbid)
.def_readwrite("dlcOnWire", &CANMessage::dlcOnWire)

View File

@ -11,7 +11,7 @@ void init_ethernetmessage(pybind11::module_& m) {
.def("to_string", &MACAddress::toString)
.def("__repr__", &MACAddress::toString);
pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, Frame>(m, "EthernetMessage")
pybind11::class_<EthernetMessage, std::shared_ptr<EthernetMessage>, BusMessage>(m, "EthernetMessage")
.def(pybind11::init())
.def_readwrite("preemptionEnabled", &EthernetMessage::preemptionEnabled)
.def_readwrite("preemptionFlags", &EthernetMessage::preemptionFlags)

View File

@ -7,7 +7,7 @@
namespace icsneo {
void init_mdiomessage(pybind11::module_& m) {
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, Frame> mdioMessage(m, "MDIOMessage");
pybind11::class_<MDIOMessage, std::shared_ptr<MDIOMessage>, BusMessage> mdioMessage(m, "MDIOMessage");
pybind11::enum_<MDIOMessage::Clause>(mdioMessage, "Clause")
.value("Clause45", MDIOMessage::Clause::Clause45)
.value("Clause22", MDIOMessage::Clause::Clause22);

View File

@ -9,12 +9,12 @@ namespace icsneo {
void init_message(pybind11::module_& m) {
pybind11::class_<Message, std::shared_ptr<Message>> message(m, "Message");
pybind11::enum_<Message::Type>(message, "Type")
.value("Frame", Message::Type::Frame)
.value("BusMessage", Message::Type::BusMessage)
.value("CANErrorCount", Message::Type::CANErrorCount)
.value("LINHeaderOnly", Message::Type::LINHeaderOnly)
.value("LINBreak", Message::Type::LINBreak)
.value("Invalid", Message::Type::Invalid)
.value("RawMessage", Message::Type::RawMessage)
.value("InternalMessage", Message::Type::InternalMessage)
.value("ReadSettings", Message::Type::ReadSettings)
.value("ResetStatus", Message::Type::ResetStatus)
.value("DeviceVersion", Message::Type::DeviceVersion)
@ -37,14 +37,14 @@ void init_message(pybind11::module_& m) {
message.def_readonly("type", &Message::type);
message.def_readwrite("timestamp", &Message::timestamp);
pybind11::class_<RawMessage, std::shared_ptr<RawMessage>, Message>(m, "RawMessage")
.def_readwrite("network", &RawMessage::network)
.def_readwrite("data", &RawMessage::data);
pybind11::class_<InternalMessage, std::shared_ptr<InternalMessage>, Message>(m, "InternalMessage")
.def_readwrite("network", &InternalMessage::network)
.def_readwrite("data", &InternalMessage::data);
pybind11::class_<Frame, std::shared_ptr<Frame>, RawMessage>(m, "Frame")
.def_readwrite("description", &Frame::description)
.def_readwrite("transmitted", &Frame::transmitted)
.def_readwrite("error", &Frame::error);
pybind11::class_<BusMessage, std::shared_ptr<BusMessage>, InternalMessage>(m, "BusMessage")
.def_readwrite("description", &BusMessage::description)
.def_readwrite("transmitted", &BusMessage::transmitted)
.def_readwrite("error", &BusMessage::error);
}
} // namespace icsneo

View File

@ -26,7 +26,7 @@ void init_device(pybind11::module_& m) {
.def("set_polling_message_limit", &Device::setPollingMessageLimit)
.def("add_message_callback", &Device::addMessageCallback)
.def("remove_message_callback", &Device::removeMessageCallback)
.def("transmit", pybind11::overload_cast<std::shared_ptr<Frame>>(&Device::transmit))
.def("transmit", pybind11::overload_cast<std::shared_ptr<BusMessage>>(&Device::transmit))
.def("get_supported_rx_networks", &Device::getSupportedRXNetworks, pybind11::return_value_policy::reference)
.def("get_supported_tx_networks", &Device::getSupportedTXNetworks, pybind11::return_value_policy::reference)
.def("get_rtc", &Device::getRTC)

View File

@ -3,72 +3,68 @@
#include <pybind11/functional.h>
#include <icsneo/device/devicetype.h>
#include <icsneo/icsneotypes.h>
namespace icsneo {
void init_devicetype(pybind11::module_& m) {
pybind11::class_<DeviceType> deviceType(m, "DeviceType");
pybind11::enum_<icsneo_devicetype_t>(deviceType, "Enum")
.value("Unknown", _icsneo_devicetype_t::Unknown)
.value("BLUE", _icsneo_devicetype_t::BLUE)
.value("ECU_AVB", _icsneo_devicetype_t::ECU_AVB)
.value("RADSupermoon", _icsneo_devicetype_t::RADSupermoon)
.value("DW_VCAN", _icsneo_devicetype_t::DW_VCAN)
.value("RADMoon2", _icsneo_devicetype_t::RADMoon2)
.value("RADMars", _icsneo_devicetype_t::RADMars)
.value("VCAN4_1", _icsneo_devicetype_t::VCAN4_1)
.value("FIRE", _icsneo_devicetype_t::FIRE)
.value("RADPluto", _icsneo_devicetype_t::RADPluto)
.value("VCAN4_2EL", _icsneo_devicetype_t::VCAN4_2EL)
.value("RADIO_CANHUB", _icsneo_devicetype_t::RADIO_CANHUB)
.value("NEOECU12", _icsneo_devicetype_t::NEOECU12)
.value("OBD2_LCBADGE", _icsneo_devicetype_t::OBD2_LCBADGE)
.value("RADMoonDuo", _icsneo_devicetype_t::RADMoonDuo)
.value("FIRE3", _icsneo_devicetype_t::FIRE3)
.value("VCAN3", _icsneo_devicetype_t::VCAN3)
.value("RADJupiter", _icsneo_devicetype_t::RADJupiter)
.value("VCAN4_IND", _icsneo_devicetype_t::VCAN4_IND)
.value("RADGigastar", _icsneo_devicetype_t::RADGigastar)
.value("RED2", _icsneo_devicetype_t::RED2)
.value("EtherBADGE", _icsneo_devicetype_t::EtherBADGE)
.value("RAD_A2B", _icsneo_devicetype_t::RAD_A2B)
.value("RADEpsilon", _icsneo_devicetype_t::RADEpsilon)
.value("RADMoon3", _icsneo_devicetype_t::RADMoon3)
.value("RADComet", _icsneo_devicetype_t::RADComet)
.value("FIRE3_FlexRay", _icsneo_devicetype_t::FIRE3_FlexRay)
.value("Connect", _icsneo_devicetype_t::Connect)
.value("RADComet3", _icsneo_devicetype_t::RADComet3)
.value("RADMoonT1S", _icsneo_devicetype_t::RADMoonT1S)
.value("RADGigastar2", _icsneo_devicetype_t::RADGigastar2)
.value("RED", _icsneo_devicetype_t::RED)
.value("ECU", _icsneo_devicetype_t::ECU)
.value("IEVB", _icsneo_devicetype_t::IEVB)
.value("Pendant", _icsneo_devicetype_t::Pendant)
.value("OBD2_PRO", _icsneo_devicetype_t::OBD2_PRO)
.value("ECUChip_UART", _icsneo_devicetype_t::ECUChip_UART)
.value("PLASMA", _icsneo_devicetype_t::PLASMA)
.value("DONT_REUSE0", _icsneo_devicetype_t::DONT_REUSE0)
.value("NEOAnalog", _icsneo_devicetype_t::NEOAnalog)
.value("CT_OBD", _icsneo_devicetype_t::CT_OBD)
.value("DONT_REUSE1", _icsneo_devicetype_t::DONT_REUSE1)
.value("DONT_REUSE2", _icsneo_devicetype_t::DONT_REUSE2)
.value("ION", _icsneo_devicetype_t::ION)
.value("RADStar", _icsneo_devicetype_t::RADStar)
.value("DONT_REUSE3", _icsneo_devicetype_t::DONT_REUSE3)
.value("VCAN4_4", _icsneo_devicetype_t::VCAN4_4)
.value("VCAN4_2", _icsneo_devicetype_t::VCAN4_2)
.value("CMProbe", _icsneo_devicetype_t::CMProbe)
.value("EEVB", _icsneo_devicetype_t::EEVB)
.value("VCANrf", _icsneo_devicetype_t::VCANrf)
.value("FIRE2", _icsneo_devicetype_t::FIRE2)
.value("Flex", _icsneo_devicetype_t::Flex)
.value("RADGalaxy", _icsneo_devicetype_t::RADGalaxy)
.value("RADStar2", _icsneo_devicetype_t::RADStar2)
.value("VividCAN", _icsneo_devicetype_t::VividCAN)
.value("OBD2_SIM", _icsneo_devicetype_t::OBD2_SIM);
deviceType.def(pybind11::init<icsneo_devicetype_t>());
deviceType.def("get_device_type", &_icsneo_devicetype_t::getDeviceType);
deviceType.def("get_generic_product_name", &_icsneo_devicetype_t::getGenericProductName);
deviceType.def("get_device_type", &DeviceType::getDeviceType);
deviceType.def(
"get_generic_product_name", [](DeviceType &self) -> std::string {
return self.getGenericProductName(self.getDeviceType());
});
pybind11::enum_<_icsneo_devicetype_t>(m, "icsneo_devicetype_t")
.value("unknown", icsneo_devicetype_unknown)
.value("blue", icsneo_devicetype_blue)
.value("ecu_avb", icsneo_devicetype_ecu_avb)
.value("rad_supermoon", icsneo_devicetype_rad_supermoon)
.value("dw_vcan", icsneo_devicetype_dw_vcan)
.value("rad_moon2", icsneo_devicetype_rad_moon2)
.value("rad_mars", icsneo_devicetype_rad_mars)
.value("vcan41", icsneo_devicetype_vcan41)
.value("fire", icsneo_devicetype_fire)
.value("rad_pluto", icsneo_devicetype_rad_pluto)
.value("vcan42_el", icsneo_devicetype_vcan42_el)
.value("radio_canhub", icsneo_devicetype_radio_canhub)
.value("neo_ecu12", icsneo_devicetype_neo_ecu12)
.value("obd2_lc_badge", icsneo_devicetype_obd2_lc_badge)
.value("rad_moon_duo", icsneo_devicetype_rad_moon_duo)
.value("fire3", icsneo_devicetype_fire3)
.value("vcan3", icsneo_devicetype_vcan3)
.value("rad_jupiter", icsneo_devicetype_rad_jupiter)
.value("vcan4_industrial", icsneo_devicetype_vcan4_industrial)
.value("rad_gigastar", icsneo_devicetype_rad_gigastar)
.value("red2", icsneo_devicetype_red2)
.value("etherbadge", icsneo_devicetype_etherbadge)
.value("rad_a2b", icsneo_devicetype_rad_a2b)
.value("rad_epsilon", icsneo_devicetype_rad_epsilon)
.value("rad_moon3", icsneo_devicetype_rad_moon3)
.value("rad_comet", icsneo_devicetype_rad_comet)
.value("fire3_flexray", icsneo_devicetype_fire3_flexray)
.value("connect", icsneo_devicetype_connect)
.value("rad_comet3", icsneo_devicetype_rad_comet3)
.value("rad_moon_t1s", icsneo_devicetype_rad_moon_t1s)
.value("rad_gigastar2", icsneo_devicetype_rad_gigastar2)
.value("red", icsneo_devicetype_red)
.value("ecu", icsneo_devicetype_ecu)
.value("ievb", icsneo_devicetype_ievb)
.value("pendant", icsneo_devicetype_pendant)
.value("obd2_pro", icsneo_devicetype_obd2_pro)
.value("plasma", icsneo_devicetype_plasma)
.value("ion", icsneo_devicetype_ion)
.value("rad_star", icsneo_devicetype_rad_star)
.value("vcan44", icsneo_devicetype_vcan44)
.value("vcan42", icsneo_devicetype_vcan42)
.value("cm_probe", icsneo_devicetype_cm_probe)
.value("eevb", icsneo_devicetype_eevb)
.value("fire2", icsneo_devicetype_fire2)
.value("flex", icsneo_devicetype_flex)
.value("rad_galaxy", icsneo_devicetype_rad_galaxy)
.value("rad_star2", icsneo_devicetype_rad_star2)
.value("vividcan", icsneo_devicetype_vividcan)
.value("obd2_sim", icsneo_devicetype_obd2_sim);
}
} // namespace icsneo

View File

@ -54,7 +54,7 @@ uint64_t Decoder::GetUInt64FromLEBytes(const uint8_t* bytes) {
bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Packet>& packet) {
switch(packet->network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
result = HardwareEthernetPacket::DecodeToMessage(packet->data, report);
if(!result) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
@ -68,9 +68,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
eth.network = packet->network;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
case icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_lsftcan: {
if(packet->data.size() < 24) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
return false;
@ -87,7 +87,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
result->timestamp *= timestampResolution;
switch(result->type) {
case Message::Type::Frame: {
case Message::Type::BusMessage: {
CANMessage& can = *static_cast<CANMessage*>(result.get());
can.network = packet->network;
break;
@ -105,7 +105,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_flexray: {
case icsneo_msg_bus_type_flexray: {
if(packet->data.size() < 24) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
return false;
@ -124,7 +124,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
fr.network = packet->network;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141: {
case icsneo_msg_bus_type_iso9141: {
if(packet->data.size() < sizeof(HardwareISO9141Packet)) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
return false;
@ -141,7 +141,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
iso.network = packet->network;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_i2c: {
case icsneo_msg_bus_type_i2c: {
if(packet->data.size() < sizeof(HardwareI2CPacket)) {
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
return false;
@ -155,7 +155,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b: {
case icsneo_msg_bus_type_a2b: {
result = HardwareA2BPacket::DecodeToMessage(packet->data);
if(!result) {
@ -168,7 +168,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
msg.timestamp *= timestampResolution;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
result = HardwareLINPacket::DecodeToMessage(packet->data);
if(!result) {
@ -180,7 +180,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
msg.network = packet->network;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_mdio: {
case icsneo_msg_bus_type_mdio: {
result = HardwareMDIOPacket::DecodeToMessage(packet->data);
if(!result) {
@ -192,7 +192,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
msg.network = packet->network;
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_internal: {
case icsneo_msg_bus_type_internal: {
switch(packet->network.getNetID()) {
case Network::NetID::Reset_Status: {
// We can deal with not having the last two fields (voltage and temperature)
@ -308,7 +308,7 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
result = TC10StatusMessage::DecodeToMessage(packet->data);
return true;
default:
// No defined handler, treat this as a RawMessage
// No defined handler, treat this as a InternalMessage
break;
}
break;

View File

@ -23,15 +23,15 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
result.clear();
switch(message->type) {
case Message::Type::Frame: {
case Message::Type::BusMessage: {
auto frame = std::dynamic_pointer_cast<BusMessage>(message);
// Frame uses frame->data as the buffer unless directed otherwise
// BusMessage uses frame->data as the buffer unless directed otherwise
buffer = &frame->data;
netid = uint16_t(frame->network.getNetID());
switch(frame->network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
auto ethmsg = std::dynamic_pointer_cast<EthernetMessage>(message);
if(!ethmsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -43,10 +43,10 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false;
break;
} // End of Network::Type::Ethernet
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
} // End of icsneo_msg_bus_type_ethernet
case icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_lsftcan: {
auto canmsg = std::dynamic_pointer_cast<CANMessage>(message);
if(!canmsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -63,8 +63,8 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false; // The CANMessage was malformed
break;
} // End of Network::Type::CAN
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141: {
} // End of icsneo_msg_bus_type_can
case icsneo_msg_bus_type_iso9141: {
auto isomsg = std::dynamic_pointer_cast<ISO9141Message>(message);
if(!isomsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -74,8 +74,8 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
// Skip the normal message wrapping at the bottom since we need to send multiple
// packets to the device. This function just encodes them back to back into `result`
return HardwareISO9141Packet::EncodeFromMessage(*isomsg, result, report, packetizer);
} // End of Network::Type::ISO9141
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b: {
} // End of icsneo_msg_bus_type_iso9141
case icsneo_msg_bus_type_a2b: {
auto a2bmsg = std::dynamic_pointer_cast<A2BMessage>(message);
if(!a2bmsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -86,8 +86,8 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false;
}
break;
} // End of Network::Type::A2B
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_i2c: {
} // End of icsneo_msg_bus_type_a2b
case icsneo_msg_bus_type_i2c: {
auto i2cmsg = std::dynamic_pointer_cast<I2CMessage>(message);
if(!i2cmsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -98,8 +98,8 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false;
}
break;
} // End of Network::Type::I2C
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
} // End of icsneo_msg_bus_type_i2c
case icsneo_msg_bus_type_lin: {
auto linmsg = std::dynamic_pointer_cast<LINMessage>(message);
if(!linmsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -110,8 +110,8 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false;
}
break;
} // End of Network::Type::LIN
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_mdio: {
} // End of icsneo_msg_bus_type_lin
case icsneo_msg_bus_type_mdio: {
auto mdiomsg = std::dynamic_pointer_cast<MDIOMessage>(message);
if(!mdiomsg) {
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
@ -122,7 +122,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
return false;
}
break;
} // End of Network::Type::MDIO
} // End of icsneo_msg_bus_type_mdio
default:
report(APIEvent::Type::UnexpectedNetworkType, APIEvent::Severity::Error);
return false;
@ -130,7 +130,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
break;
}
case Message::Type::RawMessage: {
case Message::Type::InternalMessage: {
auto raw = std::dynamic_pointer_cast<InternalMessage>(message);
// Raw message uses raw->data as the buffer unless directed otherwise

View File

@ -102,7 +102,7 @@ bool A2BWAVOutput::callIfMatch(const std::shared_ptr<Message>& message) const {
return false;
}
if(message->type != Message::Type::Frame) {
if(message->type != Message::Type::BusMessage) {
return false;
}
@ -112,7 +112,7 @@ bool A2BWAVOutput::callIfMatch(const std::shared_ptr<Message>& message) const {
return false;
}
if(frameMsg->network.getType() != _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b)
if(frameMsg->network.getType() != icsneo_msg_bus_type_a2b)
return false;
const auto& a2bMsg = std::dynamic_pointer_cast<A2BMessage>(frameMsg);

View File

@ -14,7 +14,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
neomsg.timestamp = message->timestamp;
switch (message->type)
{
case Message::Type::Frame: {
case Message::Type::BusMessage: {
neomessage_frame_t& frame = *(neomessage_frame_t*)&neomsg;
auto framemsg = std::static_pointer_cast<BusMessage>(message);
const auto netType = framemsg->network.getType();
@ -29,9 +29,9 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
frame.status.transmitMessage = framemsg->transmitted;
switch(netType) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
case icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_lsftcan: {
neomessage_can_t& can = *(neomessage_can_t*)&neomsg;
auto canmsg = std::static_pointer_cast<CANMessage>(message);
can.arbid = canmsg->arbid;
@ -44,7 +44,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
can.status.canfdESI = canmsg->errorStateIndicator;
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
neomessage_eth_t& eth = *(neomessage_eth_t*)&neomsg;
auto ethmsg = std::static_pointer_cast<EthernetMessage>(message);
eth.preemptionFlags = ethmsg->preemptionFlags;
@ -55,7 +55,7 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
//eth.status.xyz = ethmsg->noPadding;
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
neomessage_lin_t& lin = *(neomessage_lin_t*)&neomsg;
auto linmsg = std::static_pointer_cast<LINMessage>(message);
if(!linmsg) { break; }
@ -120,12 +120,12 @@ neomessage_t icsneo::CreateNeoMessage(const std::shared_ptr<Message> message) {
std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t* neomessage) {
switch((Message::Type)neomessage->messageType) {
case Message::Type::Frame: {
case Message::Type::BusMessage: {
const Network network = ((neomessage_frame_t*)neomessage)->netid;
switch(network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan:
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
case icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_lsftcan: {
neomessage_can_t& can = *(neomessage_can_t*)neomessage;
auto canmsg = std::make_shared<CANMessage>();
canmsg->network = network;
@ -140,7 +140,7 @@ std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t*
canmsg->errorStateIndicator = can.status.canfdESI;
return canmsg;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
neomessage_eth_t& eth = *(neomessage_eth_t*)neomessage;
auto ethmsg = std::make_shared<EthernetMessage>();
ethmsg->network = network;
@ -148,7 +148,7 @@ std::shared_ptr<Message> icsneo::CreateMessageFromNeoMessage(const neomessage_t*
ethmsg->data.insert(ethmsg->data.end(), eth.data, eth.data + eth.length);
return ethmsg;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
neomessage_lin_t& lin = *(neomessage_lin_t*)neomessage;
auto linmsg = std::make_shared<LINMessage>();
linmsg->network = network;

View File

@ -69,7 +69,7 @@ std::shared_ptr<Message> HardwareCANPacket::DecodeToMessage(const std::vector<ui
return msg;
} else { // CAN Frame
} else { // CAN BusMessage
auto msg = std::make_shared<CANMessage>();
// Arb ID
@ -104,7 +104,7 @@ std::shared_ptr<Message> HardwareCANPacket::DecodeToMessage(const std::vector<ui
// Data
// The first 8 bytes are always in the standard place
if((data->dlc.RTR && data->header.IDE) || (!data->header.IDE && data->header.SRR)) { // Remote Request Frame
if((data->dlc.RTR && data->header.IDE) || (!data->header.IDE && data->header.SRR)) { // Remote Request BusMessage
msg->data.resize(length); // This data will be all zeros, but the length will be set
msg->isRemote = true;
} else {
@ -197,7 +197,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector
// Status and DLC bits
if(message.isCANFD) {
result.push_back(0x0F); // FD Frame
result.push_back(0x0F); // FD BusMessage
uint8_t fdStatusByte = *dlc;
if(message.baudrateSwitch)
fdStatusByte |= 0x80; // BRS status bit

View File

@ -1718,11 +1718,11 @@ void Device::handleInternalMessage(std::shared_ptr<Message> message) {
case Message::Type::ResetStatus:
latestResetStatus = std::static_pointer_cast<ResetStatusMessage>(message);
break;
case Message::Type::RawMessage: {
case Message::Type::InternalMessage: {
auto rawMessage = std::static_pointer_cast<InternalMessage>(message);
switch(rawMessage->network.getNetID()) {
case Network::NetID::Device: {
// Device is not guaranteed to be a CANMessage, it might be a RawMessage
// Device is not guaranteed to be a CANMessage, it might be a InternalMessage
// if it couldn't be decoded to a CANMessage. We only care about the
// CANMessage decoding right now.
auto canmsg = std::dynamic_pointer_cast<CANMessage>(message);

View File

@ -49,7 +49,7 @@ void FlexRay::Extension::handleMessage(const std::shared_ptr<Message>& message)
}
bool FlexRay::Extension::transmitHook(const std::shared_ptr<BusMessage>& frame, bool& success) {
if(!frame || frame->network.getType() != _icsneo_msg_bus_type_t::icsneo_msg_bus_type_flexray)
if(!frame || frame->network.getType() != icsneo_msg_bus_type_flexray)
return true; // Don't hook non-FlexRay messages
success = false;

View File

@ -403,7 +403,7 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
const CAN_SETTINGS* cfg = getCANSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::CANSettingsNotAvailable, APIEvent::Severity::Error);
@ -417,7 +417,7 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const {
}
return baudrate;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan: {
case icsneo_msg_bus_type_swcan: {
const SWCAN_SETTINGS* cfg = getSWCANSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::SWCANSettingsNotAvailable, APIEvent::Severity::Error);
@ -431,7 +431,7 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const {
}
return baudrate;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
case icsneo_msg_bus_type_lsftcan: {
const CAN_SETTINGS* cfg = getLSFTCANSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LSFTCANSettingsNotAvailable, APIEvent::Severity::Error);
@ -445,7 +445,7 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const {
}
return baudrate;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
const LIN_SETTINGS* cfg = getLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -477,7 +477,7 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
if(baudrate > 1000000) { // This is an FD baudrate. Use setFDBaudrateFor instead.
report(APIEvent::Type::CANFDSettingsNotAvailable, APIEvent::Severity::Error);
return false;
@ -499,7 +499,7 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan: {
case icsneo_msg_bus_type_lsftcan: {
CAN_SETTINGS* cfg = getMutableLSFTCANSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LSFTCANSettingsNotAvailable, APIEvent::Severity::Error);
@ -516,7 +516,7 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan: {
case icsneo_msg_bus_type_swcan: {
SWCAN_SETTINGS* cfg = getMutableSWCANSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::SWCANSettingsNotAvailable, APIEvent::Severity::Error);
@ -533,7 +533,7 @@ bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
return true;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
LIN_SETTINGS* cfg = getMutableLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -566,7 +566,7 @@ int64_t IDeviceSettings::getFDBaudrateFor(Network net) const {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
const CANFD_SETTINGS* cfg = getCANFDSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::CANFDSettingsNotAvailable, APIEvent::Severity::Error);
@ -604,7 +604,7 @@ bool IDeviceSettings::setFDBaudrateFor(Network net, int64_t baudrate) {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
CANFD_SETTINGS* cfg = getMutableCANFDSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::CANFDSettingsNotAvailable, APIEvent::Severity::Error);
@ -771,7 +771,7 @@ std::optional<bool> IDeviceSettings::isCommanderResistorEnabledFor(Network net)
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
const LIN_SETTINGS* cfg = getLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -803,7 +803,7 @@ bool IDeviceSettings::setCommanderResistorFor(Network net, bool resistor_on) {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
LIN_SETTINGS* cfg = getMutableLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -831,7 +831,7 @@ std::optional<LINMode> IDeviceSettings::getLINModeFor(Network net) const {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
const LIN_SETTINGS* cfg = getLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -863,7 +863,7 @@ bool IDeviceSettings::setLINModeFor(Network net, LINMode mode) {
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
LIN_SETTINGS* cfg = getMutableLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -891,7 +891,7 @@ std::optional<uint8_t> IDeviceSettings::getLINCommanderResponseTimeFor(Network n
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
const LIN_SETTINGS* cfg = getLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);
@ -923,7 +923,7 @@ bool IDeviceSettings::setLINCommanderResponseTimeFor(Network net, uint8_t bits)
}
switch(net.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin: {
case icsneo_msg_bus_type_lin: {
LIN_SETTINGS* cfg = getMutableLINSettingsFor(net);
if(cfg == nullptr) {
report(APIEvent::Type::LINSettingsNotAvailable, APIEvent::Severity::Error);

View File

@ -31,7 +31,7 @@ void VSAExtendedMessage::truncatePacket(std::shared_ptr<Packet> packet)
{
static constexpr auto EthernetLengthOffset = 26u;
switch(packet->network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet:
case icsneo_msg_bus_type_ethernet:
{
const auto& packetLength = *reinterpret_cast<uint16_t*>(packet->data.data() + EthernetLengthOffset);
const size_t ethernetFrameSize = packetLength - (sizeof(uint16_t) * 2);

View File

@ -36,9 +36,9 @@ the arbitration ID.
std::cout << "We got " << messages.size() << " messages!" << std::endl;
for(auto& msg : messages) {
switch(msg->network.getType()) {
case icsneo::Network::Type::CAN:
case icsneo::Network::Type::SWCAN:
case icsneo::Network::Type::LSFTCAN: {
case icsneo::icsneo_msg_bus_type_can:
case icsneo::icsneo_msg_bus_type_swcan:
case icsneo::icsneo_msg_bus_type_lsftcan: {
// A message of type CAN is guaranteed to be a CANMessage, so we can static cast safely
auto canmsg = std::static_pointer_cast<icsneo::CANMessage>(msg);
// canmsg->arbid is valid here

View File

@ -37,7 +37,7 @@ void sleep_ms(uint32_t ms) {
int print_error_code(const char* message, icsneo_error_t error) {
char error_str[256] = {0};
uint32_t error_length = 256;
icsneo_error_t res = icsneo_error_code(error, error_str, &error_length);
icsneo_error_t res = icsneo_get_error_code(error, error_str, &error_length);
if (res != icsneo_error_success) {
printf("%s: Failed to get string for error code %d with error code %d\n", message, error, res);
return res;
@ -70,7 +70,7 @@ int main(int argc, char* argv[]) {
icsneo_device_t* devices[255] = {0};
uint32_t devices_count = 255;
icsneo_error_t res = icsneo_find(devices, &devices_count, NULL);
icsneo_error_t res = icsneo_device_find_all(devices, &devices_count, NULL);
if (res != icsneo_error_success) {
return print_error_code("Failed to find devices", res);
};
@ -82,14 +82,14 @@ int main(int argc, char* argv[]) {
// Get description of the device
const char description[255] = {0};
uint32_t description_length = 255;
res = icsneo_device_describe(device, description, &description_length);
res = icsneo_device_get_description(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, &timestamp_resolution);
res = icsneo_device_get_timestamp_resolution(device, &timestamp_resolution);
if (res != icsneo_error_success) {
print_device_events(device, description);
return print_error_code("Failed to get timestamp resolution", res);
@ -97,21 +97,21 @@ int main(int argc, char* argv[]) {
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);
res = icsneo_device_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);
res = icsneo_device_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);
res = icsneo_device_open(device);
if (res != icsneo_error_success) {
print_device_events(device, description);
return print_error_code("Failed to open device", res);
@ -123,7 +123,7 @@ int main(int argc, char* argv[]) {
icsneo_message_t* messages[20000] = {0};
uint32_t message_count = 20000;
printf("Getting messages from device with timeout of 3000ms on %s...\n", description);
res = icsneo_get_messages(device, messages, &message_count, 3000);
res = icsneo_device_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);
@ -136,7 +136,7 @@ int main(int argc, char* argv[]) {
}
// Finally, close the device.
printf("Closing device: %s...\n", description);
res = icsneo_close(device);
res = icsneo_device_close(device);
if (res != icsneo_error_success) {
print_device_events(device, description);
return print_error_code("Failed to close device", res);
@ -215,8 +215,8 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
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);
uint32_t result = icsneo_can_message_get_arbid(device, message, &arbid);
result += icsneo_can_message_get_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);
@ -233,7 +233,6 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
printf(" ]\n");
continue;
}
}
return icsneo_error_success;

View File

@ -259,7 +259,7 @@ void example4(const std::shared_ptr<icsneo::Device>& rada2b) {
auto handler = rada2b->addMessageCallback(std::make_shared<icsneo::MessageCallback>(
[] (std::shared_ptr<icsneo::Message> newMsg) {
if(newMsg->type == icsneo::Message::Type::Frame) {
if(newMsg->type == icsneo::Message::Type::BusMessage) {
const auto& frame = std::dynamic_pointer_cast<icsneo::BusMessage>(newMsg);
if(frame && frame->network.getNetID() == icsneo::Network::NetID::I2C2) {
const auto& i2cMessage = std::dynamic_pointer_cast<icsneo::I2CMessage>(frame);
@ -392,11 +392,11 @@ int main(int argc, char** argv) {
const auto& txNetworks = dev->getSupportedTXNetworks();
const auto& rxNetworks = dev->getSupportedRXNetworks();
if(std::none_of(txNetworks.begin(), txNetworks.end(), [](const icsneo::Network& net) { return net.getType() == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b; })) {
if(std::none_of(txNetworks.begin(), txNetworks.end(), [](const icsneo::Network& net) { return net.getType() == icsneo_msg_bus_type_a2b; })) {
return false;
}
if(std::none_of(rxNetworks.begin(), rxNetworks.end(), [](const icsneo::Network& net) { return net.getType() == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b; })) {
if(std::none_of(rxNetworks.begin(), rxNetworks.end(), [](const icsneo::Network& net) { return net.getType() == icsneo_msg_bus_type_a2b; })) {
return false;
}

View File

@ -184,11 +184,11 @@ std::shared_ptr<icsneo::Device> selectDevice(const std::vector<std::shared_ptr<i
void printMessage(const std::shared_ptr<icsneo::Message>& message) {
switch(message->type) {
case icsneo::Message::Type::Frame: {
// A message of type Frame is guaranteed to be a Frame, so we can static cast safely
case icsneo::Message::Type::BusMessage: {
// A message of type BusMessage is guaranteed to be a BusMessage, so we can static cast safely
auto frame = std::static_pointer_cast<icsneo::BusMessage>(message);
switch(frame->network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
// A message of type CAN is guaranteed to be a CANMessage, so we can static cast safely
auto canMessage = std::static_pointer_cast<icsneo::CANMessage>(message);
@ -214,10 +214,10 @@ void printMessage(const std::shared_ptr<icsneo::Message>& message) {
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
std::cout << "\t\t" << ethMessage->network << " BusMessage - " << std::dec
<< ethMessage->data.size() << " bytes on wire\n";
std::cout << "\t\t Timestamped:\t"<< ethMessage->timestamp << " ns since 1/1/2007\n";
@ -235,7 +235,7 @@ void printMessage(const std::shared_ptr<icsneo::Message>& message) {
std::cout << std::dec << std::endl;
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141: {
case icsneo_msg_bus_type_iso9141: {
// Note that the default settings on some devices have ISO9141 disabled by default in favor of LIN
// and that this example loads the device defaults at the very end.
// A message of type ISO9414 is guaranteed to be an ISO9141Message, so we can static cast safely
@ -264,7 +264,7 @@ void printMessage(const std::shared_ptr<icsneo::Message>& message) {
break;
}
break;
} // end of icsneo::Message::Type::Frame
} // end of icsneo::Message::Type::BusMessage
case icsneo::Message::Type::CANErrorCount: {
// A message of type CANErrorCount is guaranteed to be a CANErrorCount, so we can static cast safely
auto cec = std::static_pointer_cast<icsneo::CANErrorCountMessage>(message);

View File

@ -96,9 +96,9 @@ int main() {
std::cout << "OK" << std::endl << std::endl;
auto handler = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([&](std::shared_ptr<icsneo::Message> message) {
if(icsneo::Message::Type::Frame == message->type) {
if(icsneo::Message::Type::BusMessage == message->type) {
auto frame = std::static_pointer_cast<icsneo::BusMessage>(message);
if(_icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin == frame->network.getType()) {
if(icsneo_msg_bus_type_lin == frame->network.getType()) {
auto msg = std::static_pointer_cast<icsneo::LINMessage>(message);
std::cout << msg->network << " RX frame | ID: 0x" << std::hex << static_cast<int>(msg->ID) << " | ";
std::cout << "Protected ID: 0x" << static_cast<int>(msg->protectedID) << "\n" << "Data: ";

View File

@ -92,9 +92,9 @@ int main()
auto handler = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([&](std::shared_ptr<icsneo::Message> message)
{
if(icsneo::Message::Type::Frame == message->type) {
if(icsneo::Message::Type::BusMessage == message->type) {
auto frame = std::static_pointer_cast<icsneo::BusMessage>(message);
if(_icsneo_msg_bus_type_t::icsneo_msg_bus_type_mdio == frame->network.getType()) {
if(icsneo_msg_bus_type_mdio == frame->network.getType()) {
auto msg = std::static_pointer_cast<icsneo::MDIOMessage>(message);
std::cout << msg->network << " " << ((msg->isTXMsg)? "TX" : "RX") << " frame\n";
std::cout << "Clause: " << ((msg->clause == icsneo::MDIOMessage::Clause::Clause22) ? "22" : "45") << "\n";

View File

@ -169,11 +169,11 @@ int main() {
// MessageCallbacks are powerful, and can filter on things like ArbID for you. See the documentation
auto handler = device->addMessageCallback(std::make_shared<icsneo::MessageCallback>([](std::shared_ptr<icsneo::Message> message) {
switch(message->type) {
case icsneo::Message::Type::Frame: {
// A message of type Frame is guaranteed to be a Frame, so we can static cast safely
case icsneo::Message::Type::BusMessage: {
// A message of type BusMessage is guaranteed to be a BusMessage, so we can static cast safely
auto frame = std::static_pointer_cast<icsneo::BusMessage>(message);
switch(frame->network.getType()) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can: {
case icsneo_msg_bus_type_can: {
// A message of type CAN is guaranteed to be a CANMessage, so we can static cast safely
auto canMessage = std::static_pointer_cast<icsneo::CANMessage>(message);
@ -199,10 +199,10 @@ int main() {
std::cout << std::dec << '(' << canMessage->timestamp << " ns since 1/1/2007)\n";
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet: {
case icsneo_msg_bus_type_ethernet: {
auto ethMessage = std::static_pointer_cast<icsneo::EthernetMessage>(message);
std::cout << "\t\t" << ethMessage->network << " Frame - " << std::dec
std::cout << "\t\t" << ethMessage->network << " BusMessage - " << std::dec
<< ethMessage->data.size() << " bytes on wire\n";
std::cout << "\t\t Timestamped:\t"<< ethMessage->timestamp << " ns since 1/1/2007\n";
@ -220,7 +220,7 @@ int main() {
std::cout << std::dec << std::endl;
break;
}
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141: {
case icsneo_msg_bus_type_iso9141: {
// Note that the default settings on some devices have ISO9141 disabled by default in favor of LIN
// and that this example loads the device defaults at the very end.
// A message of type ISO9414 is guaranteed to be an ISO9141Message, so we can static cast safely
@ -249,7 +249,7 @@ int main() {
break;
}
break;
} // end of icsneo::Message::Type::Frame
} // end of icsneo::Message::Type::BusMessage
case icsneo::Message::Type::CANErrorCount: {
// A message of type CANErrorCount is guaranteed to be a CANErrorCount, so we can static cast safely
auto cec = std::static_pointer_cast<icsneo::CANErrorCountMessage>(message);

View File

@ -166,13 +166,13 @@ int main(int argc, char* argv[]) {
uint64_t canFrameCount = 0;
uint64_t ethFrameCount = 0;
rxDevice->addMessageCallback(std::make_shared<icsneo::MessageCallback>([&](std::shared_ptr<icsneo::Message> msg) {
if(msg->type != icsneo::Message::Type::Frame) {
if(msg->type != icsneo::Message::Type::BusMessage) {
return;
}
const auto frame = std::static_pointer_cast<icsneo::BusMessage>(msg);
if(frame->network.getType() == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can) {
if(frame->network.getType() == icsneo_msg_bus_type_can) {
++canFrameCount;
} else if(frame->network.getType() == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet) {
} else if(frame->network.getType() == icsneo_msg_bus_type_ethernet) {
++ethFrameCount;
}
}));
@ -216,7 +216,7 @@ int main(int argc, char* argv[]) {
size_t currentMessage = 0;
rxDevice->addMessageCallback(std::make_shared<icsneo::MessageCallback>([&](std::shared_ptr<icsneo::Message> msg) {
if(msg->type != icsneo::Message::Type::Frame) {
if(msg->type != icsneo::Message::Type::BusMessage) {
return;
}
auto frame = std::static_pointer_cast<icsneo::BusMessage>(msg);

View File

@ -13,8 +13,8 @@ namespace icsneo {
class CANMessageFilter : public MessageFilter {
public:
CANMessageFilter() : MessageFilter(_icsneo_msg_bus_type_t::icsneo_msg_bus_type_can), arbid(INVALID_ARBID) { messageType = Message::Type::Frame; }
CANMessageFilter(uint32_t arbid) : MessageFilter(_icsneo_msg_bus_type_t::icsneo_msg_bus_type_can), arbid(arbid) { messageType = Message::Type::Frame; }
CANMessageFilter() : MessageFilter(icsneo_msg_bus_type_can), arbid(INVALID_ARBID) { messageType = Message::Type::BusMessage; }
CANMessageFilter(uint32_t arbid) : MessageFilter(icsneo_msg_bus_type_can), arbid(arbid) { messageType = Message::Type::BusMessage; }
bool match(const std::shared_ptr<Message>& message) const {
if(!MessageFilter::match(message))

View File

@ -15,9 +15,9 @@ public:
MessageFilter(Message::Type type) : includeInternalInAny(neomessagetype_t(type) & 0x8000), messageType(type) {}
MessageFilter(Network::NetID netid) : MessageFilter(Network::GetTypeOfNetID(netid, false), netid) {} // Messages on the communication layer are never encoded as VNET ID + common ID, so skip the expansion step
MessageFilter(icsneo_msg_bus_type_t type, Network::NetID net = Network::NetID::Any) : networkType(type), netid(net) {
// If a Network::Type::Internal is used, we want to also get internal Message::Types
// If a icsneo_msg_bus_type_internal is used, we want to also get internal Message::Types
// The NetID we want may be in there
includeInternalInAny = (networkType == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_internal);
includeInternalInAny = (networkType == icsneo_msg_bus_type_internal);
}
virtual ~MessageFilter() = default;
// When getting "all" types of messages, include the ones marked as "internal only"
@ -27,14 +27,14 @@ public:
if(!matchMessageType(message->type))
return false;
if(message->type == Message::Type::Frame || message->type == Message::Type::Main51 ||
message->type == Message::Type::RawMessage || message->type == Message::Type::ReadSettings) {
if(message->type == Message::Type::BusMessage || message->type == Message::Type::Main51 ||
message->type == Message::Type::InternalMessage || message->type == Message::Type::ReadSettings) {
const auto frame = std::static_pointer_cast<InternalMessage>(message);
if(!matchNetworkType(frame->network.getType()))
return false;
if(!matchNetID(frame->network.getNetID()))
return false;
} else if (netid != Network::NetID::Any || networkType != _icsneo_msg_bus_type_t::icsneo_msg_bus_type_any) {
} else if (netid != Network::NetID::Any || networkType != icsneo_msg_bus_type_any) {
return false; // Filtering on a NetID or Type, but this message doesn't have one
}
return true;
@ -48,9 +48,9 @@ protected:
return messageType == mtype;
}
icsneo_msg_bus_type_t networkType = _icsneo_msg_bus_type_t::icsneo_msg_bus_type_any;
icsneo_msg_bus_type_t networkType = icsneo_msg_bus_type_any;
bool matchNetworkType(icsneo_msg_bus_type_t mtype) const {
if(networkType == _icsneo_msg_bus_type_t::icsneo_msg_bus_type_any && (mtype != _icsneo_msg_bus_type_t::icsneo_msg_bus_type_internal || includeInternalInAny))
if(networkType == icsneo_msg_bus_type_any && (mtype != icsneo_msg_bus_type_internal || includeInternalInAny))
return true;
return networkType == mtype;
}

View File

@ -9,7 +9,7 @@ namespace icsneo {
class FlashMemoryMessage : public InternalMessage {
public:
FlashMemoryMessage() : InternalMessage(Message::Type::RawMessage, Network::NetID::RED_INT_MEMORYREAD) {}
FlashMemoryMessage() : InternalMessage(Message::Type::InternalMessage, Network::NetID::RED_INT_MEMORYREAD) {}
uint16_t startAddress = 0;
};

View File

@ -22,7 +22,7 @@ public:
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_device; }
enum class Type : neomessagetype_t {
Frame = 0,
BusMessage = 0,
CANErrorCount = 0x100,
@ -31,7 +31,7 @@ public:
// Past 0x8000 are all for internal use only
Invalid = 0x8000,
RawMessage = 0x8001,
InternalMessage = 0x8001,
ReadSettings = 0x8002,
ResetStatus = 0x8003,
DeviceVersion = 0x8004,
@ -59,10 +59,10 @@ public:
class InternalMessage : public Message {
public:
InternalMessage(Message::Type type = Message::Type::RawMessage) : Message(type) {}
InternalMessage(Message::Type type = Message::Type::InternalMessage) : Message(type) {}
InternalMessage(Message::Type type, Network net) : Message(type), network(net) {}
InternalMessage(Network net) : Message(Message::Type::RawMessage), network(net) {}
InternalMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::RawMessage), network(net), data(d) {}
InternalMessage(Network net) : Message(Message::Type::InternalMessage), network(net) {}
InternalMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::InternalMessage), network(net), data(d) {}
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_internal; }
@ -72,7 +72,7 @@ public:
class BusMessage : public InternalMessage {
public:
BusMessage() : InternalMessage(Message::Type::Frame) {}
BusMessage() : InternalMessage(Message::Type::BusMessage) {}
const icsneo_msg_type_t getMsgType() const final { return icsneo_msg_type_bus; }

View File

@ -9,7 +9,7 @@ namespace icsneo {
class NeoReadMemorySDMessage : public InternalMessage {
public:
NeoReadMemorySDMessage() : InternalMessage(Message::Type::RawMessage, Network::NetID::NeoMemorySDRead) {}
NeoReadMemorySDMessage() : InternalMessage(Message::Type::InternalMessage, Network::NetID::NeoMemorySDRead) {}
uint32_t startAddress = 0;
};

View File

@ -291,35 +291,35 @@ public:
};
static const char* GetTypeString(icsneo_msg_bus_type_t type) {
switch(type) {
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can:
case icsneo_msg_bus_type_can:
return "CAN";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin:
case icsneo_msg_bus_type_lin:
return "LIN";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_flexray:
case icsneo_msg_bus_type_flexray:
return "FlexRay";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_most:
case icsneo_msg_bus_type_most:
return "MOST";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_other:
case icsneo_msg_bus_type_other:
return "Other";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_internal:
case icsneo_msg_bus_type_internal:
return "Internal";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141:
case icsneo_msg_bus_type_iso9141:
return "ISO 9141-2";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet:
case icsneo_msg_bus_type_ethernet:
return "Ethernet";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan:
case icsneo_msg_bus_type_lsftcan:
return "Low Speed Fault Tolerant CAN";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan:
case icsneo_msg_bus_type_swcan:
return "Single Wire CAN";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_i2c:
case icsneo_msg_bus_type_i2c:
return "I²C";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b:
case icsneo_msg_bus_type_a2b:
return "A2B";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_spi:
case icsneo_msg_bus_type_spi:
return "SPI";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_mdio:
case icsneo_msg_bus_type_mdio:
return "MDIO";
case _icsneo_msg_bus_type_t::icsneo_msg_bus_type_invalid:
case icsneo_msg_bus_type_invalid:
default:
return "Invalid Type";
}
@ -515,7 +515,7 @@ public:
case NetID::DWCAN14:
case NetID::DWCAN15:
case NetID::DWCAN16:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_can;
return icsneo_msg_bus_type_can;
case NetID::LIN:
case NetID::LIN2:
case NetID::LIN3:
@ -532,18 +532,18 @@ public:
case NetID::LIN14:
case NetID::LIN15:
case NetID::LIN16:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lin;
return icsneo_msg_bus_type_lin;
case NetID::FlexRay:
case NetID::FlexRay1a:
case NetID::FlexRay1b:
case NetID::FlexRay2:
case NetID::FlexRay2a:
case NetID::FlexRay2b:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_flexray;
return icsneo_msg_bus_type_flexray;
case NetID::MOST25:
case NetID::MOST50:
case NetID::MOST150:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_most;
return icsneo_msg_bus_type_most;
case NetID::RED:
case NetID::RED_OLDFORMAT:
case NetID::Device:
@ -565,10 +565,10 @@ public:
case NetID::RED_GET_RTC:
case NetID::DiskData:
case NetID::RED_App_Error:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_internal;
return icsneo_msg_bus_type_internal;
case NetID::Invalid:
case NetID::Any:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_invalid;
return icsneo_msg_bus_type_invalid;
case NetID::Ethernet:
case NetID::Ethernet_DAQ:
case NetID::Ethernet2:
@ -589,26 +589,26 @@ public:
case NetID::OP_Ethernet14:
case NetID::OP_Ethernet15:
case NetID::OP_Ethernet16:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_ethernet;
return icsneo_msg_bus_type_ethernet;
case NetID::LSFTCAN:
case NetID::LSFTCAN2:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_lsftcan;
return icsneo_msg_bus_type_lsftcan;
case NetID::SWCAN:
case NetID::SWCAN2:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_swcan;
return icsneo_msg_bus_type_swcan;
case NetID::ISO9141:
case NetID::ISO9141_2:
case NetID::ISO9141_3:
case NetID::ISO9141_4:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_iso9141;
return icsneo_msg_bus_type_iso9141;
case NetID::I2C:
case NetID::I2C2:
case NetID::I2C3:
case NetID::I2C4:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_i2c;
return icsneo_msg_bus_type_i2c;
case NetID::A2B1:
case NetID::A2B2:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_a2b;
return icsneo_msg_bus_type_a2b;
case NetID::SPI1:
case NetID::SPI2:
case NetID::SPI3:
@ -617,7 +617,7 @@ public:
case NetID::SPI6:
case NetID::SPI7:
case NetID::SPI8:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_spi;
return icsneo_msg_bus_type_spi;
case NetID::MDIO1:
case NetID::MDIO2:
case NetID::MDIO3:
@ -626,9 +626,9 @@ public:
case NetID::MDIO6:
case NetID::MDIO7:
case NetID::MDIO8:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_mdio;
return icsneo_msg_bus_type_mdio;
default:
return _icsneo_msg_bus_type_t::icsneo_msg_bus_type_other;
return icsneo_msg_bus_type_other;
}
}
static const char* GetNetIDString(NetID netid, bool expand = true) {

View File

@ -103,7 +103,7 @@ typedef uint32_t icsneo_error_t;
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_error_code(icsneo_error_t error_code, const char* value, uint32_t* value_length);
ICSNEO_API icsneo_error_t icsneo_get_error_code(icsneo_error_t error_code, const char* value, uint32_t* value_length);
/** @brief Get the device type string for a icsneo_devicetype_t.
*
@ -124,7 +124,7 @@ ICSNEO_API icsneo_error_t icsneo_device_type_from_type(icsneo_devicetype_t devic
*
* @return icsneo_error_t icsneo_error_success if successful.
*/
ICSNEO_API icsneo_error_t icsneo_find(icsneo_device_t** devices, uint32_t* devices_count, void* reserved);
ICSNEO_API icsneo_error_t icsneo_device_find_all(icsneo_device_t** devices, uint32_t* devices_count, void* reserved);
/** @brief Check to make sure a device is valid.
*
@ -141,7 +141,7 @@ ICSNEO_API icsneo_error_t icsneo_device_is_valid(icsneo_device_t* device);
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_open_options(icsneo_device_t* device, icsneo_open_options_t* options);
ICSNEO_API icsneo_error_t icsneo_device_get_open_options(icsneo_device_t* device, icsneo_open_options_t* options);
/** @brief Set the open options for a device
*
@ -150,31 +150,31 @@ ICSNEO_API icsneo_error_t icsneo_get_open_options(icsneo_device_t* device, icsne
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_set_open_options(icsneo_device_t* device, icsneo_open_options_t options);
ICSNEO_API icsneo_error_t icsneo_device_set_open_options(icsneo_device_t* device, icsneo_open_options_t options);
/** @brief Open a connection to a device.
*
* After a successful call to this function, icsneo_close() must be called to close the device.
* After a successful call to this function, icsneo_device_close() must be called to close the device.
*
* @param[in] icsneo_device_t device The device to open.
* @param[out] icsneo_handle_t* handle Pointer to a handle to the opened device. Will be NULL on failure.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_failure otherwise.
*
* @see icsneo_close
* @see icsneo_device_close
*/
ICSNEO_API icsneo_error_t icsneo_open(icsneo_device_t* device);
ICSNEO_API icsneo_error_t icsneo_device_open(icsneo_device_t* device);
/** @brief Close a connection to a previously opened device.
*
* After a successful call to icsneo_open(), this function must be called to close the device.
* After a successful call to icsneo_device_open(), this function must be called to close the device.
* An already closed device will still succeed.
*
* @param[in] icsneo_device_t device The device to close.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_failure otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_close(icsneo_device_t* device);
ICSNEO_API icsneo_error_t icsneo_device_close(icsneo_device_t* device);
/** @brief Get the description of a device
*
@ -184,16 +184,16 @@ ICSNEO_API icsneo_error_t icsneo_close(icsneo_device_t* device);
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_device_describe(icsneo_device_t* device, const char* value, uint32_t* value_length);
ICSNEO_API icsneo_error_t icsneo_device_get_description(icsneo_device_t* device, const char* value, uint32_t* value_length);
/** @brief Get the description type a device
/** @brief Get the type of a device
*
* @param[in] icsneo_device_t device The device to get the description of.
* @param[in] icsneo_device_t device The device to get the type of.
* @param[out] icsneo_devicetype_t* value Pointer to an icsneo_devicetype_t to copy the type into.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_device_type(icsneo_device_t* device, icsneo_devicetype_t* value);
ICSNEO_API icsneo_error_t icsneo_device_get_type(icsneo_device_t* device, icsneo_devicetype_t* value);
/** @brief Get the serial of a device
*
@ -203,7 +203,7 @@ ICSNEO_API icsneo_error_t icsneo_device_type(icsneo_device_t* device, icsneo_dev
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_device_serial(icsneo_device_t* device, const char* value, uint32_t* value_length);
ICSNEO_API icsneo_error_t icsneo_device_get_serial(icsneo_device_t* device, const char* value, uint32_t* value_length);
/** @brief Set the online state of a device.
*
@ -212,16 +212,25 @@ ICSNEO_API icsneo_error_t icsneo_device_serial(icsneo_device_t* device, const ch
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_go_online(icsneo_device_t* device, bool go_online);
ICSNEO_API icsneo_error_t icsneo_device_go_online(icsneo_device_t* device, bool go_online);
/** @brief Get the online state of a device.
*
* @param[in] icsneo_device_t device The device to set the online state of.
* @param[in] icsneo_device_t device The device to get the online state of.
* @param[out] bool true if online, false if offline.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_is_online(icsneo_device_t* device, bool* is_online);
ICSNEO_API icsneo_error_t icsneo_device_is_online(icsneo_device_t* device, bool* is_online);
/** @brief Get the online supported state of a device.
*
* @param[in] icsneo_device_t device The device to get the online supported state of.
* @param[out] bool true if online, false if offline.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_device_is_online_supported(icsneo_device_t* device, bool* is_online_supported);
/** @brief Set the message polling state of a device.
@ -231,7 +240,7 @@ ICSNEO_API icsneo_error_t icsneo_is_online(icsneo_device_t* device, bool* is_onl
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_set_message_polling(icsneo_device_t* device, bool enable);
ICSNEO_API icsneo_error_t icsneo_device_set_message_polling(icsneo_device_t* device, bool enable);
/** @brief Get the message polling state of a device.
*
@ -240,7 +249,7 @@ ICSNEO_API icsneo_error_t icsneo_set_message_polling(icsneo_device_t* device, bo
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_message_polling(icsneo_device_t* device, bool* is_enabled);
ICSNEO_API icsneo_error_t icsneo_device_get_message_polling(icsneo_device_t* device, bool* is_enabled);
/** @brief Set the message polling limit of a device.
*
@ -251,18 +260,18 @@ ICSNEO_API icsneo_error_t icsneo_get_message_polling(icsneo_device_t* device, bo
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_set_message_polling_limit(icsneo_device_t* device, uint32_t limit);
ICSNEO_API icsneo_error_t icsneo_device_set_message_polling_limit(icsneo_device_t* device, uint32_t limit);
/** @brief Get the message polling limit of a device.
*
* @see icsneo_set_message_polling_limit
* @see icsneo_device_set_message_polling_limit
*
* @param[in] icsneo_device_t device The device to enforce the message polling limit.
* @param[out] uint32_t limit The limit to get.
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_message_polling_limit(icsneo_device_t* device, uint32_t* limit);
ICSNEO_API icsneo_error_t icsneo_device_get_message_polling_limit(icsneo_device_t* device, uint32_t* limit);
/** @brief Get the message count of a device
*
@ -271,7 +280,7 @@ ICSNEO_API icsneo_error_t icsneo_get_message_polling_limit(icsneo_device_t* devi
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_message_count(icsneo_device_t* device, uint32_t* count);
ICSNEO_API icsneo_error_t icsneo_device_get_message_count(icsneo_device_t* device, uint32_t* count);
/** @brief Get the timestamp resolution (nanoseconds) of a device
@ -281,7 +290,7 @@ ICSNEO_API icsneo_error_t icsneo_get_message_count(icsneo_device_t* device, uint
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_timestamp_resolution(icsneo_device_t* device, uint32_t* resolution);
ICSNEO_API icsneo_error_t icsneo_device_get_timestamp_resolution(icsneo_device_t* device, uint32_t* resolution);
/** @brief Get the messages of a device
*
@ -295,7 +304,7 @@ ICSNEO_API icsneo_error_t icsneo_get_timestamp_resolution(icsneo_device_t* devic
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t* messages_count, uint32_t timeout_ms);
ICSNEO_API icsneo_error_t icsneo_device_get_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t* messages_count, uint32_t timeout_ms);
/** @brief Check if a message is valid
*
@ -305,7 +314,7 @@ ICSNEO_API icsneo_error_t icsneo_get_messages(icsneo_device_t* device, icsneo_me
*
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
*/
ICSNEO_API icsneo_error_t icsneo_is_message_valid(icsneo_device_t* device, icsneo_message_t* message, bool* is_valid);
ICSNEO_API icsneo_error_t icsneo_message_is_valid(icsneo_device_t* device, icsneo_message_t* message, bool* is_valid);
/** @brief Get the type of a message
*
@ -350,7 +359,7 @@ ICSNEO_API icsneo_error_t icsneo_message_get_data(icsneo_device_t* device, icsne
*
* @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);
ICSNEO_API icsneo_error_t icsneo_can_message_get_arbid(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value);
/** @brief Get the DLC on wire of a CAN message
*
@ -360,7 +369,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_arbid(icsneo_device_t* device, icsn
*
* @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);
ICSNEO_API icsneo_error_t icsneo_can_message_get_dlc_on_wire(icsneo_device_t* device, icsneo_message_t* message, uint32_t* value);
/** @brief Get the remote status of a CAN message
*
@ -400,7 +409,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_is_canfd(icsneo_device_t* device, i
*
* @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);
ICSNEO_API icsneo_error_t icsneo_can_message_get_baudrate_switch(icsneo_device_t* device, icsneo_message_t* message, bool* value);
/** @brief Get the error state indicator status of a CAN message
*
@ -410,7 +419,7 @@ ICSNEO_API icsneo_error_t icsneo_can_message_baudrate_switch(icsneo_device_t* de
*
* @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);
ICSNEO_API icsneo_error_t icsneo_can_message_get_error_state_indicator(icsneo_device_t* device, icsneo_message_t* message, bool* value);
/** @brief Get the global events not specifically related to a device.
*

View File

@ -1,10 +1,5 @@
#pragma once
// _Static_assert support, this can be removed once C23 is the "standard"
#if __STDC_VERSION__ < 202311L && !defined(__cplusplus)
#include <assert.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -12,7 +7,7 @@ extern "C" {
#include <stdint.h>
/** @brief
* Options for opening a device. See icsneo_open() for more info.
* Options for opening a device. See icsneo_device_open() for more info.
*/
typedef enum _icsneo_open_options_t {
// No options
@ -158,13 +153,6 @@ typedef enum _icsneo_devicetype_t {
*/
typedef uint32_t icsneo_devicetype_t;
// Make sure icsneo_devicetype_t is never smaller than the actual enum
#if __STDC_VERSION__ < 202311L && !defined(__cplusplus)
_Static_assert(sizeof(_icsneo_devicetype_t) <= sizeof(icsneo_devicetype_t), "icsneo_devicetype_t is too small");
#else // C++ or C23
static_assert(sizeof(_icsneo_devicetype_t) <= sizeof(icsneo_devicetype_t));
#endif
typedef enum _icsneo_msg_type_t {
icsneo_msg_type_device,
icsneo_msg_type_internal,