src/atchannel.c
/**
 * Internal send_command implementation
 * Doesn't lock or call the timeout callback
 *
 * timeoutMsec == 0 means infinite timeout
 */
Internal send_command implementation
Doesn't lock or call the timeout callback

timeoutMsec == 0 means infinite timeout
Internal send_command implementation Doesn ' t lock or call the timeout callback timeoutMsec == 0 means infinite timeout
static ATReturn at_send_command_full_nolock(ATChannel* atch, const char *command,
                    ATCommandType type, const char *responsePrefix, const char *smspdu,
                    long long timeoutMsec, ATResponse **pp_outResponse)
{
    ATReturn err = 0;
    struct timespec ts;
    if (pp_outResponse) {
        *pp_outResponse = NULL;
    }
    if(atch->impl->p_response != NULL) {
        err = AT_ERROR_COMMAND_PENDING;
        goto error;
    }
    err = writeline(atch, command);
    if (err < 0) {
        goto error;
    }
    atch->impl->type = type;
    atch->impl->responsePrefix = responsePrefix;
    atch->impl->smsPDU = smspdu;
    atch->impl->p_response = at_response_new();
    if (timeoutMsec != 0) {
        setTimespecRelative(&ts, timeoutMsec);
    }
    while (atch->impl->p_response->finalResponse == NULL && !atch->impl->readerClosed) {
        if (timeoutMsec != 0) {
            err = pthread_cond_timedwait(&atch->impl->commandcond, &atch->impl->commandmutex, &ts);
        } else {
            err = pthread_cond_wait(&atch->impl->commandcond, &atch->impl->commandmutex);
        }
        if (err == ETIMEDOUT) {
            err = AT_ERROR_TIMEOUT;
            goto error;
        }
    }
    if (pp_outResponse == NULL) {
        at_response_free(atch->impl->p_response);
    } else {
        reverseIntermediates(atch->impl->p_response);
        *pp_outResponse = atch->impl->p_response;
    }
    atch->impl->p_response = NULL;
    if(atch->impl->readerClosed) {
        err = AT_ERROR_CHANNEL_CLOSED;
        goto error;
    }
    err = AT_SUCCESS;
error:
    clearPendingCommand(atch);
    return err;
}
static ATReturn at_send_command_full_nolock ( ATChannel * atch , const char * command , ATCommandType type , const char * responsePrefix , const char * smspdu , long long timeoutMsec , ATResponse * * pp_outResponse ) { ATReturn err = 0 ; struct timespec ts ; if ( pp_outResponse ) { * pp_outResponse = NULL ; } if ( atch -> impl -> p_response != NULL ) { err = AT_ERROR_COMMAND_PENDING ; goto error ; } err = writeline ( atch , command ) ; if ( err < 0 ) { goto error ; } atch -> impl -> type = type ; atch -> impl -> responsePrefix = responsePrefix ; atch -> impl -> smsPDU = smspdu ; atch -> impl -> p_response = at_response_new ( ) ; if ( timeoutMsec != 0 ) { setTimespecRelative ( & ts , timeoutMsec ) ; } while ( atch -> impl -> p_response -> finalResponse == NULL && ! atch -> impl -> readerClosed ) { if ( timeoutMsec != 0 ) { err = pthread_cond_timedwait ( & atch -> impl -> commandcond , & atch -> impl -> commandmutex , & ts ) ; } else { err = pthread_cond_wait ( & atch -> impl -> commandcond , & atch -> impl -> commandmutex ) ; } if ( err == ETIMEDOUT ) { err = AT_ERROR_TIMEOUT ; goto error ; } } if ( pp_outResponse == NULL ) { at_response_free ( atch -> impl -> p_response ) ; } else { reverseIntermediates ( atch -> impl -> p_response ) ; * pp_outResponse = atch -> impl -> p_response ; } atch -> impl -> p_response = NULL ; if ( atch -> impl -> readerClosed ) { err = AT_ERROR_CHANNEL_CLOSED ; goto error ; } err = AT_SUCCESS ; error : clearPendingCommand ( atch ) ; return err ; }
Internal send_command implementation
 Doesn't lock or call the timeout callback
Internal send_command implementation Doesn ' t lock or call the timeout callback
/* line reader stores intermediate responses in reverse order */