Shop OBEX P1 Docs P2 Docs Learn Events
serial data — Parallax Forums

serial data

Hi gang, I need to send 2 10 bit values via a serial port any suggestion as to what might be the best method?
Jim

Comments

  • what processor, language?
  • Prop, spin
    Jim
  • You could send them as decimal data using "Parallax Serial Terminal.spin" and the dec method. Or you could use its hex method.

    What does the receiving system expect? Or is it flexible?

    -Phil
  • The receiver is running serial4port and can be flexable. I will lookinto the code for the DEC method to see what it is sending. I had not even thought of that. I definately like the HEX method Idea.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2017-10-01 00:50
    Two, 10-bit values will require a minimum of four bytes to transmit unless you want to do some packing and unpacking. Here's an easy method that will send two, 10-bit values.
    pub tx_values(val0, val1) : idx
    
      val0.word[1] := val1
      repeat 4
        serial.tx(val0.byte[idx++])
    
    If you decide to use the DEC method, you will have a stream of two (both values less than 10) to eight (both values more than 999) bytes. It's not hard to parse decimal values, but you'll need to insert a separator so that you know where one value ends and the other begins.
  • Thanks for the input Jon. I am still trying to sort through exactly what is happening at each step.
    Jim
Sign In or Register to comment.