本文整理汇总了C++中RIMESTATS_ADD函数的典型用法代码示例。如果您正苦于以下问题:C++ RIMESTATS_ADD函数的具体用法?C++ RIMESTATS_ADD怎么用?C++ RIMESTATS_ADD使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RIMESTATS_ADD函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transmit
/*---------------------------------------------------------------------------*/
static int
transmit(unsigned short payload_len)
{
if(tx_in_progress) {
return RADIO_TX_COLLISION;
}
tx_in_progress = 1;
/* Energest */
if(listen_on) {
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
}
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
/* Transmit and wait */
vMMAC_StartPhyTransmit(&tx_frame_buffer,
E_MMAC_TX_START_NOW |
(send_on_cca ? E_MMAC_TX_USE_CCA : E_MMAC_TX_NO_CCA));
if(poll_mode) {
BUSYWAIT_UNTIL(u32MMAC_PollInterruptSource(E_MMAC_INT_TX_COMPLETE), MAX_PACKET_DURATION);
} else {
if(in_ack_transmission) {
/* as nested interupts are not possible, the tx flag will never be cleared */
BUSYWAIT_UNTIL(FALSE, MAX_ACK_DURATION);
} else {
/* wait until the tx flag is cleared */
BUSYWAIT_UNTIL(!tx_in_progress, MAX_PACKET_DURATION);
}
}
/* Energest */
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
if(listen_on) {
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
}
tx_in_progress = 0;
/* Check error code */
int ret;
uint32_t tx_error = u32MMAC_GetTxErrors();
if(tx_error == 0) {
ret = RADIO_TX_OK;
RIMESTATS_ADD(acktx);
} else if(tx_error & E_MMAC_TXSTAT_ABORTED) {
ret = RADIO_TX_ERR;
RIMESTATS_ADD(sendingdrop);
} else if(tx_error & E_MMAC_TXSTAT_CCA_BUSY) {
ret = RADIO_TX_COLLISION;
RIMESTATS_ADD(contentiondrop);
} else if(tx_error & E_MMAC_TXSTAT_NO_ACK) {
ret = RADIO_TX_NOACK;
RIMESTATS_ADD(noacktx);
} else {
ret = RADIO_TX_ERR;
}
return ret;
}
示例2: read
/*---------------------------------------------------------------------------*/
static int
read(void *buf, unsigned short bufsize)
{
int len = 0;
uint16_t radio_last_rx_crc;
uint8_t radio_last_rx_crc_ok = 1;
len = input_frame_buffer->u8PayloadLength;
if(len <= CHECKSUM_LEN) {
input_frame_buffer->u8PayloadLength = 0;
return 0;
} else {
len -= CHECKSUM_LEN;
/* Check CRC */
#if CRC_SW
uint16_t checksum = crc16_data(input_frame_buffer->uPayload.au8Byte, len, 0);
radio_last_rx_crc =
(uint16_t)(input_frame_buffer->uPayload.au8Byte[len + 1] << (uint16_t)8)
| input_frame_buffer->uPayload.au8Byte[len];
radio_last_rx_crc_ok = (checksum == radio_last_rx_crc);
if(!radio_last_rx_crc_ok) {
RIMESTATS_ADD(badcrc);
}
#endif /* CRC_SW */
if(radio_last_rx_crc_ok) {
/* If we are in poll mode we need to check the frame here */
if(poll_mode) {
if(frame_filtering &&
!is_packet_for_us(input_frame_buffer->uPayload.au8Byte, len, 0)) {
len = 0;
} else {
read_last_rssi();
}
}
if(len != 0) {
bufsize = MIN(len, bufsize);
memcpy(buf, input_frame_buffer->uPayload.au8Byte, bufsize);
RIMESTATS_ADD(llrx);
if(!poll_mode) {
/* Not in poll mode: packetbuf should not be accessed in interrupt context */
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, radio_last_rssi);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, radio_last_correlation);
}
}
} else {
len = 0;
}
/* Disable further read attempts */
input_frame_buffer->u8PayloadLength = 0;
}
return len;
}
示例3: prepare
/*---------------------------------------------------------------------------*/
static int
prepare(const void *payload, unsigned short payload_len)
{
uint8_t i;
uint16_t checksum;
RIMESTATS_ADD(lltx);
if(tx_in_progress) {
return 1;
}
if(payload_len > 127 || payload == NULL) {
return 1;
}
/* Copy payload to (soft) Ttx buffer */
memcpy(tx_frame_buffer.uPayload.au8Byte, payload, payload_len);
i = payload_len;
#if CRC_SW
/* Compute CRC */
checksum = crc16_data(payload, payload_len, 0);
tx_frame_buffer.uPayload.au8Byte[i++] = checksum;
tx_frame_buffer.uPayload.au8Byte[i++] = (checksum >> 8) & 0xff;
tx_frame_buffer.u8PayloadLength = payload_len + CHECKSUM_LEN;
#else
tx_frame_buffer.u8PayloadLength = payload_len;
#endif
return 0;
}
示例4: runicast_send
/*---------------------------------------------------------------------------*/
int
runicast_send(struct runicast_conn *c, const rimeaddr_t *receiver,
uint8_t max_retransmissions)
{
int ret;
if(runicast_is_transmitting(c)) {
PRINTF("%d.%d: runicast: already transmitting\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
return 0;
}
packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 1);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_DATA);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, c->sndnxt);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, 3);
c->max_rxmit = max_retransmissions;
c->rxmit = 0;
c->is_tx = 1;
RIMESTATS_ADD(reliabletx);
PRINTF("%d.%d: runicast: sending packet %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->sndnxt);
ret = stunicast_send_stubborn(&c->c, receiver, REXMIT_TIME);
if(!ret) {
c->is_tx = 0;
}
return ret;
}
示例5: cc2520_prepare
/*---------------------------------------------------------------------------*/
static int
cc2520_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
GET_LOCK();
PRINTF("cc2520: sending %d bytes\n", payload_len);
/*int i;
for(i = 0; i < payload_len;i++)
printf("%x",((uint8_t *) payload)[i]);
printf("\n");*/
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2520_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2520_INS_SFLUSHTX);
total_len = payload_len + FOOTER_LEN;
CC2520_WRITE_FIFO_BUF(&total_len, 1);
CC2520_WRITE_FIFO_BUF(payload, payload_len);
RELEASE_LOCK();
return 0;
}
示例6: cc2420_prepare
/*---------------------------------------------------------------------------*/
static int
cc2420_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
#if CC2420_CONF_CHECKSUM
uint16_t checksum;
#endif /* CC2420_CONF_CHECKSUM */
GET_LOCK();
PRINTF("cc2420: sending %d bytes\n", payload_len);
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2420_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2420_SFLUSHTX);
#if CC2420_CONF_CHECKSUM
checksum = crc16_data(payload, payload_len, 0);
#endif /* CC2420_CONF_CHECKSUM */
total_len = payload_len + AUX_LEN;
CC2420_WRITE_FIFO_BUF(&total_len, 1);
CC2420_WRITE_FIFO_BUF(payload, payload_len);
#if CC2420_CONF_CHECKSUM
CC2420_WRITE_FIFO_BUF(&checksum, CHECKSUM_LEN);
#endif /* CC2420_CONF_CHECKSUM */
RELEASE_LOCK();
return 0;
}
示例7: uwb_dma_interrupt
void uwb_dma_interrupt(void)
{
/* DMA transaction finished */
if (uwb_fsm == UWB_STATE_RX_LEN_DOWNLOAD)
{
/* we downloaded the frame length - now download the frame! */
if (ram_rx_buffer[2] > 0)
{
ram_tx_buffer[0] = CMD_READ_RAM_RX;
hal_spi_dma_transfer(ram_tx_buffer, ram_rx_buffer, ram_rx_buffer[2]+3);
uwb_fsm = UWB_STATE_RX_FRAME_DOWNLOAD;
}
else
{
/* directly poll process to handle zero-length frame */
process_poll(&uwb_process);
RIMESTATS_ADD(llrx);
uwb_fsm = UWB_STATE_RX_PROCESS_POLLED;
}
}
else if (uwb_fsm == UWB_STATE_RX_FRAME_DOWNLOAD)
{
/* download complete, poll process */
process_poll(&uwb_process);
RIMESTATS_ADD(llrx);
uwb_fsm = UWB_STATE_RX_PROCESS_POLLED;
}
else if (uwb_fsm == USB_STATE_TX_FRAME_UPLOAD)
{
/* tx frame uploaded, move back to listen state */
/* here we could also implement a mechanism that starts the tx by sending config right away */
uwb_fsm = UWB_STATE_LISTEN;
// PRINTF("d1");
}
else if (uwb_fsm == USB_STATE_TX_CONFIG_UPLOAD)
{
/* tx config uploaded, assume the phy is transmitting now */
uwb_fsm = USB_STATE_TX_ACTIVE;
/* enable tx-int */
HAL_ENABLE_IRQ1( );
// PRINTF("d2");
}
}
示例8: rime_output
/*---------------------------------------------------------------------------*/
int
rime_output(struct channel *c)
{
RIMESTATS_ADD(tx);
if(chameleon_create(c)) {
packetbuf_compact();
NETSTACK_MAC.send(packet_sent, c);
return 1;
}
return 0;
}
示例9: sent_by_stunicast
/*---------------------------------------------------------------------------*/
static void
sent_by_stunicast(struct stunicast_conn *stunicast, int status, int num_tx)
{
struct runicast_conn *c = (struct runicast_conn *)stunicast;
PRINTF("runicast: sent_by_stunicast c->rxmit %d num_tx %d\n",
c->rxmit, num_tx);
/* Only process data packets, not ACKs. */
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_DATA) {
c->rxmit += 1;
if(c->rxmit != 0) {
RIMESTATS_ADD(rexmit);
PRINTF("%d.%d: runicast: sent_by_stunicast packet %u (%u) resent %u\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID),
c->sndnxt, c->rxmit);
}
if(c->rxmit >= c->max_rxmit) {
RIMESTATS_ADD(timedout);
c->is_tx = 0;
stunicast_cancel(&c->c);
if(c->u->timedout) {
c->u->timedout(c, stunicast_receiver(&c->c), c->rxmit);
}
c->rxmit = 0;
PRINTF("%d.%d: runicast: packet %d timed out\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->sndnxt);
c->sndnxt = (c->sndnxt + 1) % (1 << RUNICAST_PACKET_ID_BITS);
} else {
// int shift;
// shift = c->rxmit > 4? 4: c->rxmit;
// stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
}
}
}
示例10: qsend_packet
static int
qsend_packet(void)
{
if(someone_is_sending) {
PRINTF("xmac: should queue packet, now just dropping %d %d %d %d.\n",
waiting_for_packet, someone_is_sending, we_are_sending, radio_is_on);
if(queued_packet != NULL) {
RIMESTATS_ADD(sendingdrop);
return 0;
} else {
#if WITH_QUEUE
queued_packet = queuebuf_new_from_rimebuf();
return 1;
#else
RIMESTATS_ADD(sendingdrop);
return 0;
#endif
}
} else {
PRINTF("xmac: send immediately.\n");
return send_packet();
}
}
示例11: input
/*---------------------------------------------------------------------------*/
static void
input(const struct mac_driver *r)
{
int len;
struct rime_sniffer *s;
len = rime_mac->read();
if(len > 0) {
for(s = list_head(sniffers); s != NULL; s = s->next) {
if(s->input_callback != NULL) {
s->input_callback();
}
}
RIMESTATS_ADD(rx);
chameleon_input();
}
}
示例12: qsend_packet
/*---------------------------------------------------------------------------*/
static void
qsend_packet(mac_callback_t sent, void *ptr)
{
int ret;
if(someone_is_sending) {
PRINTF("cxmac: should queue packet, now just dropping %d %d %d %d.\n",
waiting_for_packet, someone_is_sending, we_are_sending, radio_is_on);
RIMESTATS_ADD(sendingdrop);
ret = MAC_TX_COLLISION;
} else {
PRINTF("cxmac: send immediately.\n");
ret = send_packet();
}
mac_call_sent_callback(sent, ptr, ret, 1);
}
示例13: radio_read
/*---------------------------------------------------------------------------*/
static int
radio_read(void *buf, unsigned short bufsize)
{
int tmp = simInSize;
if (simInSize == 0) {
return 0;
}
if(bufsize < simInSize) {
simInSize = 0; /* rx flush */
RIMESTATS_ADD(toolong);
return 0;
}
memcpy(buf, simInDataBuffer, simInSize);
simInSize = 0;
return tmp;
}
示例14: input
/*---------------------------------------------------------------------------*/
static void
input(void)
{
struct rime_sniffer *s;
struct channel *c;
RIMESTATS_ADD(rx);
c = chameleon_parse();
for(s = list_head(sniffers); s != NULL; s = list_item_next(s)) {
if(s->input_callback != NULL) {
s->input_callback();
}
}
if(c != NULL) {
abc_input(c);
}
}
示例15: rime_output
/*---------------------------------------------------------------------------*/
void
rime_output(void)
{
struct rime_sniffer *s;
RIMESTATS_ADD(tx);
packetbuf_compact();
if(rime_mac) {
if(rime_mac->send()) {
/* Call sniffers, but only if the packet was sent. */
for(s = list_head(sniffers); s != NULL; s = s->next) {
if(s->output_callback != NULL) {
s->output_callback();
}
}
}
}
}