Skip to content

Commit 1540bd7

Browse files
joerghonashif
authored andcommitted
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 <[email protected]>
1 parent be7445d commit 1540bd7

File tree

1 file changed

+2
-2
lines changed
  • samples/modules/nanopb/src

1 file changed

+2
-2
lines changed

samples/modules/nanopb/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ bool encode_message(uint8_t *buffer, size_t buffer_size, size_t *message_length)
3030

3131
/* Fill in the lucky number */
3232
message.lucky_number = 13;
33-
for (int i = 0; i < 8; ++i) {
33+
for (int i = 0; i < CONFIG_SAMPLE_BUFFER_SIZE; ++i) {
3434
message.buffer[i] = (uint8_t)(i * 2);
3535
}
3636
#ifdef CONFIG_SAMPLE_UNLUCKY_NUMBER
@@ -66,7 +66,7 @@ bool decode_message(uint8_t *buffer, size_t message_length)
6666
/* Print the data contained in the message. */
6767
printk("Your lucky number was %d!\n", (int)message.lucky_number);
6868
printk("Buffer contains: ");
69-
for (int i = 0; i < 8; ++i) {
69+
for (int i = 0; i < CONFIG_SAMPLE_BUFFER_SIZE; ++i) {
7070
printk("%s%d", ((i == 0) ? "" : ", "), (int) message.buffer[i]);
7171
}
7272
printk("\n");

0 commit comments

Comments
 (0)