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

  • 6 Comments sorted by Date Added Votes
  • what processor, language?
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • 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
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • 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: 5,870
    edited October 1 Vote Up0Vote Down
    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.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • 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.