本文整理汇总了C++中Q_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_ERROR函数的具体用法?C++ Q_ERROR怎么用?C++ Q_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pfq_egress_bind
int
pfq_egress_bind(pfq_t *q, const char *dev, int queue)
{
struct pfq_binding b;
int index;
if (strcmp(dev, "any")==0) {
index = Q_ANY_DEVICE;
}
else {
index = pfq_ifindex(q, dev);
if (index == -1) {
return Q_ERROR(q, "PFQ: egress_bind: device not found");
}
}
b.gid = 0;
b.if_index = index;
b.hw_queue = queue;
if (setsockopt(q->fd, PF_Q, Q_SO_EGRESS_BIND, &b, sizeof(b)) == -1)
return Q_ERROR(q, "PFQ: egress bind error");
return Q_OK(q);
}
示例2: pfq_unbind_group
int
pfq_unbind_group(pfq_t *q, int gid, const char *dev, int queue) /* Q_ANY_QUEUE */
{
struct pfq_binding b;
int index;
if (strcmp(dev, "any")==0) {
index = Q_ANY_DEVICE;
}
else {
index = pfq_ifindex(q, dev);
if (index == -1) {
return Q_ERROR(q, "PFQ: unbind_group: device not found");
}
}
b.gid = gid;
b.if_index = index;
b.hw_queue = queue;
if (setsockopt(q->fd, PF_Q, Q_SO_GROUP_UNBIND, &b, sizeof(b)) == -1) {
return Q_ERROR(q, "PFQ: unbind error");
}
return Q_OK(q);
}
示例3: pfq_disable
int
pfq_disable(pfq_t *q)
{
if (q->fd == -1)
return Q_ERROR(q, "PFQ: socket not open");
if (q->shm_addr != MAP_FAILED) {
if (munmap(q->shm_addr,q->shm_size) == -1)
return Q_ERROR(q, "PFQ: munmap error");
if (q->hd != -1) {
char filename[64];
snprintf(filename, 64, "/dev/hugepages/pfq.%d", q->fd);
unlink(filename);
}
}
q->shm_addr = NULL;
q->shm_size = 0;
if(setsockopt(q->fd, PF_Q, Q_SO_DISABLE, NULL, 0) == -1) {
return Q_ERROR(q, "PFQ: socket disable");
}
return Q_OK(q);
}
示例4: main
int main(void) {
uint16_t status;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
LED_init();
LED_on();
/* configure the Basic Clock Module */
DCOCTL = CALDCO_1MHZ;
BCSCTL1 = CALBC1_1MHZ;
BCSCTL2 = SELM_3 + DIVM_0;//MCLK = LFXTCLK/1
#ifdef NECESSARY
do {
int i;
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
} while ((IFG1 & OFIFG)); // OSCFault flag still set?
#endif
TACTL = TASSEL_2 | MC_1; /* SMCLK, upmode */
TACCR0 = TIMER_CLK_HZ/SYSTICK_HZ;
TACCTL0 = CCIE; /*Enable timer A0 interrupt*/
//Enable SCLK, SDI, SDO, master
USICTL0 |= USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE;
USICKCTL |= USIDIV_0 //this actually means divide by 1
| USISSEL_2//Use SMCLK to drive the SPI clk
//| USICKPL
;
USICTL1 |= USICKPH;//delay?
//USICTL1 |= USIIE;//interrupt enable
// ;
P1OUT = BIT4;//Pull up nCS at first
P1DIR |= BIT4;//nCS is P1.4
//P1REN |= 0x10;?
_enable_interrupts();//vs. _BIS_SR(LPM0_bits + GIE);
LED_off();
dSPIN_Soft_Stop();
dSPIN_Reset_Device();
status = dSPIN_Get_Status();
if(status & dSPIN_STATUS_SW_EVN
|| (status & dSPIN_STATUS_MOT_STATUS) != dSPIN_STATUS_MOT_STATUS_STOPPED
|| status & dSPIN_STATUS_NOTPERF_CMD
|| status & dSPIN_STATUS_WRONG_CMD
// !(status & dSPIN_STATUS_UVLO)
|| !(status & dSPIN_STATUS_TH_SD)
|| !(status & dSPIN_STATUS_OCD))
Q_ERROR();
if(dSPIN_Busy_HW()) Q_ERROR();
return 0;
}
示例5: pfq_enable
int
pfq_enable(pfq_t *q)
{
size_t tot_mem; socklen_t size = sizeof(tot_mem);
char filename[64];
if (q->shm_addr != MAP_FAILED &&
q->shm_addr != NULL) {
return Q_ERROR(q, "PFQ: queue already enabled");
}
if (getsockopt(q->fd, PF_Q, Q_SO_GET_SHMEM_SIZE, &tot_mem, &size) == -1) {
return Q_ERROR(q, "PFQ: queue memory error");
}
snprintf(filename, 64, "/dev/hugepages/pfq.%d", q->fd);
q->hd = open(filename, O_CREAT | O_RDWR, 0755);
if (q->hd != -1)
q->shm_addr = mmap(NULL, tot_mem, PROT_READ|PROT_WRITE, MAP_SHARED, q->hd, 0);
if (q->shm_addr != MAP_FAILED &&
q->shm_addr != NULL) {
if(setsockopt(q->fd, PF_Q, Q_SO_ENABLE, &q->shm_addr, sizeof(q->shm_addr)) == -1) {
return Q_ERROR(q, "PFQ: socket enable (hugepages)");
}
}
else {
void * null = NULL;
if(setsockopt(q->fd, PF_Q, Q_SO_ENABLE, &null, sizeof(null)) == -1) {
return Q_ERROR(q, "PFQ: socket enable");
}
q->shm_addr = mmap(NULL, tot_mem, PROT_READ|PROT_WRITE, MAP_SHARED, q->fd, 0);
}
if (q->shm_addr == MAP_FAILED ||
q->shm_addr == NULL) {
return Q_ERROR(q, "PFQ: socket enable (memory map)");
}
q->shm_size = tot_mem;
q->rx_queue_addr = (char *)(q->shm_addr) + sizeof(struct pfq_shared_queue);
q->rx_queue_size = q->rx_slots * q->rx_slot_size;
q->tx_queue_addr = (char *)(q->shm_addr) + sizeof(struct pfq_shared_queue) + q->rx_queue_size * 2;
q->tx_queue_size = q->tx_slots * q->tx_slot_size;
return Q_OK(q);
}
示例6: pfq_set_tx_slots
int
pfq_set_tx_slots(pfq_t *q, size_t value)
{
int enabled = pfq_is_enabled(q);
if (enabled == 1) {
return Q_ERROR(q, "PFQ: enabled (Tx slots could not be set)");
}
if (setsockopt(q->fd, PF_Q, Q_SO_SET_TX_SLOTS, &value, sizeof(value)) == -1) {
return Q_ERROR(q, "PFQ: set Tx slots error");
}
q->tx_slots = value;
return Q_OK(q);
}
示例7: pfq_set_caplen
int
pfq_set_caplen(pfq_t *q, size_t value)
{
int enabled = pfq_is_enabled(q);
if (enabled == 1) {
return Q_ERROR(q, "PFQ: enabled (caplen could not be set)");
}
if (setsockopt(q->fd, PF_Q, Q_SO_SET_RX_CAPLEN, &value, sizeof(value)) == -1) {
return Q_ERROR(q, "PFQ: set caplen error");
}
q->rx_slot_size = ALIGN(sizeof(struct pfq_pkthdr) + value, 8);
return Q_OK(q);
}
示例8: BSP_init
/*..........................................................................*/
void BSP_init(void) {
WDT.TCSRWD.BYTE = 0x10; /* disable Watchdog */
WDT.TCSRWD.BYTE = 0x00;
MSTCR2.BIT.MSTTZ = 0; /* turn on TimerZ */
TZ0.TCR.BIT.TPSC = 3; /* internal clock phi/8 */
TZ0.TCR.BIT.CCLR = 1;
TZ0.GRA = (uint16_t)(((f1_CLK_SPEED/8 + BSP_TICKS_PER_SEC/2)
/ BSP_TICKS_PER_SEC) - 1);
TZ0.TIER.BIT.IMIEA = 1; /* compare match interrupt enable */
/* enable the User LEDs... */
LED0_DDR_1(); /* configure LED0 pin as output */
LED1_DDR_1(); /* configure LED1 pin as output */
LED2_DDR_1(); /* configure LED2 pin as output */
LED3_DDR_1(); /* configure LED3 pin as output */
LED0 = LED_OFF;
LED1 = LED_OFF;
LED2 = LED_OFF;
LED3 = LED_OFF;
/* enable the Switch... */
SW1_DDR = 0;
if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */
Q_ERROR();
}
}
示例9: BSP_init
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* enable GPIOA clock for the LED */
RCC->AHBENR |= (1U << 0);
/* configure LED (PA.5) pin as push-pull outputs, No pull-up, pull-down */
GPIOA->MODER &= ~((3U << 2*5));
GPIOA->MODER |= ((1U << 2*5));
GPIOA->OTYPER &= ~((1U << 5));
GPIOA->OSPEEDR &= ~((3U << 2*5));
GPIOA->OSPEEDR |= ((1U << 2*5));
GPIOA->PUPDR &= ~((3U << 2*5));
/* enable GPIOC clock for the Button */
RCC->AHBENR |= (1ul << 2);
/* configure BTN (PC.13) pin as push-pull outputs, No pull-up, pull-down */
GPIOC->MODER &= ~(3ul << 2*13);
GPIOC->OSPEEDR &= ~(3ul << 2*13);
GPIOC->OSPEEDR |= (1ul << 2*13);
GPIOC->PUPDR &= ~(3ul << 2*13);
BSP_randomSeed(1234U);
if (QS_INIT((void *)0) == 0U) { /* initialize the QS software tracing */
Q_ERROR();
}
QS_OBJ_DICTIONARY(&l_tickHook);
QS_OBJ_DICTIONARY(&l_EXTI0_IRQHandler);
}
示例10: BSP_init
/*..........................................................................*/
void BSP_init(void) {
uint32_t i;
for (i = 0; i < Q_DIM(l_led); ++i) { /* initialize the LEDs... */
AT91C_BASE_PIOA->PIO_PER = l_led[i]; /* enable pin */
AT91C_BASE_PIOA->PIO_OER = l_led[i]; /* configure as output pin */
LED_OFF(i); /* extinguish the LED */
}
/* configure Advanced Interrupt Controller (AIC) of AT91... */
AT91C_BASE_AIC->AIC_IDCR = ~0; /* disable all interrupts */
AT91C_BASE_AIC->AIC_ICCR = ~0; /* clear all interrupts */
for (i = 0; i < 8; ++i) {
AT91C_BASE_AIC->AIC_EOICR = 0; /* write AIC_EOICR 8 times */
}
/* set the desired ticking rate for the PIT... */
i = (MCK / 16 / BSP_TICKS_PER_SEC) - 1;
AT91C_BASE_PITC->PITC_PIMR = (AT91C_PITC_PITEN | AT91C_PITC_PITIEN | i);
if (QS_INIT((void *)0) == 0) { /* initialize the QS software tracing */
Q_ERROR();
}
QS_OBJ_DICTIONARY(&QS_tickIRQ);
}
示例11: Philo_hungry
/*${AOs::Philo::SM::hungry} ................................................*/
QState Philo_hungry(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*${AOs::Philo::SM::hungry} */
case Q_ENTRY_SIG: {
QACTIVE_POST(&AO_Table, HUNGRY_SIG, me->num);
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::hungry::EAT} */
case EAT_SIG: {
status_ = Q_TRAN(&Philo_eating);
break;
}
/*${AOs::Philo::SM::hungry::DONE} */
case DONE_SIG: {
Q_ERROR(); /* this event should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例12: Philo_thinking
/*${AOs::Philo::SM::thinking} ..............................................*/
QState Philo_thinking(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*${AOs::Philo::SM::thinking} */
case Q_ENTRY_SIG: {
me->tickCtr = THINK_TIME;
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::thinking} */
case Q_EXIT_SIG: {
me->tickCtr = 0U;
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::thinking::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_hungry);
break;
}
/*${AOs::Philo::SM::thinking::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例13: Philo_eating
/*${AOs::Philo::SM::eating} ................................................*/
QState Philo_eating(Philo * const me) {
QState status_;
switch (Q_SIG(me)) {
/*${AOs::Philo::SM::eating} */
case Q_ENTRY_SIG: {
me->tickCtr = EAT_TIME;
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::eating} */
case Q_EXIT_SIG: {
me->tickCtr = 0U;
QACTIVE_POST(QF_ACTIVE_CAST(&AO_Table), DONE_SIG, me->num);
status_ = Q_HANDLED();
break;
}
/*${AOs::Philo::SM::eating::Q_TIMEOUT} */
case Q_TIMEOUT_SIG: {
status_ = Q_TRAN(&Philo_thinking);
break;
}
/*${AOs::Philo::SM::eating::EAT, DONE} */
case EAT_SIG: /* intentionally fall through */
case DONE_SIG: {
Q_ERROR(); /* these events should never arrive in this state */
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
}
}
return status_;
}
示例14: BSP_init
void BSP_init(void) {
uint32_t err_code;
err_code = nrf_drv_timer_init(&TIMER1, NULL, Timer1_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_timer_extended_compare(&TIMER1, NRF_TIMER_CC_CHANNEL0
, nrf_drv_timer_ms_to_ticks(&TIMER1, 1000/BSP_TICKS_PER_SEC)
, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
// Configure button 1 for low accuracy (why not high accuracy?)
Q_ALLEGE(nrf_drv_gpiote_init() == NRF_SUCCESS);
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
config.pull = NRF_GPIO_PIN_PULLUP;
Q_ALLEGE(nrf_drv_gpiote_in_init(BTN_PIN, &config, btn1_event_handler)
== NRF_SUCCESS);
nrf_drv_gpiote_in_event_enable(BTN_PIN, /* int enable = */ true);
NRF_GPIO->DIRSET = 1 << GPIO_TP;
/* initialize the QS software tracing... */
if (QS_INIT((void *)0) == 0) {
Q_ERROR();
}
}
示例15: BSP_init
/* BSP functions ===========================================================*/
void BSP_init(void) {
/* NOTE: SystemInit() has been already called from the startup code
* but SystemCoreClock needs to be updated
*/
SystemCoreClockUpdate();
/* turn the GPIO clock on */
LPC_SC->PCONP |= (1U << 15);
/* setup the GPIO pin functions for the LEDs... */
LPC_PINCON->PINSEL3 &= ~(3U << 4); /* LED_1: function P1.18 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 8); /* LED_2: function P1.20 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 10); /* LED_3: function P1.21 to GPIO */
LPC_PINCON->PINSEL3 &= ~(3U << 14); /* LED_4: function P1.23 to GPIO */
/* Set GPIO-P1 LED pins to output */
LPC_GPIO1->FIODIR |= (LED_1 | LED_2 | LED_3 | LED_4);
/* setup the GPIO pin function for the Button... */
LPC_PINCON->PINSEL0 &= ~(3U << 12); /* function P0.6 to GPIO, pull-up */
/* Set GPIO-P0 Button pin as input */
LPC_GPIO0->FIODIR &= ~BTN_EXT;
BSP_randomSeed(1234U);
if (QS_INIT((void *)0) == 0U) { /* initialize the QS software tracing */
Q_ERROR();
}
QS_OBJ_DICTIONARY(&l_SysTick_Handler);
QS_OBJ_DICTIONARY(&l_EINT0_IRQHandler);
QS_USR_DICTIONARY(PHILO_STAT);
}