Announcement

Collapse
No announcement yet.

How do I send an integer through the serout command?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I send an integer through the serout command?

    I need to send the data in an integer variable (data such as 5, 15, or 155), out though the serout command but I can't figure out how to do it.
    I am successfully sending individual literal chars, such as 'R' and '1', but I can't figure out how to send an integer variable. If you could show me how this is done, I would greatly appreciate it.
    I'm guessing that perhaps I need to send the integer 155 out as '1', then '5', then '5', but I can't figure out how to get it into that form to send it.
    While trying to work on this, I tried to figure out how to convert data in an integer variable to a char variable or char array (which I could then perhaps send through serout?). But I can't figure out how to do that either.
    Your assistance is much appreciated it.

  • #2


    serout(i >> 8) ;

    serout(i) ;



    Will send it as an integer (big endian)



    to(COM0) ;

    print(i) ;



    Will send it as a string



    To convert it to a string, you can also use 'to' with different operands.
    Mark

    Comment


    • #3


      Thank you for the quick reply. I will try these. I understand the to(COM0); print(i);, but on the first method, I don't understand the second line serout(i). Can you elaborate a little bit on what you're doing there?

      Comment


      • #4


        Say i := 0x1234 ;



        serout(i >> 8) ;



        will output i shifted right 8 bits, or 0x12



        serout(i) ;



        will output the last 8 bits of i, or 0x34, since serout only outputs 8 bits (or a byte)
        Mark

        Comment


        • #5


          Ah. I see. OK. Thanks.
          I tried the to(COM0); print(i); method and that immediately solved my problem. I'm off and running now to the next step in the process. Thanks for your help.

          Comment

          Working...
          X