Skip to content

Commit 5f26bb3

Browse files
changes that made work
1 parent ca17448 commit 5f26bb3

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

NetX/inc/u_nx_ethernet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef enum {
2727
MSB4 = (1 << 6), // 0b01000000
2828
NODE8 = (1 << 7), // 0b10000000
2929
} ethernet_node_t;
30-
#define ETH_IP(node) IP_ADDRESS(239, 0, 0, node)
30+
#define ETH_IP(node) IP_ADDRESS(224, 0, 0, node)
3131

3232
/* These node ids are ONLY relavent to PLCA configuration.
3333
They are meant to be used when configuring a PHY. The IDs must be sequential, and the "0" id always indicates the network's coordinator node.
@@ -55,7 +55,7 @@ typedef struct {
5555
uint8_t recipient_id;
5656
uint8_t message_id;
5757
uint8_t data_length;
58-
uint8_t data[ETH_MESSAGE_SIZE];
58+
uint8_t data[10]; // change back
5959
} ethernet_message_t;
6060

6161
/* Function Pointers (for initialization). */

NetX/src/u_nx_ethernet.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* PRIVATE MACROS */
1010
#define _PACKET_POOL_SIZE \
11-
((sizeof(ethernet_message_t) + sizeof(NX_PACKET)) * ETH_MAX_PACKETS)
11+
((sizeof(ethernet_message_t) + sizeof(NX_PACKET)) * ETH_MAX_PACKETS * 100)
1212
#define _IP_THREAD_STACK_SIZE 2048
1313
#define _ARP_CACHE_SIZE 1024
1414
#define _IP_THREAD_PRIORITY 1
@@ -109,7 +109,7 @@ uint8_t ethernet_init(ethernet_node_t node_id, DriverFunction driver, OnRecieve
109109
status = nx_packet_pool_create(
110110
&device.packet_pool, // Pointer to the packet pool instance
111111
"Ethernet Packet Pool", // Name
112-
sizeof(ethernet_message_t), // Payload size (i.e. the size of each packet)
112+
sizeof(ethernet_message_t) + 128, // Payload size (i.e. the size of each packet)
113113
device.packet_pool_memory, // Pointer to the pool's memory area
114114
_PACKET_POOL_SIZE // Size of the pool's memory area
115115
);
@@ -263,6 +263,18 @@ uint8_t ethernet_send_message(ethernet_message_t *message) {
263263
return U_ERROR;
264264
}
265265

266+
PRINTLN_INFO("got to this part of ethernet_send_message()");
267+
268+
/* Make sure interface is up. */
269+
ULONG actual_status = 0;
270+
status = nx_ip_interface_status_check(&device.ip, 0, NX_IP_LINK_ENABLED, &actual_status, TX_WAIT_FOREVER);
271+
if(status != NX_SUCCESS) {
272+
PRINTLN_ERROR("Failed to call nx_ip_interface_status_check() (Status: %d/%s).", status, nx_status_toString(status));
273+
return U_ERROR;
274+
} else {
275+
PRINTLN_INFO("Succeeded calling nx_ip_interface_status_check() (Status: %d/%s).", status, nx_status_toString(status));
276+
}
277+
266278
/* Allocate a packet */
267279
status = nx_packet_allocate(
268280
&device.packet_pool, // Packet pool
@@ -275,6 +287,8 @@ uint8_t ethernet_send_message(ethernet_message_t *message) {
275287
return U_ERROR;
276288
}
277289

290+
PRINTLN_INFO("got to nx_packet_allocate() part of send message");
291+
278292
/* Append message data to packet */
279293
status = nx_packet_data_append(
280294
packet, // Packet
@@ -289,6 +303,16 @@ uint8_t ethernet_send_message(ethernet_message_t *message) {
289303
return U_ERROR;
290304
}
291305

306+
PRINTLN_INFO("got to nx_packet_data_append() part of send message");
307+
308+
ULONG length = 0;
309+
status = nx_packet_length_get(packet, &length);
310+
if(status != NX_SUCCESS) {
311+
PRINTLN_ERROR("Failed to call nx_packet_length_get() (Status: %d/%n).", status, nx_status_toString(status));
312+
} else {
313+
PRINTLN_INFO("Packet has length of %d!", length);
314+
}
315+
292316
/* Send message */
293317
status = nx_udp_socket_send(
294318
&device.socket,
@@ -297,12 +321,14 @@ uint8_t ethernet_send_message(ethernet_message_t *message) {
297321
ETH_UDP_PORT
298322
);
299323
if(status != NX_SUCCESS) {
300-
PRINTLN_ERROR("Failed to send packet (Status: %d/%s, Message ID: %d).", status, nx_status_toString(status), message->message_id);
324+
PRINTLN_ERROR("Failed to send packet (Status: %d/%s, Message ID: %d, Recipient ID: %d, IP Address: %d, IP components: 224.0.0.%d).", status, nx_status_toString(status), message->message_id, message->recipient_id, ETH_IP(message->recipient_id), ETH_IP(message->recipient_id));
301325
nx_packet_release(packet);
302326
return U_ERROR;
303327
}
304328

305-
PRINTLN_INFO("Sent ethernet message (Recipient ID: %d, Message ID: %d).", message->recipient_id, message->message_id);
329+
PRINTLN_INFO("got to nx_udp_socket_send() part of send message");
330+
331+
PRINTLN_INFO("Sent ethernet message (Recipient ID: %d, Message ID: %d, Message Contents: %d).", message->recipient_id, message->message_id, message->data);
306332
return U_SUCCESS;
307333
}
308334
// clang-format on

0 commit comments

Comments
 (0)