Skip to content

Commit f521b40

Browse files
Modified Queue Size Checking and Increased Ethernet Message Size (#374)
Co-authored-by: Jack Rubacha <rubacha.jack03@gmail.com>
1 parent 3a81f84 commit f521b40

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

NetX/inc/u_nx_ethernet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/* CONFIG */
1616
#define ETH_UDP_PORT 2006 /* UDP port for communication */
17-
#define ETH_MESSAGE_SIZE 60 /* Maximum ethernet message size in bytes. */
17+
#define ETH_MESSAGE_SIZE 128 /* Maximum ethernet message size in bytes. */
1818
#define ETH_MAX_PACKETS 10 /* Maximum number of packets we wanna handle simultaneously */
1919
#define ETH_NUMBER_OF_NODES 8 /* Number of nodes in the network. */
2020

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/Middlewares/ST/threadx/common/src/txe_queue_create.c b/Middlewares/ST/threadx/common/src/txe_queue_create.c
2+
index 592d0a8..9e73537 100644
3+
--- a/Middlewares/ST/threadx/common/src/txe_queue_create.c
4+
+++ b/Middlewares/ST/threadx/common/src/txe_queue_create.c
5+
@@ -31,6 +31,8 @@
6+
#include "tx_thread.h"
7+
#include "tx_queue.h"
8+
9+
+/* Macro to configure max queue message sizes. This is a value in 32-bit words, so the message size in bytes would be (U_MAX_QUEUE_MESSAGE_SIZE * 4) */
10+
+#define U_MAX_QUEUE_MESSAGE_SIZE ((UINT) 128)
11+
12+
/**************************************************************************/
13+
/* */
14+
@@ -180,7 +182,7 @@ TX_THREAD *thread_ptr;
15+
}
16+
17+
/* Check for an invalid message size - greater than 16. */
18+
- else if (message_size > TX_16_ULONG)
19+
+ else if (message_size > U_MAX_QUEUE_MESSAGE_SIZE)
20+
{
21+
22+
/* Invalid message size specified. */

threadX/src/u_tx_queues.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ uint8_t create_queue(TX_BYTE_POOL *byte_pool, queue_t *queue)
88
uint8_t status;
99
void *pointer;
1010

11-
/* Calculate message size in 32-bit words (round up), and then validate it. */
12-
/* According to the Azure RTOS ThreadX Docs, "message sizes range from 1 32-bit word to 16 32-bit words". */
11+
/* Calculate message size in 32-bit words (round up). */
12+
/* According to the Azure RTOS ThreadX Docs, message sizes have to be given in 32-bit words. */
1313
/* Basically, queue messages have to be a multiple of 4 bytes? Kinda weird but this should handle it. */
1414
UINT message_size_words = (queue->message_size + 3) / 4;
15-
if (message_size_words < 1 || message_size_words > 16) {
16-
PRINTLN_ERROR("Invalid message size %d bytes (must be 1-64 bytes). Queue: %s", queue->message_size, queue->name);
17-
return U_ERROR;
18-
}
15+
// Not going to validate the size of message_size_words, because if it's invalid, ThreadX should return a TX_SIZE_ERROR.
1916

2017
/* Store metadata */
2118
queue->_bytes = queue->message_size;
@@ -27,14 +24,14 @@ uint8_t create_queue(TX_BYTE_POOL *byte_pool, queue_t *queue)
2724
/* Allocate the stack for the queue. */
2825
status = tx_byte_allocate(byte_pool, (VOID **)&pointer, queue_size_bytes, TX_NO_WAIT);
2926
if (status != TX_SUCCESS) {
30-
PRINTLN_ERROR("Failed to allocate memory before creating queue (Status: %d/%s, Queue: %s).", status, tx_status_toString(status), queue->name);
27+
PRINTLN_ERROR("Failed to allocate memory before creating queue (Status: %d/%s, Queue: %s, queue_size_bytes: %d).", status, tx_status_toString(status), queue->name, queue_size_bytes);
3128
return U_ERROR;
3229
}
3330

3431
/* Create the queue */
3532
status = tx_queue_create(&queue->_TX_QUEUE, (CHAR *)queue->name, message_size_words, pointer, queue_size_bytes);
3633
if (status != TX_SUCCESS) {
37-
PRINTLN_ERROR("Failed to create queue (Status: %d/%s, Queue: %s).", status, tx_status_toString(status), queue->name);
34+
PRINTLN_ERROR("Failed to create queue (Status: %d/%s, Queue: %s, message_size_words: %d, queue_size_bytes: %d).", status, tx_status_toString(status), queue->name, message_size_words, queue_size_bytes);
3835
tx_byte_release(pointer); // Free allocated memory if queue creation fails
3936
return U_ERROR;
4037
}

0 commit comments

Comments
 (0)