QP/C  6.5.1
qs_rx.c File Reference

QS/C receive channel services. More...

#include "qs_port.h"
#include "qs_pkg.h"
#include "qassert.h"
Include dependency graph for qs_rx.c:

Go to the source code of this file.

Functions

void QS_rxInitBuf (uint8_t sto[], uint16_t stoSize)
 Initialize the QS RX data buffer. More...
 
uint16_t QS_rxGetNfree (void)
 Obtain the number of free bytes in the QS RX data buffer. More...
 
void QS_rxParse (void)
 Parse all bytes present in the QS RX data buffer. More...
 
static void QS_rxParseData_ (uint8_t b)
 
static void QS_rxHandleGoodFrame_ (uint8_t state)
 
static void QS_rxHandleBadFrame_ (uint8_t state)
 
static void QS_rxReportAck_ (enum QSpyRxRecords recId)
 
static void QS_rxReportError_ (uint8_t code)
 
static void QS_rxReportDone_ (enum QSpyRxRecords recId)
 
static void QS_rxPoke_ (void)
 
uint32_t QS_getTestProbe_ (void(*const api)(void))
 QS internal function to get the Test-Probe for a given API. More...
 
QSTimeCtr QS_onGetTime (void)
 Callback to obtain a timestamp for a QS record. More...
 

Variables

QSrxPriv QS_rxPriv_
 

Detailed Description

QS/C receive channel services.

Definition in file qs_rx.c.

Function Documentation

◆ QS_rxInitBuf()

void QS_rxInitBuf ( uint8_t  sto[],
uint16_t  stoSize 
)

Initialize the QS RX data buffer.

Description
This function should be called from QS_onStartup() to provide QS-RX with the receive data buffer.
Parameters
[in]sto[]the address of the memory block
[in]stoSizethe size of this block [bytes]. The size of the QS RX buffer cannot exceed 64KB.
Note
QS-RX can work with quite small data buffers, but you will start losing data if the buffer is not drained fast enough in the idle task.
If the data input rate exceeds the QS-RX processing rate, the data will be lost, but the QS protocol will notice that: (1) that the checksum in the incomplete QS records will fail; and (2) the sequence counter in QS records will show discontinuities.

The QS-RX channel will report any data errors by sending the QS_RX_DATA_ERROR trace record.

Definition at line 253 of file qs_rx.c.

◆ QS_rxGetNfree()

uint16_t QS_rxGetNfree ( void  )

Obtain the number of free bytes in the QS RX data buffer.

Description
This function is intended to be called from the ISR that reads the QS-RX bytes from the QSPY host application. The function returns the conservative number of free bytes currently available in the buffer, assuming that the head pointer is not being moved concurrently. The tail pointer might be moving, meaning that bytes can be concurrently removed from the buffer.

Definition at line 292 of file qs_rx.c.

◆ QS_rxParse()

void QS_rxParse ( void  )

Parse all bytes present in the QS RX data buffer.

Definition at line 308 of file qs_rx.c.

◆ QS_rxParseData_()

static void QS_rxParseData_ ( uint8_t  b)
static

Definition at line 353 of file qs_rx.c.

◆ QS_rxHandleGoodFrame_()

static void QS_rxHandleGoodFrame_ ( uint8_t  state)
static

Definition at line 816 of file qs_rx.c.

◆ QS_rxHandleBadFrame_()

static void QS_rxHandleBadFrame_ ( uint8_t  state)
static

Definition at line 1156 of file qs_rx.c.

◆ QS_rxReportAck_()

static void QS_rxReportAck_ ( enum QSpyRxRecords  recId)
static

Definition at line 1171 of file qs_rx.c.

◆ QS_rxReportError_()

static void QS_rxReportError_ ( uint8_t  code)
static

Definition at line 1179 of file qs_rx.c.

◆ QS_rxReportDone_()

static void QS_rxReportDone_ ( enum QSpyRxRecords  recId)
static

Definition at line 1187 of file qs_rx.c.

◆ QS_rxPoke_()

static void QS_rxPoke_ ( void  )
static

Definition at line 1196 of file qs_rx.c.

◆ QS_getTestProbe_()

uint32_t QS_getTestProbe_ ( void(*)(void)  api)

QS internal function to get the Test-Probe for a given API.

Description
This function obtains the Test-Probe for a given API.
Parameters
[in]api_idthe API-ID that requests its Test-Probe

@returs Test-Probe data that has been received for the given API from the Host (running qutest). For any ginve API, the function returns the Test-Probe data in the same order as it was received from the Host. If there is no Test-Probe for a ginve API, or no more Test-Probes for a given API, the function returns zero.

Definition at line 1235 of file qs_rx.c.

◆ QS_onGetTime()

QSTimeCtr QS_onGetTime ( void  )

Callback to obtain a timestamp for a QS record.

Description
This is a platform-dependent "callback" function invoked from the macro QS_TIME_ to add the time stamp to a QS record.
Note
Some of the predefined QS records from QP do not output the time stamp. However, ALL user records do output the time stamp.
QS_onGetTime() is called in a critical section and should not exit the critical section.
Returns
the current timestamp.
Usage
The following example shows using a system call to implement QS time stamping:
#ifdef Q_SPY
return (QSTimeCtr)clock();
}
. . .
#endif /* Q_SPY */

Definition at line 1259 of file qs_rx.c.

Variable Documentation

◆ QS_rxPriv_

QSrxPriv QS_rxPriv_

Definition at line 48 of file qs_rx.c.