• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ set_address函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PROCESS_THREAD

PROCESS_THREAD(snd_process, ev, data){
	static struct etimer et;
	static struct simple_udp_connection broadcast_connection;
	static uip_ipaddr_t mcast_allnodes_address;

PROCESS_BEGIN();
	etimer_set(&et, CLOCK_SECOND*HOW_MUCH_TIME);
	set_address();
	simple_udp_register(&broadcast_connection, UDP_PORT, NULL,UDP_PORT, 		callback_function);
	mcast_allnodes_address=get_multicast_all_nodes_addr();

	while(1){//A broadcast message is sent periodically
		PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
		simple_udp_sendto(&broadcast_connection, "Hello", 5, (const 		uip_ipaddr_t*)&mcast_allnodes_address);
		etimer_reset(&et);
		}
	
PROCESS_END();
}
开发者ID:PP90,项目名称:ANAWS,代码行数:19,代码来源:snd_broadcast_UDP.c


示例2: main

int main ( int argc, char **argv)
{
	struct sockaddr_in peer;
	SOCKET s;

	INIT();

	set_address(argv[1], argv[2], &peer, "upd");
	s = socket(AF_INET, SOCK_DGRAM, 0);
	if (!isvalidsock(s))
		error(1, errno, "error in call socket()");

	if (connect(s, (struct sockaddr *)&peer, sizeof(peer)))
		error (1, errno, "error in call connect");

	udpclient(s, &peer);

	EXIT(0);
}
开发者ID:codegooglecom,项目名称:vpnms,代码行数:19,代码来源:udpclient.skel.c


示例3: set_address

int LidarLiteI2C::probe()
{
	// cope with both old and new I2C bus address
	const uint8_t addresses[2] = {LL40LS_BASEADDR, LL40LS_BASEADDR_OLD};

	// more retries for detection
	_retries = 10;

	for (uint8_t i = 0; i < sizeof(addresses); i++) {
		uint8_t who_am_i = 0, max_acq_count = 0;

		// set the I2C bus address
		set_address(addresses[i]);

		/* register 2 defaults to 0x80. If this matches it is
		   almost certainly a ll40ls */
		if (read_reg(LL40LS_MAX_ACQ_COUNT_REG, max_acq_count) == OK && max_acq_count == 0x80) {
			// very likely to be a ll40ls. This is the
			// default max acquisition counter
			goto ok;
		}

		if (read_reg(LL40LS_WHO_AM_I_REG, who_am_i) == OK && who_am_i == LL40LS_WHO_AM_I_REG_VAL) {
			// it is responding correctly to a
			// WHO_AM_I. This works with older sensors (pre-production)
			goto ok;
		}

		debug("probe failed reg11=0x%02x reg2=0x%02x\n",
		      (unsigned)who_am_i,
		      (unsigned)max_acq_count);
	}

	// not found on any address
	return -EIO;

ok:
	_retries = 3;

	// reset the sensor to ensure it is in a known state with
	// correct settings
	return reset_sensor();
}
开发者ID:adityag6994,项目名称:Firmware,代码行数:43,代码来源:LidarLiteI2C.cpp


示例4: snprintf

/*
  implement wrapper for PX4 I2C driver
 */
bool PX4_I2C::do_transfer(uint8_t address, const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len)
{
    if (!init_done) {
        init_done = true;
        // we do late init() so we can setup the device paths
        snprintf(devname, sizeof(devname), "AP_I2C_%u", instance);
        snprintf(devpath, sizeof(devpath), "/dev/api2c%u", instance);
        init_ok = (init() == OK);
        if (init_ok) {
            instance++;
        }
    }
    if (!init_ok) {
        return false;
    }
    set_address(address);
    bool ret = (transfer(send, send_len, recv, recv_len) == OK);
    return ret;
}
开发者ID:ArmaJo,项目名称:ardupilot,代码行数:22,代码来源:I2CDevice.cpp


示例5: set_address

