Skip to content

Commit

Permalink
samples: modules: nanopb: display buffer content of correct size
Browse files Browse the repository at this point in the history
With commit ad242b9, the buffer size was made configurable. Hence, the
corresponding definition CONFIG_SAMPLE_BUFFER_SIZE has to be used when
filling and displaying the buffer.

Signed-off-by: Joerg Hofrichter <[email protected]>
  • Loading branch information
joergho authored and nashif committed Aug 30, 2024
1 parent be7445d commit 1540bd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/modules/nanopb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool encode_message(uint8_t *buffer, size_t buffer_size, size_t *message_length)

/* Fill in the lucky number */
message.lucky_number = 13;
for (int i = 0; i < 8; ++i) {
for (int i = 0; i < CONFIG_SAMPLE_BUFFER_SIZE; ++i) {
message.buffer[i] = (uint8_t)(i * 2);
}
#ifdef CONFIG_SAMPLE_UNLUCKY_NUMBER
Expand Down Expand Up @@ -66,7 +66,7 @@ bool decode_message(uint8_t *buffer, size_t message_length)
/* Print the data contained in the message. */
printk("Your lucky number was %d!\n", (int)message.lucky_number);
printk("Buffer contains: ");
for (int i = 0; i < 8; ++i) {
for (int i = 0; i < CONFIG_SAMPLE_BUFFER_SIZE; ++i) {
printk("%s%d", ((i == 0) ? "" : ", "), (int) message.buffer[i]);
}
printk("\n");
Expand Down

0 comments on commit 1540bd7

Please sign in to comment.