Code:
char *InBuf;
//.................
int RecebeSerial(void){
int iLenBuf, iReadReturn;
if(IsCom(iComBalanca)){
iLenBuf = DataSizeInCom (iComBalanca);
iReadReturn = ReadComn(iComBalanca, InBuf, iLenBuf);
InBuf [iLenBuf] = '\0';
if (iReadReturn >= 0){
ProcessaBuffer (InBuf);
}
return 1;
}
return -1;
}
int strrpos (char *pStrText, char pChar){
int iLen, iCont;
iLen = strlen (pStrText);
printCom1 (pStrText);
printCom1 ("\nSTR.: %s", pStrText);
printCom1 ("\nSTR1: %s", pStrText[1]);
printCom1 ("\nBUF.: %s", InBuf);
printCom1 ("\nLEN.: %d", iLen);
if (iLen > 0){
for (iCont=iLen - 1; iCont>=0; iCont--){
if (pStrText[iCont] == pChar)
return iCont;
}
return 0; // Não houve ocorrências
}
else { return 0; } // String Nula
}
void ProcessaBuffer (char *pInBuf){
char cChar;
unsigned char *cPacote, *cPeso;
unsigned char *cStatus;
unsigned char cByte;
int iCont;
int iPosStart, iPosEnd, iPosTam;
cChar = STARTCHAR;
iPosStart = strrpos (pInBuf, cChar);
//...
strpos return:
1234567890AB
STR.: (null)
STR1: ?
BUF.: (null)
LEN.: 0 STARTCHAR: INT: 2 Posição: 0
When i call strpos funcion, and use printCom1 (simillar printf) then result is ok, when I use %s or manipulate it string package is null.
Sorry for my english.