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

BOOL PChannel::SendCommandString ( const PString command  )  [inherited]

Send a command meta-string. A meta-string is a string of characters that may contain escaped commands. The escape command is the \ as in the C language.

The escape commands are: {description} [# #] alert (ascii value 7) [# #] backspace (ascii value 8) [##] formfeed (ascii value 12) [#
#] newline (ascii value 10) [##] return (ascii value 13) [##] horizontal tab (ascii value 9) [##] vertical tab (ascii value 11) [#\#] backslash [##] where ooo is octal number, ascii value ooo [##] where hh is hex number (ascii value 0xhh) [##] null character (ascii zero) [##] delay for n seconds [##] delay for n milliseconds [##] characters following this, up to a command or the end of string, are to be sent to modem [##] characters following this, up to a , or another or the end of the string are expected back from the modem. If the string is not received within n seconds, a failed command is registered. The exception to this is if the command is at the end of the string or the next character in the string is the , or in which case all characters are ignored from the modem until n seconds of no data. [##] as for above but timeout is in milliseconds. {description}

TRUE if the command string was completely processed.
command  Command to send to the channel

Definition at line 590 of file pchannel.cxx.

References PThread::Current(), PChannel::ReadChar(), PChannel::ReadCharWithTimeout(), PChannel::SetReadTimeout(), PChannel::SetWriteTimeout(), PThread::Sleep(), and PChannel::WriteChar().

Referenced by PModem::Deinitialise(), PModem::Dial(), PModem::HangUp(), PModem::Initialise(), and PModem::SendUser().

  abortCommandString = FALSE;

  int nextChar;
  PINDEX sendPosition = 0;
  PTimeInterval timeout;

  while (!abortCommandString) { // not aborted
    nextChar = GetNextChar(command, sendPosition, &timeout);
    switch (nextChar) {
      default :
        if (!WriteChar(nextChar))
          return FALSE;

      case NextCharEndOfString :
        return TRUE;  // Success!!

      case NextCharSend :

      case NextCharDelay : // Delay in send

      case NextCharWait : // Wait for reply
        PINDEX receivePosition = sendPosition;
        if (GetNextChar(command, receivePosition) < 0) {
          while (ReadChar() >= 0)
            if (abortCommandString) // aborted
              return FALSE;
        else {
          receivePosition = sendPosition;
          do {
            if (abortCommandString) // aborted
              return FALSE;
            if ((nextChar = ReadCharWithTimeout(timeout)) < 0)
              return FALSE;
          } while (!ReceiveCommandString(nextChar,
                                     command, receivePosition, sendPosition));
//          nextChar = GetNextChar(command, receivePosition);
          sendPosition = receivePosition;

  return FALSE;

Generated by  Doxygen 1.6.0   Back to index