Announcement

Collapse
No announcement yet.

Buffered Serial and ATOI

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

  • Buffered Serial and ATOI

    Working with a 32PT_GFX - Probably asking a bit much here, but would be greatful for either a bit of help or pointers in the right direction.
    Does anyone have a function that will accept a serial data stream, break it up via a predetermined delimeter (TAB), convert the information to the integer values that it represented and store this in and array.

    The data stream is going to be a fixed length data stream of say 30 pieces of information that I would like to store in an array. This information will then be used to display information on the dials and guages on the screen.

    Hoping that someone has done something similar and can help me out with this.

    Thanks

  • #2


    Set up buffered coms to hold 30 pieces (with a 30 element array, assuming all are integers)



    'do something else' until the buffer count is 60.



    Loop 30 times to read two elements from the coms buffer, shifing on left 8 bits and oring with the other to convert to an integer, then store in the array.



    Should be failry simple
    Mark

    Comment


    • #3


      thanks for the info .. the way you put it does sound really simple .. ill have a crack at it after i get home from work this afternoon. setup buffercall com int to start listeningperiodically check for com fullloop through the buffer get first value

      Comment


      • #4


        OK I'm struggling with this - can anyone enlighten me on the best way to achieve this. I have setup the comms buffer for serial input buffering. I then check and wait for the com full to indicate that the buffer is full. Start reading the information from the buffer (hex/Binary Value), shift this right by 8 to create the hi byte, OR this with the next byte to create a word and then save this to another array. I'm not sure how this word is a representation of an integer number. Have I got this logic all wrong?
        if I send through the the value 12 - this comes through the serial comms as ascii 32 and asc 33. Right shift the first number for the Hi byte, ORing with second ??? how does this represent the Integer value of 12 - the binary representation is a value in the 12,000 region.
        Can anyone step me in the right direction please.

        Comment


        • #5


          If you are receiving 0x32 and then 0x33, well that's ASCII 2 and 3, so it would appear whatever is sending is not sending a pure integer. Whether it's converting it to ASCII because it thinks it is supposed to I don't know.



          12 would be 0x000C, which should come though as 0x00 then 0x0C, or the other way around, depending upong the 'endianness' of the sender.



          Have a play with the way your sender is 'defining' what it is sending. IF it has to send ASCII well, fine, we can convert that easiliy enough, it's just not as efficient as sending Binary
          Mark

          Comment


          • #6


            thanks for ur feedback on this .. think this is more my lack of understanding of the language .. i found an excellent post from GregFordyce at the start of this forum which pretty much does close to what i want to do. it uses the str_GetW to extract the numbers to an array which i can then use. im going to tweak around with this to get it where i want .. thanks

            Comment


            • #7


              If you get stuck just post your code along with your question, it'll be easier for the moderators to help. Good luck!
              Atilla

              Comment

              Working...
              X