I sending a string like this: $13,-14,283,4,-4,17,6,-240,-180#
但是,由于缓冲的超负荷、我如何得到全方位或我如何在每一次逐读后加以澄清,所以没有显示。
// get a character string
char *getsU2(char *s, int len) {
char *p = s; // copy the buffer pointer
do {
*s = getU2(); // get a new character
if (( *s==
) || (*s==
)) // end of line...
break; // end the loop s++;
// increment the buffer pointer
len--;
} while (len>1); // until buffer is full
*s = ; // null terminate the string
return p; // return buffer pointer
}
// get a character string
char *getsU2(char *s, int len) {
char *p = s; // copy the buffer pointer
do {
*s = getU2(); // get a new character
if (( *s==
) || (*s==
)) // end of line...
break; // end the loop
s++;
// increment the buffer pointer
len--;
} while (len>1); // until buffer is full
*s = ; // null terminate the string
return p; // return buffer pointer
}
char getU2(void) {
if(U2STAbits.OERR == 1)
{ U2STAbits.OERR = 0; }
while (!U2STAbits.URXDA); // wait for new character to arrive return U2RXREG;
// read character from the receive buffer }
getsU2(buffer,sizeof(buffer));