void info( const T&... args) {
#ifndef __divine__
    pthread_mutex_lock( &mutex );
    _info( args... );
    pthread_mutex_unlock( &mutex );
#endif
}
Exemple #2
0
void c_peering_udp::send_data_udp_cmd(c_protocol::t_proto_cmd cmd, const string_as_bin & bin, int udp_socket) {
	_info("Send to peer (COMMAND): command="<<static_cast<int>(cmd)<<" data: " << string_as_dbg(bin).get() ); // TODO .get
	string_as_bin raw;
    raw.bytes += c_protocol::current_version;
    raw.bytes += cmd;
	raw.bytes += bin.bytes;
	this->send_data_RAW_udp(raw.bytes.c_str(), raw.bytes.size(), udp_socket);
}
Exemple #3
0
void c_the_program::init_library_sodium() {
	_fact(mo_file_reader::gettext("L_starting_lib_libsodium"));

	if (sodium_init() == -1) {
		_throw_error( std::runtime_error(mo_file_reader::gettext("L_lisodium_init_err")) );
	}
	_info(mo_file_reader::gettext("L_libsodium_ready"));
}
Exemple #4
0
c_haship_addr::c_haship_addr(tag_constr_by_hash_of_pubkey, const c_haship_pubkey & pubkey)
	 : std::array<unsigned char, g_haship_addr_size>({{}})
{
	_info("Creating HIP from pubkey: " << pubkey);

	string addr = pubkey.get_ipv6_string_bin();
	for (size_t i=0; i<16; ++i) at(i) = addr.at(i);
}
Exemple #5
0
void c_node::send_osi3_data_to_dst(t_osi3_uuid dst, t_osi2_data &&data) {
	_info("send_osi3_data_to_dst(), send data to " << dst);
	t_osi3_packet packet;
	packet.m_data = std::move(data); // move the data here
	packet.m_dst = dst; 
	packet.m_src = this->get_uuid_any(); // I am the sender. TODO choose the proper card that will be used - routing
	m_outbox.emplace_back( packet ); // to my, switch'es global outbox
}
Exemple #6
0
t_peering_reference::t_peering_reference(const c_ip46_addr & peering_addr, const t_ipv6dot & peering_hip)
	:
	peering_addr( peering_addr )
	,haship_addr( c_haship_addr::tag_constr_by_addr_dot() , peering_hip  )
{
	_info("peering REFERENCE created, now peering_addr=" << this->peering_addr << " on port="
		  << peering_addr.get_assign_port() << ", and this is: " << (*this) );
}
Exemple #7
0
static int check_forceusbboot(void)
{
  uint32_t val;
  uint32_t val1;

  /* enable clock & unreset */

  modifyreg32(MCLKCNTAPB, 0, MCLKCNTAPB_ADC_CLKEN);
  modifyreg32(MRSTCNTAPB, 0, MRSTCNTAPB_ADC_RSTB);

  usleep(10000);

  /* start ADC0,1 */

  putreg32(rADCCTL_fADCNVCK_DIV32 | rADCCTL_fADACT | rADCCTL_fADCHSCN |
           1 /* 0,1 ch */, rADCCTL);

  putreg32(53, rADCSMPL);

  /* wait for adc done */

  while ((getreg32(rADCSTS) & rADCSTS_fADCMPL) == 0)
    ;

  val = getreg32(rADC0DT);
  val1 = getreg32(rADC1DT);

  _info("val = %d, val1 = %d\n", val, val1);

  /* disable clock & reset */

  modifyreg32(MCLKCNTAPB, MCLKCNTAPB_ADC_CLKEN, 0);
  modifyreg32(MRSTCNTAPB, MRSTCNTAPB_ADC_RSTB, 0);

  /* check KEY0_AD_D key pressed */

  if (val >= (0x3A << 2) && val < (0x57 << 2))
    {
      return 1;
    }

  /* check KEY0_AD_B key pressed */

  if (val >= (0x0B << 2) && val < (0x20 << 2))
    {
      return 1;
    }

  /* check KEY1_AD_B key pressed */

  if (val1 >= (0x0B << 2) && val1 < (0x20 << 2))
    {
      return 1;
    }

  return 0;
}
Exemple #8
0
void cInstancePingable::PongLoop() {

	const int time_latency_wakeup = 200; // various wakeup latency, like at beginning and when hanged
	const int time_latency_pong = 500; // how often to send pong

	while (!m_go_flag) {
		std::this_thread::sleep_for(std::chrono::milliseconds(time_latency_wakeup));
	}
	
	_info("PongLoop - begin for m_mutex_name="<<m_mutex_name);
	const int recreate_trigger = 1000; // how often to recreate the object
	int need_recreate = recreate_trigger; // should we (re)create the mutex object now - counter. start at high level to create it initially
	while (m_run_flag) {
		_info("pong loop...");

		while (m_hang_pings && m_run_flag) {
			std::this_thread::sleep_for(std::chrono::milliseconds(time_latency_wakeup));
		}

		// create object if needed
		++need_recreate; // so we will recreate it from time to time
		if (need_recreate >= recreate_trigger) {
			_info("pong: CREATING the object now for m_mutex_name="<<m_mutex_name);
			m_pong_obj.reset( 
				new cMyNamedMutex ( boost::interprocess::open_or_create, m_mutex_name.c_str(), m_mutex_perms ) 
			);
			_info("pong: CREATED object has name: " << m_pong_obj->GetName() );
			need_recreate=false;
		}

		try {
			_info("unlocking: "<<m_pong_obj->GetName());
			m_pong_obj->unlock(); ///< this signals that we are alive <--- ***
			_info("***PONG*** - unlock worked now");
		} 
		catch(warning_already_unlocked) {
			_info("... was already unlocked");
		}
		catch(...) { 
			_info("WARNING: unlocking failed - exception: need to re-create the object probably");
			need_recreate = recreate_trigger; 
		}

		std::this_thread::sleep_for(std::chrono::milliseconds(time_latency_pong)); // sleep TODO config
	}

	_info("PongLoop - end");
}
Exemple #9
0
void c_tun_device_windows::set_ipv6_address
	(const std::array<uint8_t, 16> &binary_address, int prefixLen)
{
	_fact("Setting IPv6 address, prefixLen="<<prefixLen);
	std::wstring human_name = get_human_name(m_guid);
	NET_LUID luid = get_luid(human_name);
	_fact("Setting address on human_name " << to_string(human_name));// << " luid=" << to_string(luid));
	// remove old address
	MIB_UNICASTIPADDRESS_TABLE *table = nullptr;
	NETIOAPI_API status = GetUnicastIpAddressTable(AF_INET6, &table);
	if (status != NO_ERROR) throw std::runtime_error("GetUnicastIpAddressTable error, code");
	for (int i = 0; i < static_cast<int>(table->NumEntries); ++i) {
		_info("Removing old addresses, i="<<i);
		if (table->Table[i].InterfaceLuid.Value == luid.Value) {
		_info("Removing old addresses, entry i="<<i<<" - will remove");
			if (DeleteUnicastIpAddressEntry(&table->Table[i]) != NO_ERROR) {
				FreeMibTable(table);
				throw std::runtime_error("DeleteUnicastIpAddressEntry error");
			}
		}
	}
	FreeMibTable(table);

	// set new address
	_fact("Setting new IP address");
	MIB_UNICASTIPADDRESS_ROW iprow;
	std::memset(&iprow, 0, sizeof(iprow));
	iprow.PrefixOrigin = IpPrefixOriginUnchanged;
	iprow.SuffixOrigin = IpSuffixOriginUnchanged;
	iprow.ValidLifetime = 0xFFFFFFFF;
	iprow.PreferredLifetime = 0xFFFFFFFF;
	iprow.OnLinkPrefixLength = 0xFF;

	iprow.InterfaceLuid = luid;
	iprow.Address.si_family = AF_INET6;
	std::memcpy(&iprow.Address.Ipv6.sin6_addr, binary_address.data(), binary_address.size());
	iprow.OnLinkPrefixLength = prefixLen;

	_fact("Creating unicast IP");
	status = CreateUnicastIpAddressEntry(&iprow);
	if (status != NO_ERROR) throw std::runtime_error("CreateUnicastIpAddressEntry error");
	_goal("Created unicast IP, status=" << status);
}
Exemple #10
0
bool AudioRecord::isFileExist()
{
    _info ("AudioRecord: Try to open name : %s ", fileName_);

    if (fopen (fileName_,"rb") ==0) {
        return true;
    }

    return false;
}
Exemple #11
0
c_ip46_addr::c_ip46_addr(const std::string &ip_addr, int port) {
	// ports-TODO(r) also parse the port here
	// TODO parsing ipv6
	if (is_ipv4(ip_addr)) {
		(*this) = create_ipv4(ip_addr, port);
	} else {
		(*this) = create_ipv6(ip_addr, port);
	}
	_info("Parsing ip46 from string ["<<ip_addr<<":" << port << "] created: " << (*this));
}
Exemple #12
0
static int stm32l4_rng_initialize(void)
{
  _info("Initializing RNG\n");

  memset(&g_rngdev, 0, sizeof(struct rng_dev_s));

  sem_init(&g_rngdev.rd_devsem, 0, 1);

  if (irq_attach(STM32L4_IRQ_RNG, stm32l4_rnginterrupt))
    {
      /* We could not attach the ISR to the interrupt */

      _info("Could not attach IRQ.\n");

      return -EAGAIN;
    }

  return OK;
}
Exemple #13
0
void c_protocol::send_packet(const t_nym_id &destination_address, const e_packet_type &packet_type, const std::string &data) {
	_info("start serialize");
	std::ostringstream oss(std::ios_base::out | std::ios_base::binary);
	uint16_t uint_type = static_cast<uint16_t>(packet_type);
	_info("packet_type " << packet_type);
	oss.write(reinterpret_cast<char *>(&uint_type), sizeof(uint_type));
	
	uint32_t uint_data_size = data.size();
	oss.write(reinterpret_cast<char *>(&uint_data_size), sizeof(uint_data_size));
	oss << data;
	_info("end of serialization");
	
	_info("add to outbox");
	s_packet raw_packet;
	raw_packet.m_data = std::move(oss.str());
	raw_packet.m_packet_type = packet_type;
	raw_packet.m_address = destination_address;
	m_outbox.emplace_back(std::move(raw_packet));
}
Exemple #14
0
wrap_thread &wrap_thread::operator=(wrap_thread &&rhs) noexcept {
	_note("Moving thread -START- from rhs onto me ");
	if (&rhs == this) {
		_info("Moving onto myself? Ignoring.");
		return *this;
	}
	join();
	m_future = std::move(rhs.m_future);
	_note("Moving thread -DONE- from rhs onto me ");
	return *this;
}
Exemple #15
0
bool AudioRecord::setRecording()
{

    if (isOpenFile()) {
        if (!recordingEnabled_) {
            _info ("AudioRecording: Start recording");
            recordingEnabled_ = true;
        } else {
            recordingEnabled_ = false;
            _info ("AudioRecording: Stop recording");
        }
    } else {
        openFile();

        recordingEnabled_ = true; // once opend file, start recording
    }

    // WARNING: Unused return value
    return true;

}
Exemple #16
0
int ConnectionServer::ReleaseConnection(Connection* conn)
{
	pthread_mutex_lock(&_map_mutex);
	_info("ConnectionServer::ReleaseConnection coming\n");
	if(conn->release() == 0 && (conn->GetFlag() & ERROR_SOCKET))
	//if(conn->release() == 0)
	{
		int fd = conn->GetFd();
        	del_input_fd(fd);
		int ret=::close(fd);
		delete conn;
		conn = NULL;
		m_fd_set.erase(fd);
		pthread_mutex_lock(&_connections_mutex);
		_now_connections--;
		pthread_mutex_unlock(&_connections_mutex);
		_info("ConnectionServer::ReleaseConnection close connection (%d) ret=%d\n",fd,ret);
	}	
	pthread_mutex_unlock(&_map_mutex);
	return 0;
}
Exemple #17
0
bool cInstanceObject::BeTheOnlyInstance() {
	int instance=1;
	t_instance_outcome outcome = e_instance_unknown; 
	while (!(  outcome==e_instance_i_won  ||  outcome==e_instance_i_lost )) { // untill we win or lose
		outcome = TryToBecomeInstance(instance);
		if (outcome==e_instance_seems_dead) {
			_info("*** Previous instance at instance="<<instance<<" was dead.");
			++instance;
		}
	}
	return outcome==e_instance_i_won ;
}
Exemple #18
0
static int check_diskformat(void)
{
  int ret;

#ifdef CONFIG_FS_EVFAT
  struct evfat_format_s fmt = EVFAT_FORMAT_INITIALIZER;

  /* load MBR */

  ret = blk_read(copybuf, sizeof(copybuf), "/dev/mtdblock0p2", 0);

  if (ret < 0)
    {
      return 0;
    }

  /* If part2 has MBR signature, this eMMC was formated by PC.
   * This means the set is just after writing IPL2.
   */

  if (copybuf[510] != 0x55 || copybuf[511] != 0xaa)
    {
      return 0;
    }

  ret = mkevfatfs(CONFIG_MTD_CP_DEVPATH, &fmt);
#endif

  _info("FORMAT content partition : %d\n", ret);

  memset(copybuf, 0, sizeof(copybuf));
  ret = blk_write(copybuf, 512, CONFIG_MTD_ETC_DEVPATH, 0);
  _info("clear /etc : %d\n", ret);
  ret = blk_write(copybuf, 512, CONFIG_MTD_SYSTEM_DEVPATH, 0);
  _info("clear /system : %d\n", ret);
  ret = blk_write(copybuf, 512, CONFIG_MTD_CACHE_DEVPATH, 0);
  _info("clear /cache : %d\n", ret);

  return 1;
}
Exemple #19
0
size_t draft_net2_testsend(t_clock use_tdelta, t_netspeed_bps use_speed, size_t use_size, t_clock sim_length, int dbg) { 
	_mark("Test with use_tdelta="<<use_tdelta<<" use_speed="<<use_speed<<" use_size="<<use_size);
	
	t_netspeed_bps m_net_speed = use_speed;
	t_netsize_fraction m_net_reminder = 0; // bytes that remain partially accumulated from previous iterations
	
	size_t totall_sent=0;
	t_clock clock = 0;	 // world clock in simulation
	
	size_t c=0; // cycle number
	while (true) { // simulation
		++c;
		if (clock>=sim_length) break; // end
		
		t_clock tdelta = use_tdelta;
		clock += tdelta;
		size_t packet_size = use_size;
		
		t_netsize_fraction bytes_now_part = tdelta * m_net_speed ; // bytes we transfer just now 
		t_netsize_fraction bytes_now_all = bytes_now_part + m_net_reminder; // bytes we can now transfer with reminder
		
		t_netsize_fraction send_bytes = bytes_now_all;
		
		if (dbg) _info("=== clock="<<clock<<", cycle="<<c<<", m_net_reminder=" << m_net_reminder
		               << " bytes_now_all=" << bytes_now_all );
		while (send_bytes > packet_size) { // send a packet
			if (dbg) _info("*** SENDING at clock="<<clock<<", cycle="<<c<<", m_net_reminder=" << m_net_reminder);
			totall_sent += packet_size;
			send_bytes -= packet_size;
		}
		
		if (1) { // there is any more data waiting to be sent
			if (dbg) _info("Will send reminder to send_bytes="<<send_bytes);
			m_net_reminder = send_bytes; // "start" sending remaining data - in future
		}
		
		// TODO account for in progress the reminder of time in this cycle
	}
	return totall_sent;
}
Exemple #20
0
void up_dumpnvic(FAR const char *msg)
{
#ifdef CONFIG_DEBUG_INFO
  irqstate_t flags;
  int i;

  /* The following requires exclusive access to the NVIC/SYSCON registers */

  flags = enter_critical_section();

  _info("NVIC: %s\n", msg);
  _info("   ISER: %08x  ICER: %08x  ISPR: %08x  ICPR: %08x\n",
       getreg32(ARMV6M_NVIC_ISER), getreg32(ARMV6M_NVIC_ICER),
       getreg32(ARMV6M_NVIC_ISPR), getreg32(ARMV6M_NVIC_ICPR));

  for (i = 0 ; i < 8; i += 4)
    {
      _info("   IPR%d: %08x  IPR%d: %08x  IPR%d: %08x  IPR%d: %08x\n",
           i,   getreg32(ARMV6M_NVIC_IPR(i)),
           i+1, getreg32(ARMV6M_NVIC_IPR(i+1)),
           i+2, getreg32(ARMV6M_NVIC_IPR(i+2)),
           i+3, getreg32(ARMV6M_NVIC_IPR(i+3)));
    }

  _info("SYSCON:\n");
  _info("  CPUID: %08x  ICSR: %08x AIRCR: %08x   SCR: %08x\n",
       getreg32(ARMV6M_SYSCON_CPUID), getreg32(ARMV6M_SYSCON_ICSR),
       getreg32(ARMV6M_SYSCON_AIRCR), getreg32(ARMV6M_SYSCON_SCR));
  _info("    CCR: %08x SHPR2: %08x SHPR3: %08x\n",
       getreg32(ARMV6M_SYSCON_CCR),   getreg32(ARMV6M_SYSCON_SHPR2),
       getreg32(ARMV6M_SYSCON_SHPR3));

  leave_critical_section(flags);
#endif
}
Exemple #21
0
void AudioRecord::createFilename()
{

    time_t rawtime;

    struct tm * timeinfo;

    rawtime = time (NULL);
    timeinfo = localtime (&rawtime);

    std::stringstream out;

    // DATE
    out << timeinfo->tm_year+1900;

    if (timeinfo->tm_mon < 9) // january is 01, not 1
        out << 0;

    out << timeinfo->tm_mon+1;

    if (timeinfo->tm_mday < 10) // 01 02 03, not 1 2 3
        out << 0;

    out << timeinfo->tm_mday;

    out << '-';

    // hour
    if (timeinfo->tm_hour < 10) // 01 02 03, not 1 2 3
        out << 0;

    out << timeinfo->tm_hour;

    out << ':';

    if (timeinfo->tm_min < 10) // 01 02 03, not 1 2 3
        out << 0;

    out << timeinfo->tm_min;

    out << ':';

    if (timeinfo->tm_sec < 10) // 01 02 03,  not 1 2 3
        out << 0;

    out << timeinfo->tm_sec;

    // fileName_ = out.str();
    strncpy (fileName_, out.str().c_str(), 8192);

    _info ("AudioRecord: create filename for this call %s ", fileName_);
}
Exemple #22
0
int _sysfs_prop_get_str(struct iscsi_context *ctx, const char *dir_path,
			const char *prop_name, char *buff, size_t buff_size,
			const char *default_value)
{
	char file_path[PATH_MAX];
	int rc = LIBISCSI_OK;
	int errno_save = 0;

	assert(dir_path != NULL);
	assert(prop_name != NULL);
	assert(buff != NULL);

	snprintf(file_path, PATH_MAX, "%s/%s", dir_path, prop_name);

	errno_save = sysfs_read_file(file_path, (uint8_t *) buff, buff_size);
	if (errno_save != 0) {
		if (errno_save == ENOENT) {
			if (default_value == NULL) {
				rc = LIBISCSI_ERR_SYSFS_LOOKUP;
				_error(ctx, "Failed to read '%s': "
				       "file '%s' does not exists", prop_name,
				       file_path);
			} else {
				_info(ctx, "Failed to read '%s': "
				      "file '%s' does not exists, "
				      "using default value %s", prop_name,
				      file_path, default_value);
				memcpy(buff, (void *) default_value,
				       strlen(default_value) + 1);
			}
		} else if (errno_save == EACCES) {
			rc = LIBISCSI_ERR_ACCESS;
			_error(ctx, "Failed to read '%s': "
			       "permission deny when reading '%s'", prop_name,
			       file_path);
		} else {
			rc = LIBISCSI_ERR_BUG;
			_error(ctx, "Failed to read '%s': "
			       "error when reading '%s': %d", prop_name,
			       file_path, errno_save);
		}
	} else {
		if ((buff[0] == '\0') && (default_value != NULL)) {
			memcpy(buff, (void *) default_value,
			       strlen(default_value) + 1);
			_debug(ctx, "Open '%s', got NULL, using default value",
			       file_path, default_value);
		} else
			_debug(ctx, "Open '%s', got '%s'", file_path, buff);
	}
	return rc;
}
Exemple #23
0
static int chat_expect(FAR struct chat* priv, FAR const char* s)
{
  char c;
  struct timespec abstime;
  struct timespec endtime;
  int timeout_ms;
  int s_len = strlen(s);
  int i_match = 0; /* index of the next character to be matched in s */
  int ret = 0;

  /* Get initial time and set the end time */

  clock_gettime(CLOCK_REALTIME, (FAR struct timespec*) &abstime);
  endtime.tv_sec  = abstime.tv_sec + priv->ctl.timeout;
  endtime.tv_nsec = abstime.tv_nsec;

  while (!ret && i_match < s_len &&
         (abstime.tv_sec < endtime.tv_sec ||
          (abstime.tv_sec == endtime.tv_sec &&
           abstime.tv_nsec < endtime.tv_nsec)))
    {
      timeout_ms =
        (endtime.tv_sec - abstime.tv_sec) * 1000 +
        (endtime.tv_nsec - abstime.tv_nsec) / 1000000;

      DEBUGASSERT(timeout_ms >= 0);

      ret = chat_readb(priv, &c, timeout_ms);
      if (!ret)
        {
          if (c == s[i_match])
            {
              /* Continue matching the next character */

              i_match++;
            }
          else
            {
              /* Match failed; start anew */

              i_match = 0;
            }

          /* Update current time */

          clock_gettime(CLOCK_REALTIME, (FAR struct timespec*) &abstime);
        }
    }

  _info("result %d\n", ret);
  return ret;
}
Exemple #24
0
void c_peering_udp::send_data_udp(const char * data, size_t data_size, int udp_socket,
	c_haship_addr src_hip, c_haship_addr dst_hip, int ttl, antinet_crypto::t_crypto_nonce nonce_used) {
	_info("Send to peer (tunneled data) data: " << string_as_dbg(data,data_size).get() ); // TODO .get

	trivialserialize::generator gen(data_size + 50);
	gen.push_byte_u( c_protocol::current_version );
	gen.push_byte_u( c_protocol::e_proto_cmd_tunneled_data );
	gen.push_bytes_n( g_ipv6_rfc::length_of_addr , to_binary_string(src_hip) );
	gen.push_bytes_n( g_ipv6_rfc::length_of_addr , to_binary_string(dst_hip) );
	gen.push_byte_u( ttl );
	gen.push_bytes_n( crypto_box_NONCEBYTES , nonce_used.get().to_binary() ); // TODO avoid conversion/copy
	gen.push_varstring( std::string(data, data+data_size)  ); // TODO view_string

/*
	// TODONOW turn off this crypto (unless leave here for peer-to-peer auth only)
	static unsigned char generated_shared_key[crypto_generichash_BYTES] = {43, 124, 179, 100, 186, 41, 101, 94, 81, 131, 17,
					198, 11, 53, 71, 210, 232, 187, 135, 116, 6, 195, 175,
					233, 194, 218, 13, 180, 63, 64, 3, 11};

	static unsigned char nonce[crypto_aead_chacha20poly1305_NPUBBYTES] = {148, 231, 240, 47, 172, 96, 246, 79};
	static unsigned char additional_data[] = {1, 2, 3};
	static unsigned long long additional_data_len = 3; // TODO

	// TODO randomize this data XXX use real crypto data

	const int header_size = c_protocol::version_size + c_protocol::cmd_size + c_protocol::ttl_size ; //  [protocol] TODO pack this into protocol class --r

	// TODO allocate buffer outside
	std::unique_ptr<unsigned char[]> protomsg(new unsigned char[data_size + crypto_aead_chacha20poly1305_ABYTES + header_size ]); // plus the headers
	// long long? or u64? --r assert size  sizeof(long long  .... == ...

	// why? --r:
	assert(crypto_aead_chacha20poly1305_KEYBYTES <= crypto_generichash_BYTES);

	// write headers:
	protomsg.get()[0] = c_protocol::current_version;
	protomsg.get()[1] = c_protocol::e_proto_cmd_tunneled_data; // this are tunneled data
	assert( (ttl >= 0) && (ttl <= c_protocol::ttl_max_value_ever) );
	protomsg.get()[2] = ttl; // ...this is their route ttl

	unsigned char * ciphertext_buf = protomsg.get() + header_size; // just-pointer to part of protomsg where to write the message!
	unsigned long long ciphertext_buf_len = 0; // encryption will write here the resulting size
    crypto_aead_chacha20poly1305_encrypt(ciphertext_buf, &ciphertext_buf_len, reinterpret_cast<const unsigned char *>(data), data_size, additional_data,
                                         additional_data_len, NULL, nonce, generated_shared_key);
	unsigned long long protomsg_len = ciphertext_buf_len + header_size; // the output of crypto, plus the header in front

	// TODO asserts!!!
*/

	string protomsg = gen.str(); // TODO view_string
	this->send_data_RAW_udp(protomsg.c_str(), protomsg.size(), udp_socket);
}
Exemple #25
0
static int up_getplaneinfo(FAR struct fb_vtable_s *vtable, int planeno,
                           FAR struct fb_planeinfo_s *pinfo)
{
  _info("vtable=%p planeno=%d pinfo=%p\n", vtable, planeno, pinfo);
  if (vtable && planeno == 0 && pinfo)
    {
      memcpy(pinfo, &g_planeinfo, sizeof(struct fb_planeinfo_s));
      return OK;
    }

  _err("ERROR: Returning EINVAL\n");
  return -EINVAL;
}
Exemple #26
0
static int up_getvideoinfo(FAR struct fb_vtable_s *vtable,
                           FAR struct fb_videoinfo_s *vinfo)
{
  _info("vtable=%p vinfo=%p\n", vtable, vinfo);
  if (vtable && vinfo)
    {
      memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
      return OK;
    }

  _err("ERROR: Returning EINVAL\n");
  return -EINVAL;
}
Exemple #27
0
Connection* ConnectionServer::GetConnection(int fd)
{	
	pthread_mutex_lock(&_map_mutex);
	std::map<int, Connection*>::iterator it = m_fd_set.find(fd);
	if (it != m_fd_set.end()) 
	{
		it->second->acquire();
		pthread_mutex_unlock(&_map_mutex);
		return it->second;
	}
	pthread_mutex_unlock(&_map_mutex);
	_info("ConnectionServer::GetConnection <btlswkxt> do not get connection !!\n");
	return NULL;
}
Exemple #28
0
wrap_thread::~wrap_thread()  {
	m_time_stopped = t_sysclock::now();
	_info("wrap_thread destructor." + info());

	if(!m_future.valid()) {
		_info("wrap_thread destructor - nothing to do (it was joined already?)"); // XXX more comments
		return;
	}

	if (m_destroy_timeout != std::chrono::seconds(0)) {
		_info("wrap_thread destructor - will try to join it automatically, for time: " << m_destroy_timeout.count());
		std::future_status status = m_future.wait_for(m_destroy_timeout);
		if (status != std::future_status::ready) {
			_erro("can not end thread in given time. Will abort now.");
			std::abort();
		}
		_info("thread was correctly joined it seems");
		m_future.get(); // why? XXX
	} else {
		_erro("This thread was not joined, and you set to not wait for joining. Will abort.");
		std::abort();
	}
}
Exemple #29
0
static int up_getcursor(FAR struct fb_vtable_s *vtable,
                        FAR struct fb_cursorattrib_s *attrib)
{
  _info("vtable=%p attrib=%p\n", vtable, attrib);
  if (vtable && attrib)
    {
#ifdef CONFIG_FB_HWCURSORIMAGE
      attrib->fmt      = FB_FMT;
#endif
      _info("pos:      (x=%d, y=%d)\n", g_cpos.x, g_cpos.y);
      attrib->pos      = g_cpos;
#ifdef CONFIG_FB_HWCURSORSIZE
      attrib->mxsize.h = CONFIG_SIM_FBHEIGHT;
      attrib->mxsize.w = CONFIG_SIM_FBWIDTH;
      _info("size:     (h=%d, w=%d)\n", g_csize.h, g_csize.w);
      attrib->size     = g_csize;
#endif
      return OK;
    }

  _err("ERROR: Returning EINVAL\n");
  return -EINVAL;
}
Exemple #30
0
static void onReadable(SocketRec *rec) {
	char buff[256];

	int len = read(rec->socket, buff, sizeof(buff));

	if (len == 0) {
		_info("Server has disconnected.\n");
		//Orderly disconnect
		pumpStop(rec->pump);

		return;
	}
	printf("%.*s", len, buff);
}