Compare commits
17 Commits
351e462167
...
dae24a7370
| Author | SHA1 | Date |
|---|---|---|
|
|
dae24a7370 | |
|
|
0dc20db1ad | |
|
|
1790fb038a | |
|
|
1216c4c674 | |
|
|
7c4a3d3077 | |
|
|
780e0245b8 | |
|
|
09a4334cb2 | |
|
|
894d51953c | |
|
|
44bf7688f4 | |
|
|
40b85488dc | |
|
|
7584563002 | |
|
|
4f83614037 | |
|
|
38a4af8062 | |
|
|
3b95b41be4 | |
|
|
3da31a29b4 | |
|
|
d0f3e593df | |
|
|
90268a4f04 |
|
|
@ -437,7 +437,7 @@ build python/linux/amd64:
|
||||||
CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.sh
|
CIBW_BEFORE_ALL: yum install -y flex && sh ci/bootstrap-libpcap.sh && sh ci/bootstrap-libusb.sh
|
||||||
CIBW_BUILD: "*manylinux*" # no musl
|
CIBW_BUILD: "*manylinux*" # no musl
|
||||||
CIBW_ARCHS: x86_64
|
CIBW_ARCHS: x86_64
|
||||||
DOCKER_HOST: tcp://docker:2375/
|
DOCKER_HOST: unix:///var/run/docker.sock
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
DOCKER_TLS_CERTDIR: ""
|
DOCKER_TLS_CERTDIR: ""
|
||||||
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install:/project/libusb/install
|
CIBW_ENVIRONMENT: CMAKE_PREFIX_PATH=/project/libpcap/install:/project/libusb/install
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ each of the respective APIs.
|
||||||
- RAD-Comet 2
|
- RAD-Comet 2
|
||||||
- RAD-Comet 3
|
- RAD-Comet 3
|
||||||
- RAD-Galaxy
|
- RAD-Galaxy
|
||||||
|
- RAD-Galaxy 2
|
||||||
- RAD-Gigastar
|
- RAD-Gigastar
|
||||||
- RAD-Gigastar 2
|
- RAD-Gigastar 2
|
||||||
- RAD-Moon 2
|
- RAD-Moon 2
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,12 @@ ICSNEO_API icsneo_error_t icsneo_get_error_code(icsneo_error_t error_code, const
|
||||||
case icsneo_error_sync_rtc_failed:
|
case icsneo_error_sync_rtc_failed:
|
||||||
error = "Syncronizing RTC failed";
|
error = "Syncronizing RTC failed";
|
||||||
break;
|
break;
|
||||||
|
case icsneo_error_get_messages_failed:
|
||||||
|
error = "Getting messages failed";
|
||||||
|
break;
|
||||||
|
case icsneo_error_invalid_type:
|
||||||
|
error = "Invalid type";
|
||||||
|
break;
|
||||||
case icsneo_error_rtc_failure:
|
case icsneo_error_rtc_failure:
|
||||||
error = "RTC failure";
|
error = "RTC failure";
|
||||||
break;
|
break;
|
||||||
|
|
@ -127,6 +133,12 @@ ICSNEO_API icsneo_error_t icsneo_get_error_code(icsneo_error_t error_code, const
|
||||||
case icsneo_error_string_copy_failed:
|
case icsneo_error_string_copy_failed:
|
||||||
error = "String copy failed";
|
error = "String copy failed";
|
||||||
break;
|
break;
|
||||||
|
case icsneo_error_invalid_device:
|
||||||
|
error = "Invalid device";
|
||||||
|
break;
|
||||||
|
case icsneo_error_invalid_message:
|
||||||
|
error = "Invalid message";
|
||||||
|
break;
|
||||||
// Don't default, let the compiler warn us if we forget to handle an error code
|
// Don't default, let the compiler warn us if we forget to handle an error code
|
||||||
}
|
}
|
||||||
// Copy the string into value
|
// Copy the string into value
|
||||||
|
|
@ -186,7 +198,13 @@ ICSNEO_API icsneo_error_t icsneo_device_is_valid(icsneo_device_t* device) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !device->device ? icsneo_error_invalid_parameters : icsneo_error_success;
|
if (!std::any_of(g_devices.begin(), g_devices.end(), [&](const auto& dev) {
|
||||||
|
return dev.get() == device;
|
||||||
|
})) {
|
||||||
|
return icsneo_error_invalid_device;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !device->device ? icsneo_error_invalid_device : icsneo_error_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICSNEO_API icsneo_error_t icsneo_device_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) {
|
||||||
|
|
@ -392,7 +410,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_messages(icsneo_device_t* device, ic
|
||||||
if (!device || !messages || !messages_count) {
|
if (!device || !messages || !messages_count) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
auto dev = device->device;
|
auto dev = device->device;
|
||||||
// Wait for messages
|
// Wait for messages
|
||||||
auto start_time = std::chrono::steady_clock::now();
|
auto start_time = std::chrono::steady_clock::now();
|
||||||
|
|
@ -434,12 +456,23 @@ ICSNEO_API icsneo_error_t icsneo_device_transmit_messages(icsneo_device_t* devic
|
||||||
if (!device || !messages || !messages_count) {
|
if (!device || !messages || !messages_count) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
auto dev = device->device;
|
auto dev = device->device;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
for (; i < *messages_count; i++) {
|
for (; i < *messages_count; i++) {
|
||||||
// TODO: Check if message is valid
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, messages[i], &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
success = dev->transmit(std::static_pointer_cast<icsneo::BusMessage>(messages[i]->message));
|
success = dev->transmit(std::static_pointer_cast<icsneo::BusMessage>(messages[i]->message));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -454,10 +487,21 @@ ICSNEO_API icsneo_error_t icsneo_message_is_valid(icsneo_device_t* device, icsne
|
||||||
if (!device || !message || !is_valid) {
|
if (!device || !message || !is_valid) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
*is_valid = std::find_if(device->messages.begin(), device->messages.end(), [&](const auto& msg) {
|
auto res = icsneo_device_is_valid(device);
|
||||||
return msg->message == message->message;
|
if (res != icsneo_error_success) {
|
||||||
}) == device->messages.end();
|
return res;
|
||||||
|
}
|
||||||
|
// See if the message is a valid received message
|
||||||
|
bool is_rx_msg = std::any_of(device->messages.begin(), device->messages.end(), [&](const auto& msg) {
|
||||||
|
return msg.get() == message;
|
||||||
|
});
|
||||||
|
// See if the message is a valid transmit message
|
||||||
|
bool is_tx_msg = std::any_of(device->tx_messages.begin(), device->tx_messages.end(), [&](const auto& msg) {
|
||||||
|
return msg.get() == message;
|
||||||
|
});
|
||||||
|
|
||||||
|
*is_valid = (is_rx_msg || is_tx_msg) && message->message.get() != nullptr;
|
||||||
|
|
||||||
return icsneo_error_success;
|
return icsneo_error_success;
|
||||||
}
|
}
|
||||||
|
|
@ -466,7 +510,14 @@ ICSNEO_API icsneo_error_t icsneo_message_get_type(icsneo_device_t* device, icsne
|
||||||
if (!device || !message || !msg_type) {
|
if (!device || !message || !msg_type) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if message is valid
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
auto res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
|
|
||||||
// Assign the message type
|
// Assign the message type
|
||||||
*msg_type = message->message->getMsgType();
|
*msg_type = message->message->getMsgType();
|
||||||
|
|
@ -474,11 +525,26 @@ ICSNEO_API icsneo_error_t icsneo_message_get_type(icsneo_device_t* device, icsne
|
||||||
return icsneo_error_success;
|
return icsneo_error_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICSNEO_API icsneo_error_t icsneo_message_get_type_name(icsneo_msg_type_t msg_type, const char* value, uint32_t* value_length) {
|
||||||
|
if (!value || !value_length) {
|
||||||
|
return icsneo_error_invalid_parameters;
|
||||||
|
}
|
||||||
|
// Copy the string into value
|
||||||
|
return safe_str_copy(value, value_length, Message::getMsgTypeName(msg_type)) ? icsneo_error_success : icsneo_error_string_copy_failed;
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
if (!device || !message || !bus_type) {
|
if (!device || !message || !bus_type) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if message is valid
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
auto res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the message is a bus message
|
// Make sure the message is a bus message
|
||||||
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
|
|
@ -504,7 +570,14 @@ ICSNEO_API icsneo_error_t icsneo_message_is_transmit(icsneo_device_t* device, ic
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if message is valid
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
auto res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the message is a bus message
|
// Make sure the message is a bus message
|
||||||
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
|
|
@ -521,7 +594,14 @@ ICSNEO_API icsneo_error_t icsneo_message_get_netid(icsneo_device_t* device, icsn
|
||||||
if (!device || !message || !netid) {
|
if (!device || !message || !netid) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if message is valid
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
auto res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the message is a bus message
|
// Make sure the message is a bus message
|
||||||
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
|
|
@ -546,8 +626,19 @@ ICSNEO_API icsneo_error_t icsneo_message_set_netid(icsneo_device_t* device, icsn
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
// Make sure the message has the data field, internal and bus currently have this.
|
// 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) {
|
if (message->message->getMsgType() != icsneo_msg_type_internal && message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -565,8 +656,19 @@ ICSNEO_API icsneo_error_t icsneo_message_set_data(icsneo_device_t* device, icsne
|
||||||
if (!device || !message | !data) {
|
if (!device || !message | !data) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
// Make sure the message has the data field, internal and bus currently have this.
|
// 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) {
|
if (message->message->getMsgType() != icsneo_msg_type_internal && message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -587,8 +689,19 @@ ICSNEO_API icsneo_error_t icsneo_message_get_data(icsneo_device_t* device, icsne
|
||||||
if (!device || !message || !data || !data_length) {
|
if (!device || !message || !data || !data_length) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
// Make sure the message has the data field, internal and bus currently have this.
|
// 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) {
|
if (message->message->getMsgType() != icsneo_msg_type_internal && message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -609,8 +722,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_get_arbid(icsneo_device_t* device,
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -625,8 +749,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_arbid(icsneo_device_t* device,
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -641,8 +776,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_get_dlc(icsneo_device_t* device, ic
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -657,17 +803,28 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_dlc(icsneo_device_t* device, ic
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
auto res = CAN_LengthToDLC(static_cast<uint8_t>(can_message->data.size()), can_message->isCANFD);
|
auto dlc_res = CAN_LengthToDLC(static_cast<uint8_t>(can_message->data.size()), can_message->isCANFD);
|
||||||
can_message->dlcOnWire = res.value_or(0);
|
can_message->dlcOnWire = dlc_res.value_or(0);
|
||||||
return res.has_value() ? icsneo_error_success : icsneo_error_invalid_parameters;
|
return dlc_res.has_value() ? icsneo_error_success : icsneo_error_invalid_parameters;
|
||||||
} else {
|
} else {
|
||||||
can_message->dlcOnWire = static_cast<uint8_t>(value);
|
can_message->dlcOnWire = static_cast<uint8_t>(value);
|
||||||
return icsneo_error_success;
|
return icsneo_error_success;
|
||||||
|
|
@ -678,8 +835,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_is_remote(icsneo_device_t* device,
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -694,8 +862,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_remote(icsneo_device_t* device,
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -710,8 +889,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_is_extended(icsneo_device_t* device
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -726,8 +916,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_extended(icsneo_device_t* devic
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -742,8 +943,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_is_canfd(icsneo_device_t* device, i
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -758,8 +970,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_canfd(icsneo_device_t* device,
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -774,8 +997,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_get_baudrate_switch(icsneo_device_t
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -790,8 +1024,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_set_baudrate_switch(icsneo_device_t
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
auto* const can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -806,8 +1051,19 @@ ICSNEO_API icsneo_error_t icsneo_can_message_get_error_state_indicator(icsneo_de
|
||||||
if (!device || !message || !value) {
|
if (!device || !message || !value) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
// TODO: Check if message is valid
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
// Make sure the message is valid
|
||||||
|
bool is_msg_valid = false;
|
||||||
|
res = icsneo_message_is_valid(device, message, &is_msg_valid);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
} else if (!is_msg_valid) {
|
||||||
|
return icsneo_error_invalid_message;
|
||||||
|
}
|
||||||
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
const auto* can_message = dynamic_cast<CANMessage*>(message->message.get());
|
||||||
if (!can_message) {
|
if (!can_message) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -822,7 +1078,11 @@ ICSNEO_API icsneo_error_t icsneo_can_messages_create(icsneo_device_t* device, ic
|
||||||
if (!device || !messages) {
|
if (!device || !messages) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
auto dev = device->device;
|
auto dev = device->device;
|
||||||
// Get the device messages
|
// Get the device messages
|
||||||
for (uint32_t i = 0; i < messages_count; i++) {
|
for (uint32_t i = 0; i < messages_count; i++) {
|
||||||
|
|
@ -839,7 +1099,11 @@ ICSNEO_API icsneo_error_t icsneo_can_message_free(icsneo_device_t* device, icsne
|
||||||
if (!device || !message) {
|
if (!device || !message) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (auto it = device->tx_messages.begin(); it != device->tx_messages.end(); it++) {
|
for (auto it = device->tx_messages.begin(); it != device->tx_messages.end(); it++) {
|
||||||
if (it->get() == message) {
|
if (it->get() == message) {
|
||||||
|
|
@ -883,7 +1147,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_events(icsneo_device_t* device, icsn
|
||||||
if (!device || !events || !events_count) {
|
if (!device || !events || !events_count) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
// Setup the event filter
|
// Setup the event filter
|
||||||
EventFilter filter(device->device.get());
|
EventFilter filter(device->device.get());
|
||||||
// Clear the device events
|
// Clear the device events
|
||||||
|
|
@ -926,7 +1194,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_rtc(icsneo_device_t* device, int64_t
|
||||||
if (!device || !unix_epoch) {
|
if (!device || !unix_epoch) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (auto rtc_time = device->device->getRTC(); rtc_time != std::nullopt) {
|
if (auto rtc_time = device->device->getRTC(); rtc_time != std::nullopt) {
|
||||||
*unix_epoch = std::chrono::duration_cast<std::chrono::seconds>(rtc_time->time_since_epoch()).count();
|
*unix_epoch = std::chrono::duration_cast<std::chrono::seconds>(rtc_time->time_since_epoch()).count();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -939,7 +1211,11 @@ ICSNEO_API icsneo_error_t icsneo_device_set_rtc(icsneo_device_t* device, int64_t
|
||||||
if (!device || !unix_epoch) {
|
if (!device || !unix_epoch) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (!device->device->setRTC(std::chrono::system_clock::time_point(std::chrono::seconds(*unix_epoch)))) {
|
if (!device->device->setRTC(std::chrono::system_clock::time_point(std::chrono::seconds(*unix_epoch)))) {
|
||||||
return icsneo_error_sync_rtc_failed;
|
return icsneo_error_sync_rtc_failed;
|
||||||
}
|
}
|
||||||
|
|
@ -950,7 +1226,11 @@ ICSNEO_API icsneo_error_t icsneo_device_load_default_settings(icsneo_device_t* d
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (!device->device->settings->applyDefaults(!save)) {
|
if (!device->device->settings->applyDefaults(!save)) {
|
||||||
return icsneo_error_set_settings_failure;
|
return icsneo_error_set_settings_failure;
|
||||||
}
|
}
|
||||||
|
|
@ -962,7 +1242,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_baudrate(icsneo_device_t* device, ic
|
||||||
if (!device || !baudrate) {
|
if (!device || !baudrate) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
*baudrate = device->device->settings->getBaudrateFor(Network(netid));
|
*baudrate = device->device->settings->getBaudrateFor(Network(netid));
|
||||||
if (*baudrate < 0) {
|
if (*baudrate < 0) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -975,7 +1259,11 @@ ICSNEO_API icsneo_error_t icsneo_device_set_baudrate(icsneo_device_t* device, ic
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (!device->device->settings->setBaudrateFor(Network(netid), baudrate)) {
|
if (!device->device->settings->setBaudrateFor(Network(netid), baudrate)) {
|
||||||
return icsneo_error_set_settings_failure;
|
return icsneo_error_set_settings_failure;
|
||||||
}
|
}
|
||||||
|
|
@ -992,7 +1280,11 @@ ICSNEO_API icsneo_error_t icsneo_device_get_canfd_baudrate(icsneo_device_t* devi
|
||||||
if (!device || !baudrate) {
|
if (!device || !baudrate) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
*baudrate = device->device->settings->getFDBaudrateFor(Network(netid));
|
*baudrate = device->device->settings->getFDBaudrateFor(Network(netid));
|
||||||
if (*baudrate < 0) {
|
if (*baudrate < 0) {
|
||||||
return icsneo_error_invalid_type;
|
return icsneo_error_invalid_type;
|
||||||
|
|
@ -1005,7 +1297,11 @@ ICSNEO_API icsneo_error_t icsneo_device_set_canfd_baudrate(icsneo_device_t* devi
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (!device->device->settings->setFDBaudrateFor(Network(netid), baudrate)) {
|
if (!device->device->settings->setFDBaudrateFor(Network(netid), baudrate)) {
|
||||||
return icsneo_error_set_settings_failure;
|
return icsneo_error_set_settings_failure;
|
||||||
}
|
}
|
||||||
|
|
@ -1022,7 +1318,11 @@ ICSNEO_API icsneo_error_t icsneo_device_supports_tc10(icsneo_device_t* device, b
|
||||||
if (!device || !supported) {
|
if (!device || !supported) {
|
||||||
return icsneo_error_invalid_parameters;
|
return icsneo_error_invalid_parameters;
|
||||||
}
|
}
|
||||||
// TODO: Check if device is valid
|
// Make sure the device is valid
|
||||||
|
auto res = icsneo_device_is_valid(device);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
*supported = device->device->supportsTC10();
|
*supported = device->device->supportsTC10();
|
||||||
|
|
||||||
return icsneo_error_success;
|
return icsneo_error_success;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ pybind11_add_module(icsneopy
|
||||||
icsneopy/communication/message/message.cpp
|
icsneopy/communication/message/message.cpp
|
||||||
icsneopy/communication/message/canmessage.cpp
|
icsneopy/communication/message/canmessage.cpp
|
||||||
icsneopy/communication/message/ethernetmessage.cpp
|
icsneopy/communication/message/ethernetmessage.cpp
|
||||||
|
icsneopy/communication/message/linmessage.cpp
|
||||||
icsneopy/communication/message/tc10statusmessage.cpp
|
icsneopy/communication/message/tc10statusmessage.cpp
|
||||||
icsneopy/communication/message/mdiomessage.cpp
|
icsneopy/communication/message/mdiomessage.cpp
|
||||||
icsneopy/communication/message/callback/messagecallback.cpp
|
icsneopy/communication/message/callback/messagecallback.cpp
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ namespace icsneo {
|
||||||
|
|
||||||
void init_messagefilter(pybind11::module_& m) {
|
void init_messagefilter(pybind11::module_& m) {
|
||||||
pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter")
|
pybind11::class_<MessageFilter, std::shared_ptr<MessageFilter>>(m, "MessageFilter")
|
||||||
|
.def(pybind11::init())
|
||||||
.def(pybind11::init<_icsneo_netid_t>());
|
.def(pybind11::init<_icsneo_netid_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include "icsneo/communication/message/linmessage.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
void init_linmessage(pybind11::module_& m) {
|
||||||
|
pybind11::class_<LINErrorFlags>(m, "LINErrorFlags")
|
||||||
|
.def_readwrite("ErrRxBreakOnly", &LINErrorFlags::ErrRxBreakOnly)
|
||||||
|
.def_readwrite("ErrRxBreakSyncOnly", &LINErrorFlags::ErrRxBreakSyncOnly)
|
||||||
|
.def_readwrite("ErrTxRxMismatch", &LINErrorFlags::ErrTxRxMismatch)
|
||||||
|
.def_readwrite("ErrRxBreakNotZero", &LINErrorFlags::ErrRxBreakNotZero)
|
||||||
|
.def_readwrite("ErrRxBreakTooShort", &LINErrorFlags::ErrRxBreakTooShort)
|
||||||
|
.def_readwrite("ErrRxSyncNot55", &LINErrorFlags::ErrRxSyncNot55)
|
||||||
|
.def_readwrite("ErrRxDataLenOver8", &LINErrorFlags::ErrRxDataLenOver8)
|
||||||
|
.def_readwrite("ErrFrameSync", &LINErrorFlags::ErrFrameSync)
|
||||||
|
.def_readwrite("ErrFrameMessageID", &LINErrorFlags::ErrFrameMessageID)
|
||||||
|
.def_readwrite("ErrFrameResponderData", &LINErrorFlags::ErrFrameResponderData)
|
||||||
|
.def_readwrite("ErrChecksumMatch", &LINErrorFlags::ErrChecksumMatch);
|
||||||
|
|
||||||
|
pybind11::class_<LINStatusFlags>(m, "LINStatusFlags")
|
||||||
|
.def_readwrite("TxChecksumEnhanced", &LINStatusFlags::TxChecksumEnhanced)
|
||||||
|
.def_readwrite("TxCommander", &LINStatusFlags::TxCommander)
|
||||||
|
.def_readwrite("TxResponder", &LINStatusFlags::TxResponder)
|
||||||
|
.def_readwrite("TxAborted", &LINStatusFlags::TxAborted)
|
||||||
|
.def_readwrite("UpdateResponderOnce", &LINStatusFlags::UpdateResponderOnce)
|
||||||
|
.def_readwrite("HasUpdatedResponderOnce", &LINStatusFlags::HasUpdatedResponderOnce)
|
||||||
|
.def_readwrite("BusRecovered", &LINStatusFlags::BusRecovered)
|
||||||
|
.def_readwrite("BreakOnly", &LINStatusFlags::BreakOnly);
|
||||||
|
|
||||||
|
pybind11::class_<LINMessage, std::shared_ptr<LINMessage>, BusMessage> linMessage(m, "LINMessage");
|
||||||
|
|
||||||
|
pybind11::enum_<LINMessage::Type>(linMessage, "Type")
|
||||||
|
.value("NOT_SET", LINMessage::Type::NOT_SET)
|
||||||
|
.value("LIN_COMMANDER_MSG", LINMessage::Type::LIN_COMMANDER_MSG)
|
||||||
|
.value("LIN_HEADER_ONLY", LINMessage::Type::LIN_HEADER_ONLY)
|
||||||
|
.value("LIN_BREAK_ONLY", LINMessage::Type::LIN_BREAK_ONLY)
|
||||||
|
.value("LIN_SYNC_ONLY", LINMessage::Type::LIN_SYNC_ONLY)
|
||||||
|
.value("LIN_UPDATE_RESPONDER", LINMessage::Type::LIN_UPDATE_RESPONDER)
|
||||||
|
.value("LIN_ERROR", LINMessage::Type::LIN_ERROR);
|
||||||
|
|
||||||
|
linMessage
|
||||||
|
.def(pybind11::init<>())
|
||||||
|
.def(pybind11::init<uint8_t>())
|
||||||
|
.def_static("calc_checksum", &LINMessage::calcChecksum)
|
||||||
|
.def("calc_protected_id", &LINMessage::calcProtectedID)
|
||||||
|
.def_readwrite("ID", &LINMessage::ID)
|
||||||
|
.def_readwrite("protectedID", &LINMessage::protectedID)
|
||||||
|
.def_readwrite("checksum", &LINMessage::checksum)
|
||||||
|
.def_readwrite("linMsgType", &LINMessage::linMsgType)
|
||||||
|
.def_readwrite("isEnhancedChecksum", &LINMessage::isEnhancedChecksum)
|
||||||
|
.def_readwrite("errFlags", &LINMessage::errFlags)
|
||||||
|
.def_readwrite("statusFlags", &LINMessage::statusFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace icsneo
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace icsneo {
|
||||||
void init_network(pybind11::module_& m) {
|
void init_network(pybind11::module_& m) {
|
||||||
pybind11::class_<Network> network(m, "Network");
|
pybind11::class_<Network> network(m, "Network");
|
||||||
|
|
||||||
pybind11::enum_<_icsneo_netid_t>(network, "_icsneo_netid_t")
|
pybind11::enum_<_icsneo_netid_t>(network, "icsneo_netid_t")
|
||||||
.value("Device", _icsneo_netid_t::icsneo_netid_device)
|
.value("Device", _icsneo_netid_t::icsneo_netid_device)
|
||||||
.value("HSCAN", _icsneo_netid_t::icsneo_netid_hscan)
|
.value("HSCAN", _icsneo_netid_t::icsneo_netid_hscan)
|
||||||
.value("MSCAN", _icsneo_netid_t::icsneo_netid_mscan)
|
.value("MSCAN", _icsneo_netid_t::icsneo_netid_mscan)
|
||||||
|
|
@ -168,6 +168,31 @@ void init_network(pybind11::module_& m) {
|
||||||
.value("Invalid", _icsneo_netid_t::icsneo_netid_invalid);
|
.value("Invalid", _icsneo_netid_t::icsneo_netid_invalid);
|
||||||
|
|
||||||
network.def(pybind11::init<_icsneo_netid_t>());
|
network.def(pybind11::init<_icsneo_netid_t>());
|
||||||
|
|
||||||
|
pybind11::enum_<_icsneo_msg_bus_type_t>(network, "icsneo_msg_bus_type_t")
|
||||||
|
.value("Invalid", icsneo_msg_bus_type_invalid)
|
||||||
|
.value("Internal", icsneo_msg_bus_type_internal)
|
||||||
|
.value("CAN", icsneo_msg_bus_type_can)
|
||||||
|
.value("LIN", icsneo_msg_bus_type_lin)
|
||||||
|
.value("FlexRay", icsneo_msg_bus_type_flexray)
|
||||||
|
.value("MOST", icsneo_msg_bus_type_most)
|
||||||
|
.value("Ethernet", icsneo_msg_bus_type_ethernet)
|
||||||
|
.value("LSFTCAN", icsneo_msg_bus_type_lsftcan)
|
||||||
|
.value("SWCAN", icsneo_msg_bus_type_swcan)
|
||||||
|
.value("ISO9141", icsneo_msg_bus_type_iso9141)
|
||||||
|
.value("I2C", icsneo_msg_bus_type_i2c)
|
||||||
|
.value("A2B", icsneo_msg_bus_type_a2b)
|
||||||
|
.value("SPI", icsneo_msg_bus_type_spi)
|
||||||
|
.value("MDIO", icsneo_msg_bus_type_mdio)
|
||||||
|
.value("Any", icsneo_msg_bus_type_any)
|
||||||
|
.value("Other", icsneo_msg_bus_type_other);
|
||||||
|
|
||||||
|
network
|
||||||
|
.def(pybind11::init<_icsneo_msg_bus_type_t>())
|
||||||
|
.def("__repr__", [](Network& self) { return Network::GetNetIDString(self.getNetID()); })
|
||||||
|
.def_static("get_net_id_string", &Network::GetNetIDString, pybind11::arg("netid"), pybind11::arg("expand") = true)
|
||||||
|
.def("get_net_id", &Network::getNetID)
|
||||||
|
.def("get_type", &Network::getType);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace icsneo
|
} // namespace icsneo
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/stl.h>
|
#include <pybind11/stl.h>
|
||||||
#include <pybind11/functional.h>
|
#include <pybind11/functional.h>
|
||||||
|
#include <pybind11/chrono.h>
|
||||||
|
|
||||||
#include "icsneo/device/device.h"
|
#include "icsneo/device/device.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ void init_devicetype(pybind11::module_&);
|
||||||
void init_message(pybind11::module_&);
|
void init_message(pybind11::module_&);
|
||||||
void init_canmessage(pybind11::module_&);
|
void init_canmessage(pybind11::module_&);
|
||||||
void init_ethernetmessage(pybind11::module_&);
|
void init_ethernetmessage(pybind11::module_&);
|
||||||
|
void init_linmessage(pybind11::module_&);
|
||||||
void init_tc10statusmessage(pybind11::module_&);
|
void init_tc10statusmessage(pybind11::module_&);
|
||||||
void init_mdiomessage(pybind11::module_&);
|
void init_mdiomessage(pybind11::module_&);
|
||||||
void init_device(pybind11::module_&);
|
void init_device(pybind11::module_&);
|
||||||
|
|
@ -33,6 +34,7 @@ PYBIND11_MODULE(icsneopy, m) {
|
||||||
init_message(m);
|
init_message(m);
|
||||||
init_canmessage(m);
|
init_canmessage(m);
|
||||||
init_ethernetmessage(m);
|
init_ethernetmessage(m);
|
||||||
|
init_linmessage(m);
|
||||||
init_tc10statusmessage(m);
|
init_tc10statusmessage(m);
|
||||||
init_mdiomessage(m);
|
init_mdiomessage(m);
|
||||||
init_messagefilter(m);
|
init_messagefilter(m);
|
||||||
|
|
|
||||||
|
|
@ -1951,7 +1951,7 @@ bool Device::setRTC(const std::chrono::time_point<std::chrono::system_clock>& ti
|
||||||
}
|
}
|
||||||
|
|
||||||
auto m51msg = std::dynamic_pointer_cast<Main51Message>(generic);
|
auto m51msg = std::dynamic_pointer_cast<Main51Message>(generic);
|
||||||
if(!m51msg || m51msg->data.size() != 1) {
|
if(!m51msg || m51msg->data.empty() || m51msg->data.size() > 2) {
|
||||||
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
report(APIEvent::Type::MessageFormattingError, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
||||||
makeIfSerialMatches<RADGalaxy>(dev, newFoundDevices);
|
makeIfSerialMatches<RADGalaxy>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADGALAXY2_H_
|
||||||
|
makeIfSerialMatches<RADGalaxy2>(dev, newFoundDevices);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __RADMARS_H_
|
#ifdef __RADMARS_H_
|
||||||
makeIfSerialMatches<RADMars>(dev, newFoundDevices);
|
makeIfSerialMatches<RADMars>(dev, newFoundDevices);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -352,6 +356,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
||||||
RADGalaxy::DEVICE_TYPE,
|
RADGalaxy::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __RADGALAXY2_H_
|
||||||
|
RADGalaxy2::DEVICE_TYPE,
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __RADMARS_H_
|
#ifdef __RADMARS_H_
|
||||||
RADMars::DEVICE_TYPE,
|
RADMars::DEVICE_TYPE,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <icsneo/icsneo.h>
|
#include <icsneo/icsneo.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
@ -61,10 +62,44 @@ 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);
|
int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint32_t messages_count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints device and global events for a given device.
|
||||||
|
*
|
||||||
|
* This function retrieves and prints all current events associated with the specified device,
|
||||||
|
* as well as any global events not tied to a specific device. For each event, it retrieves
|
||||||
|
* and prints a description. If retrieving events or their descriptions fails, an error
|
||||||
|
* message is printed. The function also prints a summary of the count of device-specific
|
||||||
|
* and global events processed.
|
||||||
|
*
|
||||||
|
* @param device A pointer to the icsneo_device_t structure representing the device to get events from.
|
||||||
|
* @param device_description A description of the device used in the output.
|
||||||
|
*/
|
||||||
void print_device_events(icsneo_device_t* device, const char* device_description);
|
void print_device_events(icsneo_device_t* device, const char* device_description);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Transmits a series of CAN messages from a device.
|
||||||
|
*
|
||||||
|
* This function creates and transmits 100 CAN messages with incrementing payload data.
|
||||||
|
* Each message is configured with specific attributes such as network ID, arbitration
|
||||||
|
* ID, CANFD status, extended status, and baudrate switch. After successfully transmitting
|
||||||
|
* each message, it is freed from memory.
|
||||||
|
*
|
||||||
|
* @param device A pointer to the icsneo_device_t structure representing the device to transmit messages from.
|
||||||
|
*
|
||||||
|
* @return An icsneo_error_t value indicating success or failure of the message transmission process.
|
||||||
|
*/
|
||||||
int transmit_can_messages(icsneo_device_t* device);
|
int transmit_can_messages(icsneo_device_t* device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the RTC (Real time clock) of a device and print it.
|
||||||
|
*
|
||||||
|
* @param[in] device The device to get the RTC of.
|
||||||
|
* @param[in] description A description of the device for printing purpose.
|
||||||
|
*
|
||||||
|
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||||
|
*/
|
||||||
|
icsneo_error_t get_and_print_rtc(icsneo_device_t* device, const char* description);
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
@ -118,6 +153,25 @@ int main(int argc, char* argv[]) {
|
||||||
print_device_events(device, description);
|
print_device_events(device, description);
|
||||||
return print_error_code("Failed to open device", res);
|
return print_error_code("Failed to open device", res);
|
||||||
};
|
};
|
||||||
|
// Get RTC
|
||||||
|
res = get_and_print_rtc(device, description);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
print_device_events(device, description);
|
||||||
|
return print_error_code("Failed to get RTC", res);
|
||||||
|
}
|
||||||
|
// Set RTC
|
||||||
|
time_t current_time = time(NULL);
|
||||||
|
res = icsneo_device_set_rtc(device, (int64_t*)¤t_time);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
print_device_events(device, description);
|
||||||
|
return print_error_code("Failed to set RTC", res);
|
||||||
|
}
|
||||||
|
// Get RTC
|
||||||
|
res = get_and_print_rtc(device, description);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
print_device_events(device, description);
|
||||||
|
return print_error_code("Failed to get RTC", res);
|
||||||
|
}
|
||||||
// Get/Set baudrate for HSCAN
|
// Get/Set baudrate for HSCAN
|
||||||
uint64_t baudrate = 0;
|
uint64_t baudrate = 0;
|
||||||
res = icsneo_device_get_baudrate(device, icsneo_netid_hscan, &baudrate);
|
res = icsneo_device_get_baudrate(device, icsneo_netid_hscan, &baudrate);
|
||||||
|
|
@ -135,6 +189,7 @@ int main(int argc, char* argv[]) {
|
||||||
return print_error_code("Failed to transmit CAN messages", res);
|
return print_error_code("Failed to transmit CAN messages", res);
|
||||||
};
|
};
|
||||||
printf("HSCAN CANFD baudrate: %llu\n", baudrate);
|
printf("HSCAN CANFD baudrate: %llu\n", baudrate);
|
||||||
|
|
||||||
// Transmit CAN messages
|
// Transmit CAN messages
|
||||||
res = transmit_can_messages(device);
|
res = transmit_can_messages(device);
|
||||||
if (res != icsneo_error_success) {
|
if (res != icsneo_error_success) {
|
||||||
|
|
@ -173,6 +228,19 @@ int main(int argc, char* argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icsneo_error_t get_and_print_rtc(icsneo_device_t* device, const char* description) {
|
||||||
|
time_t unix_epoch = 0;
|
||||||
|
icsneo_error_t res = icsneo_device_get_rtc(device, &unix_epoch);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
char rtc_time[32] = {0};
|
||||||
|
strftime(rtc_time, sizeof(rtc_time), "%Y-%m-%d %H:%M:%S", localtime(&unix_epoch));
|
||||||
|
printf("RTC: %lld %s\n", unix_epoch, rtc_time);
|
||||||
|
|
||||||
|
return icsneo_error_success;
|
||||||
|
}
|
||||||
|
|
||||||
void print_device_events(icsneo_device_t* device, const char* device_description) {
|
void print_device_events(icsneo_device_t* device, const char* device_description) {
|
||||||
// Get device events
|
// Get device events
|
||||||
icsneo_event_t* events[1024] = {0};
|
icsneo_event_t* events[1024] = {0};
|
||||||
|
|
@ -221,11 +289,24 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
|
||||||
uint32_t tx_count = 0;
|
uint32_t tx_count = 0;
|
||||||
for (uint32_t i = 0; i < messages_count; i++) {
|
for (uint32_t i = 0; i < messages_count; i++) {
|
||||||
icsneo_message_t* message = messages[i];
|
icsneo_message_t* message = messages[i];
|
||||||
|
// Get the message type
|
||||||
icsneo_msg_type_t msg_type = 0;
|
icsneo_msg_type_t msg_type = 0;
|
||||||
icsneo_error_t res = icsneo_message_get_type(device, message, &msg_type);
|
icsneo_error_t res = icsneo_message_get_type(device, message, &msg_type);
|
||||||
if (res != icsneo_error_success) {
|
if (res != icsneo_error_success) {
|
||||||
return print_error_code("Failed to get message type", res);
|
return print_error_code("Failed to get message type", res);
|
||||||
}
|
}
|
||||||
|
// Get the message type name
|
||||||
|
char msg_type_name[128] = {0};
|
||||||
|
uint32_t msg_type_name_length = 128;
|
||||||
|
res = icsneo_message_get_type_name(msg_type, msg_type_name, &msg_type_name_length);
|
||||||
|
if (res != icsneo_error_success) {
|
||||||
|
return print_error_code("Failed to get message type name", res);
|
||||||
|
}
|
||||||
|
// Check if the message is a bus message, ignore otherwise
|
||||||
|
if (msg_type != icsneo_msg_type_bus) {
|
||||||
|
printf("Ignoring message type: %u (%s)\n", msg_type, msg_type_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
icsneo_msg_bus_type_t bus_type = 0;
|
icsneo_msg_bus_type_t bus_type = 0;
|
||||||
res = icsneo_message_get_bus_type(device, message, &bus_type);
|
res = icsneo_message_get_bus_type(device, message, &bus_type);
|
||||||
if (res != icsneo_error_success) {
|
if (res != icsneo_error_success) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,13 @@ typedef uint16_t neomessagetype_t;
|
||||||
#include "icsneo/communication/network.h"
|
#include "icsneo/communication/network.h"
|
||||||
#include "icsneo/icsneotypes.h"
|
#include "icsneo/icsneotypes.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractMessage {
|
class AbstractMessage {
|
||||||
public:
|
public:
|
||||||
virtual const icsneo_msg_type_t getMsgType() const = 0;
|
virtual const icsneo_msg_type_t getMsgType() const = 0;
|
||||||
|
|
@ -21,6 +25,28 @@ class Message : public AbstractMessage {
|
||||||
public:
|
public:
|
||||||
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_device; }
|
virtual const icsneo_msg_type_t getMsgType() const { return icsneo_msg_type_device; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the string representation of the message type
|
||||||
|
*
|
||||||
|
* @return String representation of the message type
|
||||||
|
*
|
||||||
|
* @see AbstractMessage::getMsgType()
|
||||||
|
*/
|
||||||
|
static std::string getMsgTypeName(icsneo_msg_type_t msg_type) {
|
||||||
|
switch (msg_type) {
|
||||||
|
case icsneo_msg_type_device:
|
||||||
|
return "Device";
|
||||||
|
case icsneo_msg_type_internal:
|
||||||
|
return "Internal";
|
||||||
|
case icsneo_msg_type_bus:
|
||||||
|
return "Bus";
|
||||||
|
// Don't default here so we can rely on the compiler to warn us about missing cases
|
||||||
|
};
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Unknown (" << (int)msg_type << ")";
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
enum class Type : neomessagetype_t {
|
enum class Type : neomessagetype_t {
|
||||||
BusMessage = 0,
|
BusMessage = 0,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
#include <icsneo/icsneotypes.h>
|
#include <icsneo/icsneotypes.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
||||||
class DeviceType {
|
class DeviceType {
|
||||||
|
|
@ -118,6 +118,8 @@ public:
|
||||||
return "neoVI Flex";
|
return "neoVI Flex";
|
||||||
case icsneo_devicetype_rad_galaxy:
|
case icsneo_devicetype_rad_galaxy:
|
||||||
return "RAD-Galaxy";
|
return "RAD-Galaxy";
|
||||||
|
case icsneo_devicetype_rad_galaxy2:
|
||||||
|
return "RAD-Galaxy 2";
|
||||||
case icsneo_devicetype_rad_star2:
|
case icsneo_devicetype_rad_star2:
|
||||||
return "RAD-Star 2";
|
return "RAD-Star 2";
|
||||||
case icsneo_devicetype_vividcan:
|
case icsneo_devicetype_vividcan:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
#ifndef __RADGALAXY2_H_
|
||||||
|
#define __RADGALAXY2_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include "icsneo/device/device.h"
|
||||||
|
#include "icsneo/device/devicetype.h"
|
||||||
|
#include "icsneo/communication/packetizer.h"
|
||||||
|
#include "icsneo/communication/decoder.h"
|
||||||
|
#include "icsneo/disk/extextractordiskreaddriver.h"
|
||||||
|
#include "icsneo/disk/neomemorydiskdriver.h"
|
||||||
|
#include "icsneo/device/tree/radgalaxy2/radgalaxy2settings.h"
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class RADGalaxy2 : public Device {
|
||||||
|
public:
|
||||||
|
// Serial numbers start with G2
|
||||||
|
// Ethernet MAC allocation is 0x17, standard driver is Raw
|
||||||
|
ICSNEO_FINDABLE_DEVICE(RADGalaxy2, icsneo_devicetype_rad_galaxy2, "G2");
|
||||||
|
|
||||||
|
static const std::vector<Network>& GetSupportedNetworks() {
|
||||||
|
static std::vector<Network> supportedNetworks = {
|
||||||
|
icsneo_netid_hscan,
|
||||||
|
icsneo_netid_mscan,
|
||||||
|
icsneo_netid_hscan2,
|
||||||
|
icsneo_netid_hscan3,
|
||||||
|
icsneo_netid_hscan4,
|
||||||
|
icsneo_netid_hscan5,
|
||||||
|
icsneo_netid_hscan6,
|
||||||
|
icsneo_netid_hscan7,
|
||||||
|
|
||||||
|
icsneo_netid_lin,
|
||||||
|
icsneo_netid_lin2,
|
||||||
|
|
||||||
|
icsneo_netid_ethernet,
|
||||||
|
icsneo_netid_ethernet2,
|
||||||
|
icsneo_netid_ethernet3,
|
||||||
|
|
||||||
|
icsneo_netid_op_ethernet1,
|
||||||
|
icsneo_netid_op_ethernet2,
|
||||||
|
icsneo_netid_op_ethernet3,
|
||||||
|
icsneo_netid_op_ethernet4,
|
||||||
|
icsneo_netid_op_ethernet5,
|
||||||
|
icsneo_netid_op_ethernet6,
|
||||||
|
icsneo_netid_op_ethernet7,
|
||||||
|
icsneo_netid_op_ethernet8,
|
||||||
|
icsneo_netid_op_ethernet9,
|
||||||
|
icsneo_netid_op_ethernet10,
|
||||||
|
icsneo_netid_op_ethernet11,
|
||||||
|
icsneo_netid_op_ethernet12,
|
||||||
|
|
||||||
|
icsneo_netid_iso9141,
|
||||||
|
icsneo_netid_iso9141_2,
|
||||||
|
|
||||||
|
icsneo_netid_mdio1,
|
||||||
|
icsneo_netid_mdio2,
|
||||||
|
icsneo_netid_mdio3,
|
||||||
|
icsneo_netid_mdio4,
|
||||||
|
icsneo_netid_mdio5,
|
||||||
|
};
|
||||||
|
return supportedNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getEthernetActivationLineCount() const override { return 1; }
|
||||||
|
|
||||||
|
bool supportsTC10() const override { return true; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RADGalaxy2(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||||
|
initialize<RADGalaxy2Settings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupPacketizer(Packetizer& packetizer) override {
|
||||||
|
Device::setupPacketizer(packetizer);
|
||||||
|
packetizer.disableChecksum = true;
|
||||||
|
packetizer.align16bit = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupEncoder(Encoder& encoder) override {
|
||||||
|
Device::setupEncoder(encoder);
|
||||||
|
encoder.supportCANFD = true;
|
||||||
|
encoder.supportEthPhy = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupDecoder(Decoder& decoder) override {
|
||||||
|
Device::setupDecoder(decoder);
|
||||||
|
decoder.timestampResolution = 10; // Timestamps are in 10ns increments instead of the usual 25ns
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||||
|
for(auto& netid : GetSupportedNetworks())
|
||||||
|
rxNetworks.emplace_back(netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The supported TX networks are the same as the supported RX networks for this device
|
||||||
|
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||||
|
|
||||||
|
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
|
||||||
|
if(message->data.size() < sizeof(radgalaxy2_status_t))
|
||||||
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
|
const radgalaxy2_status_t* status = reinterpret_cast<const radgalaxy2_status_t*>(message->data.data());
|
||||||
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||||
|
return 512*4;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
#ifndef __RADGALAXY2SETTINGS_H_
|
||||||
|
#define __RADGALAXY2SETTINGS_H_
|
||||||
|
|
||||||
|
#include "icsneo/device/idevicesettings.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t ecu_id;
|
||||||
|
uint16_t perf_en;
|
||||||
|
|
||||||
|
/* CAN */
|
||||||
|
CAN_SETTINGS can1;
|
||||||
|
CANFD_SETTINGS canfd1;
|
||||||
|
CAN_SETTINGS can2;
|
||||||
|
CANFD_SETTINGS canfd2;
|
||||||
|
CAN_SETTINGS can3;
|
||||||
|
CANFD_SETTINGS canfd3;
|
||||||
|
CAN_SETTINGS can4;
|
||||||
|
CANFD_SETTINGS canfd4;
|
||||||
|
CAN_SETTINGS can5;
|
||||||
|
CANFD_SETTINGS canfd5;
|
||||||
|
CAN_SETTINGS can6;
|
||||||
|
CANFD_SETTINGS canfd6;
|
||||||
|
CAN_SETTINGS can7;
|
||||||
|
CANFD_SETTINGS canfd7;
|
||||||
|
CAN_SETTINGS can8;
|
||||||
|
CANFD_SETTINGS canfd8;
|
||||||
|
|
||||||
|
// SWCAN_SETTINGS swcan1; G2 does not have SWCAN.
|
||||||
|
uint16_t network_enables;
|
||||||
|
// SWCAN_SETTINGS swcan2; G2 does not have SWCAN.
|
||||||
|
uint16_t network_enables_2;
|
||||||
|
|
||||||
|
uint32_t pwr_man_timeout;
|
||||||
|
uint16_t pwr_man_enable;
|
||||||
|
|
||||||
|
uint16_t network_enabled_on_boot;
|
||||||
|
|
||||||
|
/* ISO15765-2 Transport Layer */
|
||||||
|
uint16_t iso15765_separation_time_offset;
|
||||||
|
|
||||||
|
/* ISO9141 - Keyword */
|
||||||
|
uint16_t iso_9141_kwp_enable_reserved;
|
||||||
|
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
|
||||||
|
uint16_t iso_parity_1;
|
||||||
|
|
||||||
|
uint16_t iso_msg_termination_1;
|
||||||
|
|
||||||
|
uint16_t idle_wakeup_network_enables_1;
|
||||||
|
uint16_t idle_wakeup_network_enables_2;
|
||||||
|
|
||||||
|
/* reserved for T1 networks such as BR1, BR2, etc.. */
|
||||||
|
uint16_t network_enables_3;
|
||||||
|
uint16_t idle_wakeup_network_enables_3;
|
||||||
|
|
||||||
|
STextAPISettings text_api;
|
||||||
|
|
||||||
|
uint64_t termination_enables; // New feature unlike Galaxy.
|
||||||
|
|
||||||
|
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t hwComLatencyTestEn : 1;
|
||||||
|
uint16_t reserved : 15;
|
||||||
|
} flags;
|
||||||
|
|
||||||
|
LIN_SETTINGS lin1;
|
||||||
|
|
||||||
|
OP_ETH_GENERAL_SETTINGS opEthGen;
|
||||||
|
OP_ETH_SETTINGS opEth1;
|
||||||
|
OP_ETH_SETTINGS opEth2;
|
||||||
|
OP_ETH_SETTINGS opEth3;
|
||||||
|
OP_ETH_SETTINGS opEth4;
|
||||||
|
OP_ETH_SETTINGS opEth5;
|
||||||
|
OP_ETH_SETTINGS opEth6;
|
||||||
|
OP_ETH_SETTINGS opEth7;
|
||||||
|
OP_ETH_SETTINGS opEth8;
|
||||||
|
OP_ETH_SETTINGS opEth9;
|
||||||
|
OP_ETH_SETTINGS opEth10;
|
||||||
|
OP_ETH_SETTINGS opEth11;
|
||||||
|
OP_ETH_SETTINGS opEth12;
|
||||||
|
OP_ETH_SETTINGS opEth13;
|
||||||
|
OP_ETH_SETTINGS opEth14;
|
||||||
|
OP_ETH_SETTINGS opEth15;
|
||||||
|
OP_ETH_SETTINGS opEth16;
|
||||||
|
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g;
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g_2;
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g_3;
|
||||||
|
|
||||||
|
uint16_t network_enables_4;
|
||||||
|
RAD_REPORTING_SETTINGS reporting;
|
||||||
|
RAD_GPTP_SETTINGS gPTP;
|
||||||
|
|
||||||
|
uint64_t network_enables_5;
|
||||||
|
|
||||||
|
LIN_SETTINGS lin2;
|
||||||
|
} radgalaxy2_settings_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t unused[3];
|
||||||
|
uint8_t ethernetActivationLineEnabled;
|
||||||
|
} radgalaxy2_status_t;
|
||||||
|
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class RADGalaxy2Settings : public IDeviceSettings {
|
||||||
|
public:
|
||||||
|
RADGalaxy2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(radgalaxy2_settings_t)) {}
|
||||||
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
|
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case icsneo_netid_hscan:
|
||||||
|
return &(cfg->can1);
|
||||||
|
case icsneo_netid_mscan:
|
||||||
|
return &(cfg->can2);
|
||||||
|
case icsneo_netid_hscan2:
|
||||||
|
return &(cfg->can3);
|
||||||
|
case icsneo_netid_hscan3:
|
||||||
|
return &(cfg->can4);
|
||||||
|
case icsneo_netid_hscan4:
|
||||||
|
return &(cfg->can5);
|
||||||
|
case icsneo_netid_hscan5:
|
||||||
|
return &(cfg->can6);
|
||||||
|
case icsneo_netid_hscan6:
|
||||||
|
return &(cfg->can7);
|
||||||
|
case icsneo_netid_hscan7:
|
||||||
|
return &(cfg->can8);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||||
|
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case icsneo_netid_hscan:
|
||||||
|
return &(cfg->canfd1);
|
||||||
|
case icsneo_netid_mscan:
|
||||||
|
return &(cfg->canfd2);
|
||||||
|
case icsneo_netid_hscan2:
|
||||||
|
return &(cfg->canfd3);
|
||||||
|
case icsneo_netid_hscan3:
|
||||||
|
return &(cfg->canfd4);
|
||||||
|
case icsneo_netid_hscan4:
|
||||||
|
return &(cfg->canfd5);
|
||||||
|
case icsneo_netid_hscan5:
|
||||||
|
return &(cfg->canfd6);
|
||||||
|
case icsneo_netid_hscan6:
|
||||||
|
return &(cfg->canfd7);
|
||||||
|
case icsneo_netid_hscan7:
|
||||||
|
return &(cfg->canfd8);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const LIN_SETTINGS* getLINSettingsFor(Network net) const override {
|
||||||
|
auto cfg = getStructurePointer<radgalaxy2_settings_t>();
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case icsneo_netid_lin:
|
||||||
|
return &(cfg->lin1);
|
||||||
|
case icsneo_netid_lin2:
|
||||||
|
return &(cfg->lin2);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -220,7 +220,7 @@ typedef unsigned __int64 uint64_t;
|
||||||
#define NEODEVICE_RADEPSILON_EXPRESS (0x0000001d)
|
#define NEODEVICE_RADEPSILON_EXPRESS (0x0000001d)
|
||||||
#define NEODEVICE_RADPROXIMA (0x0000001e)
|
#define NEODEVICE_RADPROXIMA (0x0000001e)
|
||||||
#define NEODEVICE_NEW_DEVICE_58 (0x0000001f)
|
#define NEODEVICE_NEW_DEVICE_58 (0x0000001f)
|
||||||
#define NEODEVICE_NEW_DEVICE_59 (0x00000021)
|
#define NEODEVICE_RAD_GALAXY_2 (0x00000021)
|
||||||
#define NEODEVICE_RAD_BMS (0x00000022)
|
#define NEODEVICE_RAD_BMS (0x00000022)
|
||||||
#define NEODEVICE_RADMOON3 (0x00000023)
|
#define NEODEVICE_RADMOON3 (0x00000023)
|
||||||
#define NEODEVICE_RADCOMET (0x00000024)
|
#define NEODEVICE_RADCOMET (0x00000024)
|
||||||
|
|
@ -2999,6 +2999,100 @@ typedef struct _SRADGigastarSettings
|
||||||
|
|
||||||
#define SRADGigastarSettings_SIZE 710
|
#define SRADGigastarSettings_SIZE 710
|
||||||
|
|
||||||
|
typedef struct _SRADGalaxy2Settings
|
||||||
|
{
|
||||||
|
uint32_t ecu_id;
|
||||||
|
uint16_t perf_en;
|
||||||
|
|
||||||
|
/* CAN */
|
||||||
|
CAN_SETTINGS can1;
|
||||||
|
CANFD_SETTINGS canfd1;
|
||||||
|
CAN_SETTINGS can2;
|
||||||
|
CANFD_SETTINGS canfd2;
|
||||||
|
CAN_SETTINGS can3;
|
||||||
|
CANFD_SETTINGS canfd3;
|
||||||
|
CAN_SETTINGS can4;
|
||||||
|
CANFD_SETTINGS canfd4;
|
||||||
|
CAN_SETTINGS can5;
|
||||||
|
CANFD_SETTINGS canfd5;
|
||||||
|
CAN_SETTINGS can6;
|
||||||
|
CANFD_SETTINGS canfd6;
|
||||||
|
CAN_SETTINGS can7;
|
||||||
|
CANFD_SETTINGS canfd7;
|
||||||
|
CAN_SETTINGS can8;
|
||||||
|
CANFD_SETTINGS canfd8;
|
||||||
|
|
||||||
|
// SWCAN_SETTINGS swcan1; G2 does not have SWCAN.
|
||||||
|
uint16_t network_enables;
|
||||||
|
// SWCAN_SETTINGS swcan2; G2 does not have SWCAN.
|
||||||
|
uint16_t network_enables_2;
|
||||||
|
|
||||||
|
uint32_t pwr_man_timeout;
|
||||||
|
uint16_t pwr_man_enable;
|
||||||
|
|
||||||
|
uint16_t network_enabled_on_boot;
|
||||||
|
|
||||||
|
/* ISO15765-2 Transport Layer */
|
||||||
|
uint16_t iso15765_separation_time_offset;
|
||||||
|
|
||||||
|
/* ISO9141 - Keyword */
|
||||||
|
uint16_t iso_9141_kwp_enable_reserved;
|
||||||
|
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_1;
|
||||||
|
uint16_t iso_parity_1;
|
||||||
|
|
||||||
|
uint16_t iso_msg_termination_1;
|
||||||
|
|
||||||
|
uint16_t idle_wakeup_network_enables_1;
|
||||||
|
uint16_t idle_wakeup_network_enables_2;
|
||||||
|
|
||||||
|
/* reserved for T1 networks such as BR1, BR2, etc.. */
|
||||||
|
uint16_t network_enables_3;
|
||||||
|
uint16_t idle_wakeup_network_enables_3;
|
||||||
|
|
||||||
|
STextAPISettings text_api;
|
||||||
|
|
||||||
|
uint64_t termination_enables; // New feature unlike Galaxy.
|
||||||
|
|
||||||
|
TIMESYNC_ICSHARDWARE_SETTINGS timeSyncSettings;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t hwComLatencyTestEn : 1;
|
||||||
|
uint16_t reserved : 15;
|
||||||
|
} flags;
|
||||||
|
|
||||||
|
LIN_SETTINGS lin1;
|
||||||
|
|
||||||
|
OP_ETH_GENERAL_SETTINGS opEthGen;
|
||||||
|
OP_ETH_SETTINGS opEth1;
|
||||||
|
OP_ETH_SETTINGS opEth2;
|
||||||
|
OP_ETH_SETTINGS opEth3;
|
||||||
|
OP_ETH_SETTINGS opEth4;
|
||||||
|
OP_ETH_SETTINGS opEth5;
|
||||||
|
OP_ETH_SETTINGS opEth6;
|
||||||
|
OP_ETH_SETTINGS opEth7;
|
||||||
|
OP_ETH_SETTINGS opEth8;
|
||||||
|
OP_ETH_SETTINGS opEth9;
|
||||||
|
OP_ETH_SETTINGS opEth10;
|
||||||
|
OP_ETH_SETTINGS opEth11;
|
||||||
|
OP_ETH_SETTINGS opEth12;
|
||||||
|
OP_ETH_SETTINGS opEth13;
|
||||||
|
OP_ETH_SETTINGS opEth14;
|
||||||
|
OP_ETH_SETTINGS opEth15;
|
||||||
|
OP_ETH_SETTINGS opEth16;
|
||||||
|
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g;
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g_2;
|
||||||
|
ETHERNET10G_SETTINGS ethernet10g_3;
|
||||||
|
|
||||||
|
uint16_t network_enables_4;
|
||||||
|
RAD_REPORTING_SETTINGS reporting;
|
||||||
|
RAD_GPTP_SETTINGS gPTP;
|
||||||
|
|
||||||
|
uint64_t network_enables_5;
|
||||||
|
LIN_SETTINGS lin2;
|
||||||
|
} SRADGalaxy2Settings;
|
||||||
|
#define SRADGalaxy2Settings_SIZE 840
|
||||||
|
|
||||||
typedef struct _SVividCANSettings
|
typedef struct _SVividCANSettings
|
||||||
{
|
{
|
||||||
uint32_t ecu_id;
|
uint32_t ecu_id;
|
||||||
|
|
@ -5425,6 +5519,7 @@ CHECK_STRUCT_SIZE(SPendantSettings);
|
||||||
CHECK_STRUCT_SIZE(SIEVBSettings);
|
CHECK_STRUCT_SIZE(SIEVBSettings);
|
||||||
CHECK_STRUCT_SIZE(SEEVBSettings);
|
CHECK_STRUCT_SIZE(SEEVBSettings);
|
||||||
CHECK_STRUCT_SIZE(SRADGalaxySettings);
|
CHECK_STRUCT_SIZE(SRADGalaxySettings);
|
||||||
|
CHECK_STRUCT_SIZE(SRADGalaxy2Settings);
|
||||||
CHECK_STRUCT_SIZE(SRADStar2Settings);
|
CHECK_STRUCT_SIZE(SRADStar2Settings);
|
||||||
CHECK_STRUCT_SIZE(SOBD2SimSettings)
|
CHECK_STRUCT_SIZE(SOBD2SimSettings)
|
||||||
CHECK_STRUCT_SIZE(CmProbeSettings);
|
CHECK_STRUCT_SIZE(CmProbeSettings);
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,12 @@ typedef enum _icsneo_error_t {
|
||||||
// Failed to transmit messages
|
// Failed to transmit messages
|
||||||
icsneo_error_transmit_messages_failed,
|
icsneo_error_transmit_messages_failed,
|
||||||
// Failed to copy string to buffer
|
// Failed to copy string to buffer
|
||||||
icsneo_error_string_copy_failed
|
icsneo_error_string_copy_failed,
|
||||||
|
// Invalid device parameter
|
||||||
|
icsneo_error_invalid_device,
|
||||||
|
// Invalid message parameter
|
||||||
|
icsneo_error_invalid_message,
|
||||||
|
// NOTE: Any new values added here should be updated in icsneo_get_error_code
|
||||||
} _icsneo_error_t;
|
} _icsneo_error_t;
|
||||||
|
|
||||||
/** @brief Integer representation of _icsneo_error_t enum.
|
/** @brief Integer representation of _icsneo_error_t enum.
|
||||||
|
|
@ -343,6 +348,17 @@ ICSNEO_API icsneo_error_t icsneo_message_is_valid(icsneo_device_t* device, icsne
|
||||||
*/
|
*/
|
||||||
ICSNEO_API icsneo_error_t icsneo_message_get_type(icsneo_device_t* device, icsneo_message_t* message, icsneo_msg_type_t* msg_type);
|
ICSNEO_API icsneo_error_t icsneo_message_get_type(icsneo_device_t* device, icsneo_message_t* message, icsneo_msg_type_t* msg_type);
|
||||||
|
|
||||||
|
/** @brief Get the message type string for a icsneo_msg_bus_type_t.
|
||||||
|
*
|
||||||
|
* @param[in] icsneo_device_t* device The device to check against.
|
||||||
|
* @param[in] icsneo_message_t* message The message to check.
|
||||||
|
* @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_message_get_type_name(icsneo_msg_type_t msg_type, const char* value, uint32_t* value_length);
|
||||||
|
|
||||||
/** @brief Get the type of a bus message
|
/** @brief Get the type of a bus message
|
||||||
*
|
*
|
||||||
* @param[in] icsneo_device_t* device The device to check against.
|
* @param[in] icsneo_device_t* device The device to check against.
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,8 @@ typedef enum _icsneo_devicetype_t {
|
||||||
icsneo_devicetype_vividcan,
|
icsneo_devicetype_vividcan,
|
||||||
// neoOBD2 SIM
|
// neoOBD2 SIM
|
||||||
icsneo_devicetype_obd2_sim,
|
icsneo_devicetype_obd2_sim,
|
||||||
|
// RAD-Galaxy 2
|
||||||
|
icsneo_devicetype_rad_galaxy2,
|
||||||
|
|
||||||
|
|
||||||
// Must be last entry
|
// Must be last entry
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
|
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
|
||||||
#include "icsneo/device/tree/radepsilon/radepsilon.h"
|
#include "icsneo/device/tree/radepsilon/radepsilon.h"
|
||||||
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
||||||
|
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
|
||||||
#include "icsneo/device/tree/radgigastar/radgigastar.h"
|
#include "icsneo/device/tree/radgigastar/radgigastar.h"
|
||||||
#include "icsneo/device/tree/radgigastar2/radgigastar2.h"
|
#include "icsneo/device/tree/radgigastar2/radgigastar2.h"
|
||||||
#include "icsneo/device/tree/radjupiter/radjupiter.h"
|
#include "icsneo/device/tree/radjupiter/radjupiter.h"
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
|
#include "icsneo/device/tree/radmoont1s/radmoont1s.h"
|
||||||
#include "icsneo/device/tree/radepsilon/radepsilon.h"
|
#include "icsneo/device/tree/radepsilon/radepsilon.h"
|
||||||
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
#include "icsneo/device/tree/radgalaxy/radgalaxy.h"
|
||||||
|
#include "icsneo/device/tree/radgalaxy2/radgalaxy2.h"
|
||||||
#include "icsneo/device/tree/radgigastar/radgigastar.h"
|
#include "icsneo/device/tree/radgigastar/radgigastar.h"
|
||||||
#include "icsneo/device/tree/radgigastar2/radgigastar2.h"
|
#include "icsneo/device/tree/radgigastar2/radgigastar2.h"
|
||||||
#include "icsneo/device/tree/radjupiter/radjupiter.h"
|
#include "icsneo/device/tree/radjupiter/radjupiter.h"
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,21 @@ void TCP::Socket::poll(uint16_t event, uint32_t msTimeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCP::Find(std::vector<FoundDevice>& found) {
|
void TCP::Find(std::vector<FoundDevice>& found) {
|
||||||
|
static const auto tcpDisabled = []() -> bool {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4996)
|
||||||
|
#endif
|
||||||
|
const auto disabled = std::getenv("LIBICSNEO_DISABLE_TCP");
|
||||||
|
return disabled ? std::stoi(disabled) : false;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
if(tcpDisabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static const auto MDNS_PORT = htons((unsigned short)5353);
|
static const auto MDNS_PORT = htons((unsigned short)5353);
|
||||||
static const auto MDNS_IP = htonl((((uint32_t)224U) << 24U) | ((uint32_t)251U));
|
static const auto MDNS_IP = htonl((((uint32_t)224U) << 24U) | ((uint32_t)251U));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue