当前位置: 首页>>代码示例>>C++>>正文


C++ receive_data函数代码示例

本文整理汇总了C++中receive_data函数的典型用法代码示例。如果您正苦于以下问题:C++ receive_data函数的具体用法?C++ receive_data怎么用?C++ receive_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了receive_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_data_dl

/*
 * Handle downlink data, ports that are handled are modem and diagnostics
 * Return 1 - ok
 * Return 0 - toggle fields are out of sync
 */
static int handle_data_dl(struct nozomi *dc, enum port_type port, u8 *toggle,
			u16 read_iir, u16 mask1, u16 mask2)
{
	if (*toggle == 0 && read_iir & mask1) {
		if (receive_data(port, dc)) {
			writew(mask1, dc->reg_fcr);
			*toggle = !(*toggle);
		}

		if (read_iir & mask2) {
			if (receive_data(port, dc)) {
				writew(mask2, dc->reg_fcr);
				*toggle = !(*toggle);
			}
		}
	} else if (*toggle == 1 && read_iir & mask2) {
		if (receive_data(port, dc)) {
			writew(mask2, dc->reg_fcr);
			*toggle = !(*toggle);
		}

		if (read_iir & mask1) {
			if (receive_data(port, dc)) {
				writew(mask1, dc->reg_fcr);
				*toggle = !(*toggle);
			}
		}
	} else {
		dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n",
			*toggle);
		return 0;
	}
	return 1;
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:39,代码来源:nozomi.c

示例2: receive_message

int receive_message(int connection, message_t *m) {
    char param[HEADER_LENGTH];
    
    receive_data(connection, m->header, sizeof(m->header));
    get_parameter(m->header, strlen(m->header), "length", param, sizeof(param));
    m->data_length = atoi(param);

    if (m->data_length) {
        m->data = malloc(m->data_length);
        receive_data(connection, m->data, m->data_length);
    }
    
    return 0;
}
开发者ID:lucat,项目名称:opendcp-1,代码行数:14,代码来源:opendcp_encoder_remote.c

示例3: receive_data

