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

Looking for a serial print function with no predefined formats

I try to print with serial. How can I print something without a format. I want to print it directly. If yes, which function should I call?

For example, What I am looking for: if I print "ABC", I receive only 41 42 43 and some padding zeros from the serial window.

My current situation is that when I try to print "EVA", what I get is  "45 56 41                |EVA            "

For this example, I print "EVA" by using the NRF_LOG_RAW_HEXDUMP_INFO(pointer of the data, 3);

Output from the serial window:

Parents
  • Hi,

    What you see in the PC application that you use, are both a listing of the hexadecimal values of the bytes sent over UART (e.g. "45 56 41") and the same data printed out as ASCII text (e.g. "EVA"). Those are two ways to display the same binary data (the three bytes that you send.) The specific format that you see in the application, is something that the application made. The data sent over UART was always the three bytes representing the ascii text "EVA".

    Regards,
    Terje

  • Thanks for your reply, but I have tried to use NRF_LOG_RAW_INFO("ABC"); to print it as desired.

    But the problem is how can I print the data from with a pointer. I tried to use .NRF_LOG_RAW_INFO(pointer), aiming to print the 'A' at the pointer. However, it fails.

    The pointer points to the p.data of the scanned buffer. An"ABC" is saved in this scanned buffer. I tried to create a variable of char/uint8_t to store the data located by the pointer but I cannot get it printed correctly. 

    Can you aid me with how to cast this pointer into a printable string for the function NRF_LOG_RAW_INFO?

Reply
  • Thanks for your reply, but I have tried to use NRF_LOG_RAW_INFO("ABC"); to print it as desired.

    But the problem is how can I print the data from with a pointer. I tried to use .NRF_LOG_RAW_INFO(pointer), aiming to print the 'A' at the pointer. However, it fails.

    The pointer points to the p.data of the scanned buffer. An"ABC" is saved in this scanned buffer. I tried to create a variable of char/uint8_t to store the data located by the pointer but I cannot get it printed correctly. 

    Can you aid me with how to cast this pointer into a printable string for the function NRF_LOG_RAW_INFO?

Children
Related