void Extsram::write_data(uint16_t start_address, uint16_t amount_of_bytes, uint32_t flash_address){
	uint16_t a;
	uint8_t byte;
	data_p_mode = out;
	addr_p_mode = out;
	for(a=0; a<amount_of_bytes; a++){
		set_address(start_address+a);
		byte = pgm_read_byte(Emulator::eeprom1_image_address+a);
		*data_p = byte;
		//_delay_us(20);
		ce = low;
		we = low;
		//_delay_us(20);
		ce = hi;
		we = hi;
		//_delay_us(20);
	}
	default_mode();
	//l.L2 = Leds::off;
}
开发者ID:ravmiecznik,项目名称:eeprom-emu-bluetooth,代码行数:20,代码来源:extsram.cpp


示例6: read_sram_mode

void Extsram::read_data_and_transmit(uint16_t start_address, uint16_t amount_of_bytes, Bluetooth* bt){
/*
 * reads provided amount of bytes to bt
 */
	uint16_t a;
	uint8_t byte;
	read_sram_mode();
	oe = low;
	for(a=0; a<amount_of_bytes; a++){
		set_address(start_address+a);
		//_delay_us(20);
		ce = low;
		//_delay_us(20);
		byte = *data_v;
		//byte = 'u';
		bt->put_c(byte);
		ce = hi;
	}
	default_mode();
}
开发者ID:ravmiecznik,项目名称:eeprom-emu-bluetooth,代码行数:20,代码来源:extsram.cpp


示例7:

/*
创建隧道对象函数
*/
Tunnel *tunnel_new_client (const char *host, int host_port)
{
	
	const char *remote;
	int remote_port;
	Tunnel *tunnel;
	tunnel=(Tunnel *)malloc(sizeof(Tunnel));
	if(tunnel==NULL)
	{
		return NULL;
	}
	tunnel->in_fd=INVALID_SOCKET;
	tunnel->out_fd=INVALID_SOCKET;
	tunnel->server_socket=INVALID_SOCKET;
	tunnel->dest.host_name=host;
	tunnel->dest.host_port=host_port;
	tunnel->dest.user_agent=NULL;
	
	tunnel->content_length=DEFAULT_CONTENT_LENGTH;
	tunnel->buf_ptr=tunnel->buf;
    tunnel->buf_len=0;
	/*
    tunnel->in_total_raw=0;
	tunnel->in_total_data=0;
	tunnel->out_total_raw=0;
	tunnel->out_total_data=0;
	*/
	tunnel->strict_content_length=FALSE;
	tunnel->bytes=0;
	remote=tunnel->dest.host_name;
	remote_port=tunnel->dest.host_port;
	if(set_address(&tunnel->address,remote,remote_port)==-1)
	{
		free(tunnel);
		return NULL;
	}
	//tunnel->keep_alive = DEFAULT_KEEP_ALIVE;
	//tunnel->max_connection_age =  DEFAULT_MAX_CONNECTION_AGE;
	//tunnel->out_connect_time = DEFAULT_OUT_CONNECTION_TIME;
	return tunnel;
}
开发者ID:340211173,项目名称:Tunnel-based-on-HTTP-,代码行数:44,代码来源:tunnel.cpp


示例8: remove_double_gaps

/* function to merge two empty gaps if they are next to each other. */
void remove_double_gaps(long *memory)
{
	long index;
	index = BLOCK_START;
	while(1)
	{
		if(block_is_used(memory[index]) == 0 && block_is_used(memory[get_index(memory[index])]) == 0)
		{
			memory[index] = set_address(memory[get_index(memory[index])], 0); 
			/* to take care of a removal between to empty gaps. */
			remove_double_gaps(memory);
			break;
		}

		index = get_index(memory[index]);
		if(index >= memory[BLOCK_MAX_INDEX])
		{
			break;
		}
	}
}
开发者ID:Snuggert,项目名称:Share,代码行数:22,代码来源:address.c


示例9: set_address

