Logo Search packages:      
Sourcecode: icomlib version File versions  Download package

PComm::PCHear ( char *  mesg  ) 

Receive a repsonse from the radio.

mesg a character string long enough to hold a reply
This function makes sure that mesg is pointing to a valid address (ie: is malloc'd) then it zero's out the message string and hearBuffer. It then calls Read()... remembering the number of bytes read, it cuts out the end-of-command marker read in (CR-LF) and copies what it heard into the message string.

If the radio kept spitting out LF chars, it checks for the err bool.

the number of bytes read, or -1 on err.
See also:

Definition at line 251 of file pcomm.cpp.

References errRead, hearBuf, hearCtr, and Read().

Referenced by PCP::PCPCheckResponse(), PCP::PCPQueryOn(), PCP::PCPQuerySquelch(), PCP::PCPSigStrength(), and PCP::PCPSigStrengthStr().

    char *cut;

    #ifdef DEBUG_VER_2
    assert(mesg != 0);
    fprintf(stderr, "PComm: PCHEAR \n");
    #endif /* DEBUG_VER_ */

    bzero(hearBuf, sizeof(hearBuf));
    bzero(mesg, sizeof(mesg));

    hearCtr = Read(hearBuf);
    cut=strpbrk(hearBuf, PCRECMD);
    if (cut!=NULL) { 
        hearCtr -= 2;
    strcpy(mesg, hearBuf); 
    #ifdef DEBUG_VER_2
    fprintf(stderr, "Hear: %s\n", mesg);
    #endif /* DEBUG_VER_ */

      if (errRead) {
            return (-1);
      } else { 
            return (hearCtr);


Generated by  Doxygen 1.6.0   Back to index