Shop OBEX P1 Docs P2 Docs Learn Events
How to send raw hex data asynchronously using software UART — Parallax Forums

How to send raw hex data asynchronously using software UART

Hello!
I have run into a bit of a road block where I am trying to send raw hex data from the Propeller using software UART in C. I am using a dprint statement and even though I tell it to format as a hexadecimal, it is sending it as ascii characters, which I think is due to the nature of the dprint. What is the best way to send raw hex asynchronously where it does not get converted to a ascii character?

Thanks in advance!
James

Comments

  • What, exactly, do you mean by "raw hex"? Do you actually mean "raw binary", sending a single character, say, 0xF7, as opposed to something like "F7" in ASCII?

    -Phil
  • What, exactly, do you mean by "raw hex"? Do you actually mean "raw binary", sending a single character, say, 0xF7, as opposed to something like "F7" in ASCII?

    -Phil

    Yes I mean raw binary
  • If you're not wanting to send the values in a human readable format, then use the .tx() method. If, though, you want that output going to a terminal where a human can read it, you have to convert the value to a hex string with .hex().

    Examples:
      serial.tx($30)
    
    ...sends the byte $30 (0x30). If it lands on a terminal you will see "0".
      serial.hex($30)
    
    ...sends the two-byte string "30".

    Keep in mind that all values in a computer are stored in binary format. Other notations, e.g. hex, are for humans.
  • Whoops... I blew right past the part where you wanted to use C -- I'm a Spin programmer. Still, I think the functions in the C version of FullDuplexSerial are identical to the Spin version.
Sign In or Register to comment.