Announcement

Collapse
No announcement yet.

Is this a correct way to read a serial buffer?

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

  • Is this a correct way to read a serial buffer?

    I am trying to troubleshoot a slight pause that happens every 2 or 3 minutes and I wonder if its not how I'm reading the serial buffer. I clear the buffer and wait for a hex 25. Then check the buffer repeatedly for valid data (anything > -1). When valid data is seen is stores it in an array until it has 30 bytes. Is there a better way to do this than what is below?

    Thanks

    HTML Code:
            com_Init(combuf, 100, 0x0025 );
            inc := 0;
            repeat
    
                loop:
    
                serdata := serin();
                if (serdata < 0) goto loop;
    
                datastring[inc] := serdata;
                inc++;
    
            until(inc > 29);

  • #2


    That code looks fine.

    If I was going it, I might use com_Count() and read everything at once when I have 30 bytes, but depending on what you need to do in the rest of your app, your code looks quite OK
    Mark

    Comment

    Working...
    X