本文整理汇总了C++中xQueueSendToBack函数的典型用法代码示例。如果您正苦于以下问题:C++ xQueueSendToBack函数的具体用法?C++ xQueueSendToBack怎么用?C++ xQueueSendToBack使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xQueueSendToBack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usb_tty_print
/*
* Carrega o buffer de saida com uma string localizada na ram
*/
void usb_tty_print(char *s){
unsigned int i = 0;
unsigned int len = 0;
char *sb = (char *)s;
USB_BUFFER buf;
/* verifica se o queue esta funcionando */
if(usb_buffer_queue == 0) return;
while(*sb++ != '\0') len++;
while(1){
if(len > USB_BUFFER_SIZE){
buf.co = USB_BUFFER_SIZE;
len-=USB_BUFFER_SIZE;
for(i = 0; i < USB_BUFFER_SIZE; i++){ buf.out[i] = *s++; }
xQueueSendToBack(usb_buffer_queue, &buf, 20/portTICK_RATE_MS);
} else {
if(len > 0){
buf.co = len;
for(i = 0; i < len; i++){ buf.out[i] = *s++; }
xQueueSendToBack(usb_buffer_queue, &buf, 20/portTICK_RATE_MS);
}
break;
}
}
}
示例2: qprintf
void qprintf(xQueueHandle tx_queue, const char *format, ...){
va_list ap;
va_start(ap, format);
int curr_ch = 0;
char out_ch[2] = {'\0', '\0'};
char newLine[3] = {'\n' , '\r', '\0'};
char percentage[] = "%";
char *str;
char str_num[10];
int out_int;
/* Block for 1ms. */
const portTickType xDelay = 0.1; // portTICK_RATE_MS;
while( format[curr_ch] != '\0' ){
vTaskDelay( xDelay );
if(format[curr_ch] == '%'){
if(format[curr_ch + 1] == 's'){
str = va_arg(ap, char *);
while (!xQueueSendToBack(tx_queue, str, portMAX_DELAY));
//parameter(...,The address of a string which is put in the queue,...)
}else if(format[curr_ch + 1] == 'd'){
itoa(va_arg(ap, int), str_num);
while (!xQueueSendToBack(tx_queue, str_num, portMAX_DELAY));
}else if(format[curr_ch + 1] == 'c'){
out_ch[0] = (char)va_arg(ap, int);
while (!xQueueSendToBack(tx_queue, out_ch, portMAX_DELAY));
}else if(format[curr_ch + 1] == 'x'){
示例3: write
/*
* Funcao write utilizado na retrasmissao do STDOUT, usado no printf
* referencia:
* http://support2.microchip.com/KBSearch/KB_StdProb.aspx?ID=SQ6UJ9A009MTU
* https://www.microchip.com/forums/m601123-print.aspx
*
* Objetivo: Compatibilidade com outras bibliotecas, frameworks com o minimo de alteracao
*/
int __atribute_libc write(int handle, void *buffer, unsigned int len){
int i = 0;
USB_BUFFER printf_buffer;
/* verifica se o queue esta funcionando */
if(usb_buffer_queue == 0) return 0;
switch(handle){
case 0: // STDOUT
case 1: // STDIN
case 2: // STDERR
if(len > USB_BUFFER_SIZE){
while(len > USB_BUFFER_SIZE){
for(i = 0; i < USB_BUFFER_SIZE; i++){ printf_buffer.out[i] = *(char *)buffer; }
len -= USB_BUFFER_SIZE;
printf_buffer.co = USB_BUFFER_SIZE;
xQueueSendToBack(usb_buffer_queue, &printf_buffer, 20/portTICK_RATE_MS);
}
goto printf_parte2;
} else {
printf_parte2:
if(len > 0){
for(i = 0; i < len; i++){ printf_buffer.out[i] = *(char *)buffer; }
printf_buffer.co = len;
xQueueSendToBack(usb_buffer_queue, &printf_buffer, 20/portTICK_RATE_MS);
}
}
break;
}
return(len);
}
示例4: helpCommand
void helpCommand(xQueueHandle *outputQueue, char *line)
{
char str[81];
int str_i, help_i, found_end;
xCommandListItem * item = &xRegisteredCommands;
// Set last char as NUL
str[80] = '\0';
// Print all command names
while (item != NULL)
{
if (strlen(item->command->help) < 81)
{
if(xQueueSendToBack(*outputQueue, (void *) item->command->help, (portTickType) 100) != pdPASS)
{
sciDebug("ERROR %s:%d\n\r", __FUNCTION__, __LINE__);
}
}
else
{
help_i = 0;
found_end = 0;
// Help text longer than 81 chars, split it up
while (found_end == 0)
{
// Get next partition of the string
for (str_i = 0; str_i < 80; str_i++)
{
str[str_i] = item->command->help[help_i++];
if (str[str_i] == '\0')
{
found_end = 1;
break;
}
}
// Print partition
if(xQueueSendToBack(*outputQueue, (void *) str, (portTickType) 100) != pdPASS)
{
sciDebug("ERROR %s:%d\n\r", __FUNCTION__, __LINE__);
}
}
}
item = item->next;
}
// Send End-of-Text
sprintf(str, "\3");
if(xQueueSendToBack(*outputQueue, (void *) str, (portTickType) 100) != pdPASS)
{
sciDebug("ERROR %s:%d\n\r", __FUNCTION__, __LINE__);
}
}
示例5: guiTop_ApplyUartSettings
void guiTop_ApplyUartSettings(reqUartSettings_t *s)
{
uart_receiver_msg_t uart_msg;
uart_msg.type = UART_APPLY_NEW_SETTINGS;
uart_msg.enable = s->enable;
uart_msg.parity = s->parity;
uart_msg.brate = s->brate;
if (s->uart_num == 1)
xQueueSendToBack(xQueueUART1RX, &uart_msg, portMAX_DELAY);
else
xQueueSendToBack(xQueueUART2RX, &uart_msg, portMAX_DELAY);
}
示例6: SMTPParamsClear
/**
* Clears SMTP parameter
* \return None
*/
void SMTPParamsClear()
{
BOOL opok = FALSE;
if(mainGSM.HWReady != TRUE)
return;
// Function cycles until it is not executed
while (!opok)
{
while (xSemaphoreTake(xSemFrontEnd,0) != pdTRUE); // xSemFrontEnd TAKE
// Check mainOpStatus.ExecStat
if (mainOpStatus.ExecStat != OP_EXECUTION)
{
mainOpStatus.ExecStat = OP_EXECUTION;
mainOpStatus.Function = 5;
mainOpStatus.ErrorCode = 0;
xQueueSendToBack(xQueue,&mainOpStatus.Function,0); // Send COMMAND request to the stack
xSemaphoreGive(xSemFrontEnd); // xSemFrontEnd GIVE, the stack can answer to the command
opok = TRUE;
}
else
{
xSemaphoreGive(xSemFrontEnd);
taskYIELD();
}
}
}
示例7: vCheckTimerCallback
static void vCheckTimerCallback( xTimerHandle xTimer )
{
static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0;
/* Define the status message that is sent to the LCD task. By default the
status is PASS. */
static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS };
/* This is the callback function used by the 'check' timer, as described
at the top of this file. */
/* The parameter is not used. */
( void ) xTimer;
/* See if the standard demo tasks are executing as expected, changing
the message that is sent to the LCD task from PASS to an error code if
any tasks set reports an error. */
if( xAreComTestTasksStillRunning() != pdPASS )
{
xStatusMessage.ulMessageValue = mainERROR_COM_TEST;
}
if( xAreDynamicPriorityTasksStillRunning() != pdPASS )
{
xStatusMessage.ulMessageValue = mainERROR_DYNAMIC_TASKS;
}
if( xAreGenericQueueTasksStillRunning() != pdPASS )
{
xStatusMessage.ulMessageValue = mainERROR_GEN_QUEUE_TEST;
}
if( xAreCountingSemaphoreTasksStillRunning() != pdPASS )
{
xStatusMessage.ulMessageValue = mainERROR_COUNT_SEM_TEST;
}
if( xAreTimerDemoTasksStillRunning( ( portTickType ) mainCHECK_TIMER_PERIOD ) != pdPASS )
{
xStatusMessage.ulMessageValue = mainERROR_TIMER_TEST;
}
/* Check the reg test tasks are still cycling. They will stop
incrementing their loop counters if they encounter an error. */
if( usRegTest1Counter == usLastRegTest1Counter )
{
xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
}
if( usRegTest2Counter == usLastRegTest2Counter )
{
xStatusMessage.ulMessageValue = mainERROR_REG_TEST;
}
usLastRegTest1Counter = usRegTest1Counter;
usLastRegTest2Counter = usRegTest2Counter;
/* This is called from a timer callback so must not block! */
xQueueSendToBack( xLCDQueue, &xStatusMessage, mainDONT_BLOCK );
}
示例8: prvPrintTask
static void prvPrintTask(void* pvParameters)
{
int iIndexToString;
// Two instances of this task are created. The task parameter is used to
// pass an index into an array of strings into the task. Cast this to the
// required type.
iIndexToString = (int)pvParameters;
for (;;)
{
// Print out the string, not directly but instead by passing a pointer
// to the string to the gatekeeper task via a queue. The queue is created
// before the scheduler is started so will already exist by this time
// task executes for the first time. A block time is not specified
// because there should always be space in the queue.
xQueueSendToBack(xPrintQueue, &pcStringsToPrint[iIndexToString], 0);
// Wait a pseudo random time. Note that rand() is not necessarily
// reentrant, but in this case it does not really matter as the code
// does not care what value is returned. In a more secure application
// a version of rand() that is known to be reentrant should be used -
// or calls to rand() should be protected using a critical section.
vTaskDelay(rand() & 0x1FF);
}
}
示例9: uart_to_spi_write
/**
* UART to SPI protocol handler
*/
void uart_to_spi_write(uart_packet_t *packet)
{
for (INT32U i=0; i<packet->datalength; i++)
{
xQueueSendToBack(uart_to_spi_queue, &packet->data[i], portMAX_DELAY);
}
}
示例10: UDPWrite
/**
* UDPWrite - Writes on the UDP socket
* \param sockwr UDP socket number
* \param str2wr String to write
* \param lstr String lenght
* \return The number of write characters to the specified UDP socket.
*/
WORD UDPWrite(BYTE sockwr, BYTE* str2wr , int lstr)
{
while (xSemaphoreTake(xSemFrontEnd,0) != pdTRUE); // xSemFrontEnd TAKE
xErr = 0;
if (xFrontEndStat == 0)
{
ToSend = 36;
xFrontEndStatRet = 2;
callbackUdpSocket = sockwr;
udpByte = str2wr;
udpInt = lstr;
xQueueSendToBack(xQueue,&ToSend,0); // Send UDPWrite command to the stack
xFrontEndStat = 1;
xSemaphoreGive(xSemFrontEnd); // xSemFrontEnd GIVE
}
else
{
xErr = 36;
xSemaphoreGive(xSemFrontEnd);
taskYIELD();
return FALSE;
}
while (xFrontEndStat != 2); // Waits for stack answer
while (xSemaphoreTake(xSemFrontEnd,0) != pdTRUE); // xSemFrontEnd TAKE
WORD resconn;
resconn = udpWord;
xFrontEndStat = 0;
xSemaphoreGive(xSemFrontEnd); // xSemFrontEnd GIVE
taskYIELD();
return resconn;
}
示例11: vBlockingQueueProducer
static void vBlockingQueueProducer( void *pvParameters )
{
unsigned short usValue = 0;
xBlockingQueueParameters *pxQueueParameters;
const char * const pcTaskStartMsg = "Blocking queue producer started.\r\n";
const char * const pcTaskErrorMsg = "Could not post on blocking queue\r\n";
short sErrorEverOccurred = pdFALSE;
pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters;
/* Queue a message for printing to say the task has started. */
vPrintDisplayMessage( &pcTaskStartMsg );
for( ;; )
{
if( xQueueSendToBack( pxQueueParameters->xQueue, ( void * ) &usValue, pxQueueParameters->xBlockTime ) != pdPASS )
{
vPrintDisplayMessage( &pcTaskErrorMsg );
sErrorEverOccurred = pdTRUE;
}
else
{
/* We have successfully posted a message, so increment the variable
used to check we are still running. */
if( sErrorEverOccurred == pdFALSE )
{
( *pxQueueParameters->psCheckVariable )++;
}
/* Increment the variable we are going to post next time round. The
consumer will expect the numbers to follow in numerical order. */
++usValue;
}
}
}
示例12: ForwardAudioMessage
void ForwardAudioMessage ( const char * sCommand, const char * sFileName )
{
struct AAudioMessage xAudioMessage, *pxAudioMessage = & xAudioMessage;
strncpy ( xAudioMessage.Command, sCommand, 8 - 1 );
strncpy ( xAudioMessage.Parameter, sFileName, 128 - 1 );
xQueueSendToBack ( xAudioQueue, ( void * ) &pxAudioMessage, ( portTickType ) 0 );
};
示例13: TCPisConn
/**
* TCPisConn - Verifies the connection of a remote TCP device with the socket. It can be useful to catch an incoming new connection to a TCP server.
* \param sockconn - The handle of the socket to control (the handle returned by the command TCPServerOpen).
* \return TRUE - The remote connection is established.
* \return FALSE - The remote connection is not established.
*/
BOOL TCPisConn(TCP_SOCKET sockconn)
{
BOOL opok = FALSE;
while (!opok)
{
while (xSemaphoreTake(xSemFrontEnd,0) != pdTRUE); // xSemFrontEnd TAKE
if (xFrontEndStat == 0)
{
ToSend = 24;
xFrontEndStatRet = 2;
xSocket = sockconn;
xQueueSendToBack(xQueue,&ToSend,0); // Send TCPIsConnected command to the stack
xFrontEndStat = 1;
xSemaphoreGive(xSemFrontEnd); // xSemFrontEnd GIVE
opok = TRUE;
}
else
{
xSemaphoreGive(xSemFrontEnd);
taskYIELD();
// If WiFi module if turned OFF, function doesn't do anything
if (xFrontEndStat == -1)
return FALSE;
}
}
while (xFrontEndStat != 2); // Waits for stack answer
while (xSemaphoreTake(xSemFrontEnd,0) != pdTRUE); // xSemFrontEnd TAKE
BOOL resconn;
resconn = xBool;
xFrontEndStat = 0;
xSemaphoreGive(xSemFrontEnd); // xSemFrontEnd GIVE
taskYIELD();
return resconn;
}
示例14: runShellCommand
void runShellCommand(xQueueHandle *outputQueue, char * line)
{
xCommandListItem * item = &xRegisteredCommands;
char * strNotFound = "Command not found, use \"help\" to list available commands.\n\r\3";
int len;
while (item != NULL)
{
len = strlen(item->command->name);
// Either line contains only the command or followed by space
if (strncmp(line, item->command->name, len) == 0 && (len == strlen(line) || line[len] == ' '))
{
(*item->command->func)(outputQueue, line);
break;
}
item = item->next;
}
if (item == NULL)
{
// Command was not found
if(xQueueSendToBack(*outputQueue, (void *) strNotFound, (portTickType) 100) != pdPASS)
{
sciDebug("ERROR %s:%d\n\r", __FUNCTION__, __LINE__);
}
}
}
示例15: readTask
/* This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
*
*/
void ICACHE_FLASH_ATTR
readTask(void *pvParameters)
{
struct userdata *user = (struct userdata *)pvParameters;
int a;
float temperature;
float R;
while(1) {
// read from sensor output voltage
a = LM35;
R = (float)(1023-a)*10000/a;
// convert to Celsius temperature
temperature = 1 / (log(R/10000)/B+1/298.15) - 273.15;
// precision
temperature = temperature * 100;
// send to queue
xQueueSendToBack( user->xQueue, (void *) &temperature, portMAX_DELAY );
// Resume the suspended task ourselves.
if( user->xHandle != NULL ) {
vTaskResume( user->xHandle );
}
wait(0.8);
}
}