Skip to content

Commit b3b0f9f

Browse files
removed queue size validation and increased ethernet message size
1 parent cc59918 commit b3b0f9f

2 files changed

Lines changed: 6 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

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)