Skip to main content
John Griswold
Senior
September 14, 2017
Question

Send non-printable characters using HAL_UART_Transmit()?

  • September 14, 2017
  • 1 reply
  • 1441 views
Posted on September 14, 2017 at 20:53

I am working on a project where I have to send characters such as 0x00, 0x01, 0x09, 0x13 and such to a display device. It wasn't doing what I expect, so I connected the UART output to a terminal to suss out why.

I can send a string (thousands of times it now seems) of 'This is UART 1\n\r' through this UART with no problem. When I try to send a string consisting of non-readable characters: 01 09 00 00 64 6C ix converted to 0964 6c 0d 0a. First of all, what happened to the 01? That's the command code. The two zeros are dropped as well, and those are parameters. And where did the 0a 0d come from? I thought HAL_UART_Transmit took a UART handle, a string pointer, a count, and a timeout. No mention of filtering and adding characters.

Is there another function I should be using? A different mode?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    September 14, 2017
    Posted on September 14, 2017 at 20:57

    Likely your terminal, use something like RealTerm in HEX mode. HAL_UART_Transmit() doesn't molest the data, but things like strlen()/strcpy()/printf() are clearly inadvisable.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    John Griswold
    Senior
    September 14, 2017
    Posted on September 14, 2017 at 21:20

    Good on you for teaching me a new tool. Thanks. RealTerm indeed shows that I am send 00 and 01 OK. At least I can get  beyond THIS WTF moment.

    William chang
    Associate III
    March 8, 2018
    Posted on March 08, 2018 at 04:35

    You question is done? Why don't you close your question?