/* send general call on I2C bus to syncronise all LEDs */
int
OREOLED::send_general_call()
{
	int ret = -ENODEV;

	/* set I2C address to zero */
	set_address(0);

	/* prepare command : 0x01 = general hardware call, 0x00 = I2C address of master (but we don't act as a slave so set to zero)*/
	uint8_t msg[] = {0x01, 0x00};

	/* send I2C command */
	if (transfer(msg, sizeof(msg), nullptr, 0) == OK) {
		ret = OK;
	}

	/* record time */
	_last_gencall = hrt_absolute_time();

	return ret;
}
开发者ID:boboll,项目名称:Firmware,代码行数:22,代码来源:oreoled.cpp


示例10: new_tcp_client

int new_tcp_client(const char *host, short port)
{
	int fd;
	struct sockaddr_in address;

	fd = socket(AF_INET, SOCK_STREAM, 0);
	if (fd == -1) {
		perror("socket");
		return -1;
	}

	set_address(host, port, &address);

	if (connect(fd, (struct sockaddr*)&address, sizeof(address)) < 0) {
		perror("connect");
		close(fd);
		return -1;
	}

	return fd;
}
开发者ID:lxyscls,项目名称:PyMsg,代码行数:21,代码来源:echoTcpClient.c


示例11: DBG_SOCKET

int TCPSocketConnection::connect(const char *host, const int port) {
    if (init_socket(SOCK_STREAM, IPPROTO_TCP) < 0) {
        DBG_SOCKET("Failed to create tcp socket");
        return -1;
    }

    if (set_address(host, port) != 0) {
        DBG_SOCKET("Failed to set address (tcp)");
        return -1;
    }

    if (_cc3000_module->_socket.connect(_sock_fd, (const sockaddr *)&_remote_host, sizeof(_remote_host)) < 0) {
        DBG_SOCKET("Failed to connect (tcp)");
        close();
        return -1;
    }

    _is_connected = true;

    return 0;
}
开发者ID:Tecnologic,项目名称:ThunderCryer,代码行数:21,代码来源:TCPSocketConnection.cpp


示例12: set_address

int
MS5611::probe_address(uint8_t address)
{
	uint8_t cmd = ADDR_RESET_CMD;

	/* select the address we are going to try */
	set_address(address);

	/* send reset command */
	if (OK != transfer(&cmd, 1, nullptr, 0))
		return -EIO;

	/* wait for PROM contents to be in the device (2.8 ms) */
	usleep(3000);

	/* read PROM */
	if (OK != read_prom())
		return -EIO;

	return OK;
}
开发者ID:aliniger,项目名称:Firmware_orca,代码行数:21,代码来源:ms5611.cpp


示例13: Close

bool CMySocket::ConnectServer()
{
	Close();
	m_bfirstpack = true;
	m_bZlib = false;
	m_zlibIn.Init();
	m_zlibDe.Init();
	m_sRecvBuf.clear();

	struct sockaddr_in peer;
	if (!set_address(m_szdomian, m_port, &peer))
	{
		g_WriteLog.WriteLog(C_LOG_ERROR, "set_address error, domain:%s, port:%hd", m_szdomian, m_port);
		return FALSE;
	}
	SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
	if (s == INVALID_SOCKET)
	{
		int nerrid = WSAGetLastError();
		g_WriteLog.WriteLog(C_LOG_ERROR, "create sock error, errno=%d, %s", errno, FormatLastError(nerrid));
		return FALSE;
	}

	if (connect(s, (struct sockaddr *)&peer, sizeof(peer)))
	{
		int nerrid = WSAGetLastError();
		g_WriteLog.WriteLog(C_LOG_ERROR, "connect to %s:%hu,errno=%d, %s", m_szdomian, m_port, errno, FormatLastError(nerrid));
		closesocket(s);
		s = INVALID_SOCKET;
		return FALSE;
	}

	setNonblock(s);
	setNoDelay(s, true);


	m_hSocket = s; //赋值后导致recv线程开始执行

	return m_hSocket != INVALID_SOCKET;
}
开发者ID:StrokeAce,项目名称:YunKa_New,代码行数:40,代码来源:socket.cpp


示例14: get_env

