added icsneo_message_is_transmit
parent
f58f478ddb
commit
bac4d86c57
|
|
@ -500,6 +500,23 @@ ICSNEO_API icsneo_error_t icsneo_get_bus_type_name(icsneo_msg_bus_type_t* bus_ty
|
|||
return safe_str_copy(value, value_length, bus_type_str) ? icsneo_error_success : icsneo_error_string_copy_failed;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_message_is_transmit(icsneo_device_t* device, icsneo_message_t* message, bool* value) {
|
||||
if (!device || !message || !value) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
}
|
||||
// TODO: Check if message is valid
|
||||
|
||||
// Make sure the message is a bus message
|
||||
if (message->message->getMsgType() != icsneo_msg_type_bus) {
|
||||
return icsneo_error_invalid_type;
|
||||
}
|
||||
// We can static cast here because we are relying on the type being correct at this point
|
||||
auto bus_message = static_cast<BusMessage*>(message->message.get());
|
||||
*value = bus_message->transmitted;
|
||||
|
||||
return icsneo_error_success;
|
||||
}
|
||||
|
||||
ICSNEO_API icsneo_error_t icsneo_message_get_netid(icsneo_device_t* device, icsneo_message_t* message, icsneo_netid_t* netid) {
|
||||
if (!device || !message || !netid) {
|
||||
return icsneo_error_invalid_parameters;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
|
|||
bool is_remote = false;
|
||||
bool is_canfd = false;
|
||||
bool is_extended = false;
|
||||
bool is_tx = false;
|
||||
uint8_t data[64] = {0};
|
||||
uint32_t data_length = 64;
|
||||
const char netid_name[128] = {0};
|
||||
|
|
@ -241,11 +242,12 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
|
|||
result += icsneo_can_message_is_canfd(device, message, &is_canfd);
|
||||
result += icsneo_can_message_is_extended(device, message, &is_extended);
|
||||
result += icsneo_message_get_data(device, message, data, &data_length);
|
||||
result += icsneo_message_is_transmit(device, message, &is_tx);
|
||||
if (result != icsneo_error_success) {
|
||||
printf("\tFailed get get CAN parameters (error: %u) for index %u\n", result, i);
|
||||
continue;
|
||||
}
|
||||
printf("\t NetID: %s (0x%x)\tArbID: 0x%x\t DLC: %u\t Remote: %d\t CANFD: %d\t Extended: %d\t Data length: %u\n", netid_name, netid, arbid, dlc, is_remote, is_canfd, is_extended, data_length);
|
||||
printf("\t NetID: %s (0x%x)\tArbID: 0x%x\t DLC: %u\t TX: %d\t Remote: %d\t CANFD: %d\t Extended: %d\t Data length: %u\n", netid_name, netid, arbid, dlc, is_tx, is_remote, is_canfd, is_extended, data_length);
|
||||
printf("\t Data: [");
|
||||
for (uint32_t x = 0; x < data_length; x++) {
|
||||
printf(" 0x%x", data[x]);
|
||||
|
|
@ -273,8 +275,7 @@ int process_messages(icsneo_device_t* device, icsneo_message_t** messages, uint3
|
|||
int transmit_can_messages(icsneo_device_t* device) {
|
||||
uint64_t counter = 0;
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < 20000; i++) {
|
||||
for (uint32_t i = 0; i < 100; i++) {
|
||||
// Create the message
|
||||
icsneo_message_t* message = NULL;
|
||||
uint32_t message_count = 1;
|
||||
|
|
@ -289,7 +290,7 @@ int transmit_can_messages(icsneo_device_t* device) {
|
|||
res += icsneo_can_message_set_extended(device, message, true);
|
||||
res += icsneo_can_message_set_baudrate_switch(device, message, true);
|
||||
// Create the payload
|
||||
uint8_t data[64] = {0};
|
||||
uint8_t data[8] = {0};
|
||||
data[0] = (uint8_t)(counter >> 56);
|
||||
data[1] = (uint8_t)(counter >> 48);
|
||||
data[2] = (uint8_t)(counter >> 40);
|
||||
|
|
@ -298,7 +299,6 @@ int transmit_can_messages(icsneo_device_t* device) {
|
|||
data[5] = (uint8_t)(counter >> 16);
|
||||
data[6] = (uint8_t)(counter >> 8);
|
||||
data[7] = (uint8_t)(counter >> 0);
|
||||
data[63] = 0xCA;
|
||||
res += icsneo_message_set_data(device, message, data, sizeof(data));
|
||||
res += icsneo_can_message_set_dlc(device, message, -1);
|
||||
if (res != icsneo_error_success) {
|
||||
|
|
|
|||
|
|
@ -365,6 +365,19 @@ ICSNEO_API icsneo_error_t icsneo_message_get_bus_type(icsneo_device_t* device, i
|
|||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_get_bus_type_name(icsneo_msg_bus_type_t* bus_type, const char* value, uint32_t* value_length);
|
||||
|
||||
/** @brief Get the transmission status of a message.
|
||||
*
|
||||
* When a message is transmitted from the device, It will be returned in the receive buffer.
|
||||
* @see icsneo_device_transmit_messages
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to modify.
|
||||
* @param[out] bool value Pointer to a bool to copy the tranmission status into.
|
||||
*
|
||||
* @return icsneo_error_t icsneo_error_success if successful, icsneo_error_invalid_parameters otherwise.
|
||||
*/
|
||||
ICSNEO_API icsneo_error_t icsneo_message_is_transmit(icsneo_device_t* device, icsneo_message_t* message, bool* value);
|
||||
|
||||
/** @brief Get the Network ID (netid) of a bus message
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
|
|
@ -398,6 +411,8 @@ ICSNEO_API icsneo_error_t icsneo_get_netid_name(icsneo_netid_t netid, const char
|
|||
ICSNEO_API icsneo_error_t icsneo_message_set_netid(icsneo_device_t* device, icsneo_message_t* message, icsneo_netid_t netid);
|
||||
|
||||
/** @brief Set the data bytes of a message
|
||||
*
|
||||
* @note This function will not set the DLC of the message. @see icsneo_message_set_dlc
|
||||
*
|
||||
* @param[in] icsneo_device_t* device The device to check against.
|
||||
* @param[in] icsneo_message_t* message The message to copy the data into.
|
||||
|
|
|
|||
Loading…
Reference in New Issue