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

PComm::Write ( char *  submesg  )  [private]

Internal function to write to the socket.

Parameters:
submesg character string to write out to
sends a command to the radio/socket.

It zero's out the internal class's write buffer, and copies the message passed in called submesg into the write buffer. It appends the special end-of-command marker to the write buffer, and exec's write(). Select() is used to see if we are ready to write to the socket in the FDSet.

Returns:
what was actually written minus two. Since the minus two is to account for the end-of-command marker. On error we return -2
See also:
Read()

Definition at line 370 of file pcomm.cpp.

References fd, FDSet, timeOut, and writeBuf.

Referenced by PCAsk(), and PCTell().

{
    int __writeCtr;

    bzero(writeBuf, sizeof(writeBuf));
    strcpy(writeBuf, submesg);
    strcat(writeBuf, PCRECMD);

    #ifdef DEBUG_VER_2
    fprintf(stderr, "Write Attempt: %s\n", writeBuf);
    #endif /* DEBUG_VER_ */

    if (select(fd+1, NULL, FDSet, NULL, timeOut)) {
            __writeCtr=write(fd, writeBuf, strlen(writeBuf));
    } else {
#ifdef DEBUG_VER_
          fprintf(stderr, "Write() Time Out on socket %d\n", fd);
#endif // DEBUG_VER_ 
          __writeCtr=0;
    }

    return (__writeCtr-2);
}


Generated by  Doxygen 1.6.0   Back to index