int CSectionsdClient::readResponse(char* data, int size)
{
	struct sectionsd::msgResponseHeader responseHeader;
    receive_data((char*)&responseHeader, sizeof(responseHeader));

	if ( data != NULL )
	{
		if ( responseHeader.dataLength != size )
			return -1;
		else
			return receive_data(data, size);
	}
	else
		return responseHeader.dataLength;
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:15,代码来源:sectionsdclient.cpp

示例4: readResponse

bool CSectionsdClient::getNVODTimesServiceKey(const t_channel_id channel_id, CSectionsdClient::NVODTimesList& nvod_list)
{
	if (send(sectionsd::timesNVODservice, (char*)&channel_id, sizeof(channel_id)))
	{
		nvod_list.clear();

		int nBufSize = readResponse();

		char* pData = new char[nBufSize];
		receive_data(pData, nBufSize);
		char* dp = pData;

		CSectionsdClient::responseGetNVODTimes response;

		while( dp< pData+ nBufSize )
		{
			response.service_id = *(t_service_id *) dp;			dp += sizeof(t_service_id);
			response.original_network_id = *(t_original_network_id *) dp;	dp += sizeof(t_original_network_id);
			response.transport_stream_id = *(t_transport_stream_id *) dp;	dp += sizeof(t_transport_stream_id);
			response.zeit = *(CSectionsdClient::sectionsdTime*) dp;		dp += sizeof(CSectionsdClient::sectionsdTime);

			nvod_list.insert( nvod_list.end(), response);
		}
		close_connection();
		return true;
	}
	else
	{
		close_connection();
		return false;
	}
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:32,代码来源:sectionsdclient.cpp

示例5: SendPulsesEtc

 int32
 SendPulsesEtc()
 {
     BMessage m(GNASH_PULSE);
     int32 code;
     thread_id sender;
 
     while (true)
     {
         if (B_OK != be_app_messenger.SendMessage(&m))
             return -1;
 
         unsigned int interval =
             _gui->getInterval();
         if (interval == 0)
            interval = 15;
         // interval in miliseconds, 1000 * interval in microseconds
         usleep(1000 * interval);
 
         do {
             code = receive_data(&sender, NULL, 0);
         } while (code == B_INTERRUPTED);
         switch (code)
         {
             case GNASH_SEND_PULSE:
                 break;
             case GNASH_QUITTING:
                 return 0;
             default:
                 return -1;
         };
     }
     return 0;
 }
开发者ID:diocles,项目名称:gnash,代码行数:34,代码来源:haiku.cpp

示例6: receive_data

  void connection::read()
  {
    std::array<char, 1024> buf;

    auto ptr = buf.data();
    auto len = buf.size();
    auto res = ssize_t{0};

    do
    {
      res = socket_.recv(ptr, len, 0);

      if ( res > 0 )
      {
        receive_data(ptr, res);
      }
      else if ( res < 0 )
      {
        if ( socket_.last_error() == ECONNRESET )
        {
          stop();
        }
      }
      else
      {
        stop();
      }
    }
    while ( res != 0 && res == static_cast<ssize_t>(len) );
  }
开发者ID:bebac,项目名称:fuzzy-octo-avenger,代码行数:30,代码来源:connection.cpp

示例7: register_and_load_cluster_nodes

/* register and load cluster nodes */
cluster_t * register_and_load_cluster_nodes(char *addr, int port)
{
    int i;
    int DataNum = -1;
    char Buf[MAX_BUF_LEN] = "\0";
    int BufSize = MAX_BUF_LEN;
    char szMsg[MAX_BUF_LEN] = "\0";
    char ppData[MAX_DATA_NUM][MAX_DATA_LEN] = {0};
    ServiceHandler h = -1;
    // master server's addr and port
    h = open_remote_service(IP_ADDR,PORT);

    if(addr == NULL)
    {
        DataNum = 0;
    }
    else
    {
        DataNum = 1;
        sprintf(ppData[0],"%s %d\0",addr,port);
        debug("pasrer sprintf :%s\n",ppData[0]);     
    }

    format_ctl_data(Buf,&BufSize,CTL_REG_CMD,ppData,DataNum);
    send_data(h,Buf,BufSize);
    receive_data(h,Buf,&BufSize);
    int cmd = -1;
    parse_ctl_data(Buf,BufSize,&cmd,&DataNum,ppData);
    cluster_t *cluster = init_cluster();
    add_cluster_nodes(cluster, ppData, DataNum);
    close_remote_service(h);
    return cluster;
}
开发者ID:mrmign,项目名称:armingDB,代码行数:34,代码来源:serverNode.c

示例8: receive_data

 connection receive_data(config&           cfg,
                         connection        connection_num,
                         bandwidth_in_ptr* bandwidth_in) // TODO: use this pointer
 {
     // <- just call the previous version without timeouts
     return receive_data(cfg,connection_num, static_cast<unsigned>(0), bandwidth_in);
 }
开发者ID:blackberry,项目名称:Wesnoth,代码行数:7,代码来源:network_ana.cpp

示例9: my_printf

int my_printf(const char *fmt, ...) {
	va_list args;
	char str[256];
	va_start(args, fmt);
	vsprintf(str, fmt, args);
	va_end(args);

	/* setup header and body */
	int header = PRINTF << 24;
	header |= (strlen(str) + 1); /* make sure padded with \0 */

	buff_size = 4 + strlen(str) + 1;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	int u;
	for(u=0;u<strlen(str);u++) {
		buff[4 + u] = str[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP(_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:29,代码来源:stdio.c

示例10: my_fread

size_t my_fread(void *ptr, size_t size, size_t nitems, FILE *stream) {
	int header = FREAD << 24;
	header |= 12;

	buff_size = 16;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)size);
	*(int *)(&buff[8]) = ENDIAN_FLIP((int)nitems);
	*(int *)(&buff[12]) = ENDIAN_FLIP((int)stream);

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len, j;
	char *pack = receive_data(&len, (nitems * size) + 4);

	char *ptrC = (char *)ptr;
	for(j=4;j<len;j++) {
		ptrC[j-4] = pack[j];
	}
	int _ret = (int)*(int *)pack;
	free(pack);
	/* acknowledge the host that packet has been received */
	send_data((void *)(char *)&ret, 4, 1);
	free(buff);
	return ENDIAN_FLIP((int)_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:28,代码来源:stdio.c

示例11: strlen

FILE *my_fopen(const char *filename, const char *mode) {
	int header = FOPEN << 24;
	header |= (strlen(filename) + strlen(mode) + 8);

	buff_size = 12 + strlen(filename) + strlen(mode);
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP(strlen(filename));
	*(int *)(&buff[8]) = ENDIAN_FLIP(strlen(mode));
	int u, v;
	for(u=0;u<strlen(filename);u++) {
		buff[12 + u] = filename[u];
	}
	for(v=0;u<(strlen(filename) + strlen(mode));u++,v++) {
		buff[12 + u] = mode[v];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	_ret = ENDIAN_FLIP(_ret);
	return (FILE *)_ret;
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:28,代码来源:stdio.c

示例12: my_fprintf

int my_fprintf(FILE *stream, const char *fmt, ...) {
	va_list args;
	char str[256];
	va_start(args, fmt);
	vsprintf(str, fmt, args);
	va_end(args);

	int header = FPRINTF << 24;
	header |= 4 + strlen(str) + 1;

	buff_size = 8 + strlen(str) + 1;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)stream);
	int u;
	for(u=0;u<strlen(str);u++) {
		buff[8 + u] = str[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP(_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:29,代码来源:stdio.c

示例13: my_fwrite

size_t my_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) {
	int header = FWRITE << 24;
	header |= 12 + (size * nitems);

	buff_size = 16 + (size * nitems);
	buff = (char *)calloc(buff_size, 1);
	if(buff == NULL) {
		xil_printf("buff == NULL\n");
		exit(-1);
	}
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)size);
	*(int *)(&buff[8]) = ENDIAN_FLIP((int)nitems);
	*(int *)(&buff[12]) = ENDIAN_FLIP((int)stream);

	int u;
	char *ptrC = (char *)ptr;
	for(u=0;u<(size * nitems);u++) {
		buff[16 + u] = ptrC[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP((int)_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:31,代码来源:stdio.c

示例14: Uart_receive

/*==================================================================================================

FUNCTION: Uart_receive

DESCRIPTION:

==================================================================================================*/
uint32 Uart_receive(UartHandle h, char* buf,uint32 bytes_to_rx)
{
   UART_CONTEXT* uart_ctxt;
   uint32 bytes_read;

   UART_LOG_0(INFO,"+Uart_receive");

   if (NULL == h)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive with a NULL handle.");
      return 0;
   }

   if (NULL == buf)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive with a NULL buffer.");
      return 0;
   }

   if (0 == bytes_to_rx)          { return 0; }

   uart_ctxt = (UART_CONTEXT*)h;

   if (FALSE == uart_ctxt->is_port_open)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive on a closed port.");
      return 0;
   }

   bytes_read = receive_data(uart_ctxt,buf,bytes_to_rx);
   UART_LOG_0(INFO,"-Uart_receive");

   return bytes_read;
}
开发者ID:robcore,项目名称:flybirdlaboratory_adsp_proc,代码行数:41,代码来源:Uart.c

示例15: main

int main(void)
{
	uint8_t *val;
	USART_INIT(51);
	USART_SENDSTRING("PROGRAM STARTED");
	initSPI();
	receive_init();
	DDRD |= (1<<LEDPin);		//Set LEDPin as Output
	while(1)
	{
		USART_TRANSMIT(GetReg(CONFIG));
		USART_TRANSMIT(GetReg(STATUS));
		receive_data();
		if(((GetReg(STATUS) & (1<<6)) != 0 ))
		{
			PORTD |= (1<<LEDPin);
			_delay_ms(100);
			PORTD &= ~(1<<LEDPin);
			val = WriteToNrf(R,R_RX_PAYLOAD,val,5);
			for(int i=0;i<5;i++)
			{
				USART_TRANSMIT(val[i]);
			}
		}
		reset();
	}
}
开发者ID:TheAsuraSlayer,项目名称:nRF24L01_AVR,代码行数:27,代码来源:nRF24_RX.c


注:本文中的receive_data函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。