Walker::ApplyStatus dw2wtp_do_while_statement_walker::operator () (SuifObject *x) {
	SuifEnv *env = get_env();
	DoWhileStatement *do_while_stmt = to<DoWhileStatement>(x);

	Expression *do_while_condition = do_while_stmt->get_condition();
	do_while_stmt->set_condition(0);
	Statement *do_while_body = do_while_stmt->get_body();
	do_while_stmt->set_body(0);

	IfStatement *first_iteration = create_if_statement(env, 
						to<Expression>(deep_suif_clone(do_while_condition)), 
						to<Statement>(deep_suif_clone(do_while_body)));
	WhileStatement *remaining_iterations = create_while_statement(env, do_while_condition, do_while_body);

	StatementList *replacement = create_statement_list(env);
	replacement->append_statement(first_iteration);
	replacement->append_statement(remaining_iterations);

	do_while_stmt->get_parent()->replace(do_while_stmt, replacement);
	set_address(replacement);
    	return Walker::Replaced;
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:22,代码来源:dowhile_to_while_transform_pass.cpp


示例15: dissect_vektor_igrp

static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, guint8 network)
{
  union {
    guint8 addr_bytes[4];
    guint32 addr_word;
  } addr;
  address ip_addr;

  if (network != 0) {
    /*
     * Interior route; network is the high-order byte, and the three
     * bytes in the vector are the lower 3 bytes.
     */
    addr.addr_bytes[0]=network;
    addr.addr_bytes[1]=tvb_get_guint8(tvb,0);
    addr.addr_bytes[2]=tvb_get_guint8(tvb,1);
    addr.addr_bytes[3]=tvb_get_guint8(tvb,2);
  } else {
    /*
     * System or exterior route; the three bytes in the vector are
     * the three high-order bytes, and the low-order byte is 0.
     */
    addr.addr_bytes[0]=tvb_get_guint8(tvb,0);
    addr.addr_bytes[1]=tvb_get_guint8(tvb,1);
    addr.addr_bytes[2]=tvb_get_guint8(tvb,2);
    addr.addr_bytes[3]=0;
  }

  set_address(&ip_addr, AT_IPv4, 4, &addr);
  igrp_vektor_tree = proto_tree_add_subtree_format(igrp_vektor_tree, tvb, 0 ,14,
                                                   ett_igrp_net, NULL, "Entry for network %s", address_to_str(wmem_packet_scope(), &ip_addr));
  proto_tree_add_ipv4(igrp_vektor_tree, hf_igrp_network, tvb, 0, 3, addr.addr_word);
  proto_tree_add_item(igrp_vektor_tree, hf_igrp_delay, tvb, 3, 3, ENC_BIG_ENDIAN);
  proto_tree_add_item(igrp_vektor_tree, hf_igrp_bandwidth, tvb, 6, 3, ENC_BIG_ENDIAN);
  proto_tree_add_uint_format_value(igrp_vektor_tree, hf_igrp_mtu, tvb, 9, 2, tvb_get_ntohs(tvb,9), "%d  bytes", tvb_get_ntohs(tvb,9));
  proto_tree_add_item(igrp_vektor_tree, hf_igrp_reliability, tvb, 11, 1, ENC_BIG_ENDIAN);
  proto_tree_add_item(igrp_vektor_tree, hf_igrp_load, tvb, 12, 1, ENC_BIG_ENDIAN);
  proto_tree_add_item(igrp_vektor_tree, hf_igrp_hop_count, tvb, 13, 1, ENC_BIG_ENDIAN);
}
开发者ID:redheadedrod,项目名称:wireshark,代码行数:39,代码来源:packet-igrp.c


示例16: set_address

