This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_LOG_HEXDUMP_INFO Extra Characters

I'm trying to print a 20 byte array over uart before sending it on BLE. My array contains:

{0x34, 0x12, 0x00, 0xFF, 0x00, 0xFF, ..., 0x00, 0xFF}

However when I try to use the NRF_LOG_HEXDUMP_INFO function to print this it only prints 8 bytes per line and I get a bunch of garbage characters at the end of each line:

<info> app:  34 12 00 FF 00 FF 00 FF|4..▒.▒.▒
<info> app:  00 FF 00 FF 00 FF 00 FF|.▒.▒.▒.▒
<info> app:  00 FF 00 FF            |.▒.▒
<info> app:  34 12 00 FF 00 FF 00 FF|4..▒.▒.▒
<info> app:  00 FF 00 FF 00 FF 00 FF|.▒.▒.▒.▒
<info> app:  00 FF 00 FF            |.▒.▒

Does anyone know what's causing this or how to fix it so that it prints all 20 bytes on 1 line without the garbage at the end? I've tried adding a CR and newline at the end of the array but that made no difference.

Parents
  • No, but you can make one yourself:

    void NRF_LOG_INFO_ARRAY(uint8_t * array, uint8_t array_size)
    {
        for(int i = 0; i < array_size; i++)
        {
            NRF_LOG_RAW_INFO("0x%x ",array[i]);
        }
        NRF_LOG_RAW_INFO("\r\n");
    }
    
    uint8_t const size = 20;
    uint8_t array[size] = {0x34, 0x12, 0x36, 0x38, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, \
                           0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF};
    NRF_LOG_INFO_ARRAY(array, size);
    

    Best regards,

    Jørgen

Reply
  • No, but you can make one yourself:

    void NRF_LOG_INFO_ARRAY(uint8_t * array, uint8_t array_size)
    {
        for(int i = 0; i < array_size; i++)
        {
            NRF_LOG_RAW_INFO("0x%x ",array[i]);
        }
        NRF_LOG_RAW_INFO("\r\n");
    }
    
    uint8_t const size = 20;
    uint8_t array[size] = {0x34, 0x12, 0x36, 0x38, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, \
                           0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF};
    NRF_LOG_INFO_ARRAY(array, size);
    

    Best regards,

    Jørgen

Children
No Data
Related