samples: modules: nanopb: display buffer content of correct size

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 <joerg.hofrichter@ni.com>
This commit is contained in:
Joerg Hofrichter 2024-08-30 12:49:06 +02:00 committed by Anas Nashif
parent be7445de04
commit 1540bd7d49
1 changed files with 2 additions and 2 deletions

View File

@ -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
@ -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");