|
4 | 4 | #include "nxd_ptp_client.h" |
5 | 5 | #include "u_nx_debug.h" |
6 | 6 | #include "u_tx_debug.h" |
| 7 | +#include "c_utils.h" |
7 | 8 | #include "nx_api.h" |
8 | 9 | #include <string.h> |
9 | 10 | #include <stdio.h> |
@@ -113,20 +114,15 @@ static void _receive_message(NX_UDP_SOCKET *socket) { |
113 | 114 | } |
114 | 115 |
|
115 | 116 | /* Extract message from packet */ |
116 | | - status = nx_packet_data_extract_offset( |
117 | | - packet, // Packet to extract from |
118 | | - 0, // Offset (start of packet) |
119 | | - &message, // Message buffer |
120 | | - sizeof(ethernet_message_t), // Size to extract |
121 | | - &bytes_copied // Stores how many bytes were actually copied to &message |
122 | | - ); |
123 | | - if(bytes_copied < sizeof(ethernet_message_t)) { |
124 | | - PRINTLN_WARNING("Received ethernet message was smaller than expected (only received %lu of %u expected bytes).", bytes_copied, sizeof(ethernet_message_t)); |
| 117 | + ULONG bytes_copied = 0; |
| 118 | + status = nx_packet_data_retrieve(packet, &message, &bytes_copied); |
| 119 | + if(status != NX_SUCCESS) { |
| 120 | + PRINTLN_ERROR("Failed to call nx_packet_data_retrieve() (Status: %d/%s).", status, nx_status_toString(status)); |
125 | 121 | } |
126 | 122 |
|
127 | 123 | /* Process received message */ |
128 | 124 | if(status == NX_SUCCESS) { |
129 | | - PRINTLN_INFO("Received ethernet message! (Sender ID: %d, Message ID: %d).", message.sender_id, message.message_id); |
| 125 | + PRINTLN_INFO("Received ethernet message! (Sender ID: %d, Message ID: %d, bytes_copied: %d).", message.sender_id, message.message_id, bytes_copied); |
130 | 126 | device.on_recieve(message); |
131 | 127 | } |
132 | 128 | } |
|
0 commit comments