static void
set_address (Elf *elf, size_t offset)
{
  if (elf->kind == ELF_K_AR)
    {
      Elf *child = elf->state.ar.children;

      while (child != NULL)
	{
	  if (child->map_address == NULL)
	    {
	      child->map_address = elf->map_address;
	      child->start_offset -= offset;
	      if (child->kind == ELF_K_AR)
		child->state.ar.offset -= offset;

	      set_address (child, offset);
	    }

	  child = child->next;
	}
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:23,代码来源:elf_readall.c


示例17: main

int main(void)
{
    DDRC = 0xFF;
    uart_init();
//    stdout = &mystdout;
    //setup_timer0();
    set_address(0xFFFF);

    sei();

    while(PIND & (1 <<7));
    tx_buffer.msg.app_msgs.ping_req.tag = 0x11;
    send_msg(0x1234, PING_REQ, 0x00);
    while (1)
    {
    }

        //PORTC = 0xFF;
        //PORTC = 0x00;
        //tx_char(0x55);

    return 1;
}
开发者ID:GaugeOwnerRobot,项目名称:gauge,代码行数:23,代码来源:main.c


示例18: read

    virtual void read(boost::shared_ptr<nscapi::settings_proxy> proxy, bool oneliner, bool is_sample) {
        //parent::read(proxy, oneliner, is_sample);
        set_address(this->value);
        nscapi::settings_helper::settings_registry settings(proxy);

        nscapi::settings_helper::path_extension root_path = settings.path(get_path());
        if (is_sample)
            root_path.set_sample();

        //target_object::options_type options;
        root_path.add_path()
        ("TARGET", "Target definition for: " + this->alias)
        ;

        root_path.add_key()

        ("address", sh::string_fun_key<std::string>(boost::bind(&target_object::set_address, this, _1)),
         "TARGET ADDRESS", "Target host address")

        ("host", sh::string_fun_key<std::string>(boost::bind(&target_object::set_property_string, this, "host", _1)),
         "TARGET HOST", "The target server to report results to.", true)

        ("port", sh::string_fun_key<std::string>(boost::bind(&target_object::set_property_string, this, "port", _1)),
         "TARGET PORT", "The target server port", true)

        ("timeout", sh::int_fun_key<int>(boost::bind(&target_object::set_property_int, this, "timeout", _1), 30),
         "TIMEOUT", "Timeout when reading/writing packets to/from sockets.")

        ("retries", sh::int_fun_key<int>(boost::bind(&target_object::set_property_int, this, "retries", _1), 3),
         "RETRIES", "Number of times to retry sending.")

        ;

        settings.register_all();
        settings.notify();
    }
开发者ID:jonasoberschweiber,项目名称:nscp,代码行数:36,代码来源:nscapi_targets.hpp


示例19: set_address

int
TRONE::probe()
{
	uint8_t who_am_i = 0;

	const uint8_t cmd = TRONE_WHO_AM_I_REG;

	// set the I2C bus address
	set_address(TRONE_BASEADDR);

	// can't use a single transfer as TROne need a bit of time for internal processing
	if (transfer(&cmd, 1, nullptr, 0) == OK) {
		if (transfer(nullptr, 0, &who_am_i, 1) == OK && who_am_i == TRONE_WHO_AM_I_REG_VAL) {
			return measure();
		}
	}

	DEVICE_DEBUG("WHO_AM_I byte mismatch 0x%02x should be 0x%02x\n",
		     (unsigned)who_am_i,
		     TRONE_WHO_AM_I_REG_VAL);

	// not found on any address
	return -EIO;
}
开发者ID:27Seanerz,项目名称:Firmware,代码行数:24,代码来源:trone.cpp


示例20: tcp_server

/* tcp_server - set up for a TCP server */
SOCKET tcp_server( char *hname, char *sname )
{
	struct sockaddr_in local;
	SOCKET s;
	const int on = 1;

	set_address( hname, sname, &local, "tcp" );
	s = socket( AF_INET, SOCK_STREAM, 0 );
	if ( !isvalidsock( s ) )
		error( 1, errno, "socket call failed" );

	if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR,
		( char * )&on, sizeof( on ) ) )
		error( 1, errno, "setsockopt failed" );

	if ( bind( s, ( struct sockaddr * ) &local,
		 sizeof( local ) ) )
		error( 1, errno, "bind failed" );

	if ( listen( s, NLISTEN ) )
		error( 1, errno, "listen failed" );

	return s;
}
开发者ID:Fangang,项目名称:one-hour-hack,代码行数:25,代码来源:tcp_server.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_affinity函数代码示例发布时间:2022-05-30
下一篇:
C++ set_add函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap