Exemple #1
0
void dump_packet(struct rpc_packet *r)
{
    logd("packet header:");
    dump_buffer(&r->header, (int)sizeof(struct rpc_header));
    logd("packet data:");
    dump_buffer(r->data, r->header.len);
}
Exemple #2
0
  void iaap_video_decode (byte * buf, int len) {

    byte * q_buf = write_tail_buffer_get (len);                         // Get queue buffer tail to write to     !!! Need to lock until buffer written to !!!!
    if (ena_log_verbo)
      logd ("q_buf: %p  buf: %p  len: %d", q_buf, buf, len);
    if (q_buf == NULL) {
      loge ("Error no q_buf: %p  buf: %p  len: %d", q_buf, buf, len);
      //return;                                                         // Continue in order to write to record file
    }
    else
      memcpy (q_buf, buf, len);                                         // Copy video to queue buffer

    if (record_enable == 0)
      return;

#ifndef NDEBUG
    char * rec_file = "/home/m/dev/hu/aa.h264";
  #ifdef __ANDROID_API__
    rec_file = "/sdcard/aa.h264";
  #endif

    if (record_fd < 0)
      record_fd = open (rec_file, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
    int written = -77;
    if (record_fd >= 0)
      written = write (record_fd, buf, len);
    logd ("Video written: %d", written);
#endif
  }
Exemple #3
0
void _error(const char * file, int line, const char * str, ...){
  loge("** ERROR at %s:%i **\n",file,line);
  loge("%s", str);
  logd("\n");
  logd("** **\n");
  raise(SIGINT);
}
Exemple #4
0
    // Open interface
  static int ven_init (const bt_vendor_callbacks_t * p_cb, unsigned char * local_bdaddr) {

    logd ("ven_init p_cb: %p  local_bdaddr: %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x", p_cb, local_bdaddr [0], local_bdaddr [1], local_bdaddr [2], local_bdaddr [3], local_bdaddr [4], local_bdaddr [5] );

    logd ("main start: %s %s", binary_description, manifest_version);   // manifest_version automatically set during build
    logd (copyright);                                                   // Copyright

    utils_init ();

    if (p_cb == NULL) {
      loge ("ven_init no user callbacks");
      return (BT_HC_STATUS_FAIL);
    }
    bt_ven_cbacks = (bt_vendor_callbacks_t *) p_cb;                     // Store reference to user callbacks

    if (shim_start () == NULL) {
      loge ("ven_init shim_start error");
      return (BT_HC_STATUS_FAIL);
    }

    int ret = -88;
    if (veno_init)
      ret = veno_init (p_cb, local_bdaddr);
    logd ("ven_init ret: %d", ret);
    if (ret == 0)
      ret = server_thread_start ();

    return (ret);
  }
void ICACHE_FLASH_ATTR tfp_poll(void) {
	if(ringbuffer_is_empty(&tfp_rb)) {
		return;
	}

	uint8_t data[TFP_RECV_BUFFER_SIZE];
	uint8_t length = ringbuffer_peak(&tfp_rb, data, TFP_RECV_BUFFER_SIZE);

	if(length > TFP_RECV_BUFFER_SIZE) {
		ringbuffer_init(&tfp_rb, tfp_rb.buffer, tfp_rb.buffer_length);
		logd("tfp_poll: length > %d: %d\n", TFP_RECV_BUFFER_SIZE, length);
		return;
	}

	if(length < TFP_MIN_LENGTH) {
		ringbuffer_init(&tfp_rb, tfp_rb.buffer, tfp_rb.buffer_length);
		logd("tfp_poll: length < TFP_MIN_LENGTH\n");
		return;
	}

	if(uart_con_send(data, data[TFP_RECV_INDEX_LENGTH]) != 0) {
		ringbuffer_remove(&tfp_rb, data[TFP_RECV_INDEX_LENGTH]);
	} else {
		logd("tfp_poll send error\n");
	}
}
void ICACHE_FLASH_ATTR com_poll(void) {
	if(ringbuffer_is_empty(&com_out_rb)) {
		return;
	}

	// cid is in data[0], TFP packet has off by one, use +1 for access
	uint8_t data[TFP_RECV_BUFFER_SIZE + 1];
	uint8_t length = ringbuffer_peak(&com_out_rb, data, TFP_RECV_BUFFER_SIZE + 1);

	if(length > TFP_RECV_BUFFER_SIZE + 1) {
		ringbuffer_init(&com_out_rb, com_out_rb.buffer, com_out_rb.buffer_length);
		logd("com_poll: length > %d: %d\n", TFP_RECV_BUFFER_SIZE, length);
		return;
	}

	if(length < TFP_MIN_LENGTH + 1) {
		ringbuffer_init(&com_out_rb, com_out_rb.buffer, com_out_rb.buffer_length);
		logd("com_poll: length < TFP_MIN_LENGTH\n");
		return;
	}

	if(tfp_send_w_cid(data + 1, data[TFP_RECV_INDEX_LENGTH + 1], data[0]) != 0) {
		ringbuffer_remove(&com_out_rb, data[TFP_RECV_INDEX_LENGTH + 1] + 1);
	} else {
		//logd("com_poll send error\n");
	}
}
Exemple #7
0
int
sanity_check(const char *packet, unsigned len)
{
	struct ether_header *eh;
	struct ip *ip;
	struct udphdr *udp;

	eh = (struct ether_header *)packet;
	ip = (struct ip *)(packet + ETHER_HDR_LEN);
	udp = (struct udphdr *)(packet + ETHER_HDR_LEN + sizeof(struct ip));

	if (len < ETHER_HDR_LEN + DHCP_FIXED_LEN) {
		logd(LOG_ERR, "length too little -- packet discarded");
		return 0;
	}
	if (ntohs(eh->ether_type) != ETHERTYPE_IP) {
		logd(LOG_ERR, "wrong ether type -- packet discarded");
		return 0;
	}
	if (udp->uh_ulen < DHCP_FIXED_NON_UDP + DHCP_COOKIE_LEN + 1) {
		logd(LOG_ERR, "not enough DHCP data -- packet ignore");
		return 0;
	}
	return 1;
}
/*****************************************************************************
 函 数 名  : hifi_misc_async_write
 功能描述  : Hifi MISC 设备异步发送接口,将异步消息发给Hifi,非阻塞接口
 输入参数  :
             unsigned char *arg  :需要下发的数据buff指针
             unsigned int len    :下发的数据长度
 输出参数  : 无
 返 回 值  : int
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2012年8月1日
    作    者   : 夏青 00195127
    修改内容   : 新生成函数

*****************************************************************************/
int hifi_misc_async_write(unsigned char *arg, unsigned int len)
{
    int ret =0;

    IN_FUNCTION;

    if ( arg==NULL )
    {
        loge("input arg is NULL\n");
        return ERROR;
    }

    logd("len=%d, arg=0x%p\n", len, arg);

    /*调用核间通信接口发送数据*/
    ret = DRV_MAILBOX_SENDMAIL(MAILBOX_MAILCODE_ACPU_TO_HIFI_MISC, arg, len);

    if ( OK != ret )
    {
        loge("msg send to hifi fail,ret is %d\n", ret);
        return ERROR;
    }
    logd("SendMail ret=%d\n", ret);

    OUT_FUNCTION;

    return OK;
}
Exemple #9
0
static void *
uio_int_handler(void *arg)
{
	int ret;
	void *(*ufunc)(void *);
	void *uarg;
	tsem_t *uio_sem;
	int *exit_flag;
	if (arg) {
		void **args = arg;
		ufunc = args[0];
		uarg = args[1];
		uio_sem = args[2];
		exit_flag = args[3];
	} else {
		ufunc = uarg = NULL;
		return NULL;
	}

	logd("%s start\n", __FUNCTION__);

	while (uiomux && !*exit_flag) {
		logd("wait for an interrupt...\n");
		ret = uiomux_sleep(uiomux, VPU_UIO);
		if (ret < 0) {
			break;
		}
		logd("got an interrupt! (%d)\n", ret);
		if (ufunc)
			ufunc(uarg);
	}
	free (arg);
	return NULL;
}
int mods_spi_reg_main(int argc, char *argv[])
#endif
{
  if (dev1 == NULL)
    {
      dev1 = up_spiinitialize(CONFIG_MODS_SPI_REG_BUS);
      mods_self.dev = dev1;
      logd("Slave init complete!\n");
#ifdef CONFIG_SPI_SLAVE
      SPI_SLAVE_REGISTERCALLBACK(dev1, &cb_ops, &mods_self);
      logd("Slave setup complete!\n");
#endif
    }

  dump_regs();

#ifdef CONFIG_STM32_SPI_DMA
  if (txn_status == -1)
    {
      SPI_EXCHANGE(dev1,mods_self.regs, mods_self.regs, sizeof(mods_self.regs) + 2);
      logd("Slave DMA armed!\n");
    }
#endif
  return 0;
}
Exemple #11
0
void hifi_write_file_from_memory_regions(char *filename, u32 addr, unsigned int size)
{
	mm_segment_t fs;
	struct file *fp = NULL;
	int file_flag = O_WRONLY | O_CREAT;
	int write_size = 0;
	/* must have the following 2 statement */
	fs = get_fs();
	set_fs(KERNEL_DS);

	fp = filp_open(filename, file_flag, 0777);
	if (IS_ERR(fp)) {
		loge("open file error!\n");
		return;
	}
	logd("size	parameter = %d!\n", size);
	if((write_size = vfs_write(fp, (char *)addr, size, &fp->f_pos)) < 0) {
		loge("read file error!\n");
	}

	logd("write file size = %d \n", write_size);

	/* must have the following 1 statement */
	set_fs(fs);
	filp_close(fp, 0);
}
Exemple #12
0
/*****************************************************************************
 * public implementations
 ****************************************************************************/
struct sender6 * sender6_create(const char *device) /* {{{ */
{
	char errbuf[LIBNET_ERRBUF_SIZE];
	char *dev;
	struct sender6 *sender;

	dev = strdup(device);
	if(!dev) logea(__FILE__, __LINE__, NULL);
	sender = malloc(sizeof(struct sender6));
	if(!sender) logea(__FILE__, __LINE__, NULL);

	sender->ln = libnet_init(LIBNET_RAW6, dev, errbuf);
	if(!sender->ln) goto out_libnet;
	free(dev);
	sender->ip = libnet_get_ipaddr6(sender->ln);
	sender->icmptag = 0;
	sender->iptag = 0;
	sender->tmptag = 0;

	logd(LOG_INFO, "%s dev=%s ok\n", __func__, device);

	return sender;

	out_libnet:
	loge(LOG_FATAL, __FILE__, __LINE__);
	logd(LOG_FATAL, "%s: %s", __func__, errbuf);
	free(sender);
	free(dev);
	return NULL;
} /* }}} */
Exemple #13
0
/* Parse a servers part of config */
void
parse_servers_line(char *buf)
{
	char *p, *n;
	int inum;

	p = buf;
	strsep(&p, " \t");
	if (!open_server(buf)) {
		logd(LOG_WARNING, "Can't open server %s. Ignored.", buf);
		return;
	}
	inum = 0;
	while ((n = strsep(&p, " \t")) != NULL) {
		if (*n != '\0') {
			if (open_interface(n))
				inum++;
			else {
				logd(LOG_WARNING, "Interface %s does not exist. Ignored.", n);
			}
		}
	}
	/* We found no interfaces for listening on this computer */
	if (inum == 0) {
		srv_num--;
		free(servers[srv_num]);
	}
}
Exemple #14
0
  static void * bt_server_thread (void * arg) {
    uint16_t events;
    logd ("bt_server_thread start");

    //bc_g2_pcm_set ();

    int poll_tmo_ms = 0;                                                // No polling
    int hci_port = NET_PORT_HCI;

    while (thread_state == 1) {                                         // While needed and running...
      logd ("bt_server_thread thread_state = needed and running");
      gen_server_loop (hci_port, poll_tmo_ms);                          // !! Doesn't return if no packets sent

      if (thread_state == 1)
        sleep (1);                                                      // Keep trying if error return
    }
    logd ("bt_server_thread gen_server_exiting");

    thread_state = 0;
    logd ("bt_server_thread exit");

    pthread_exit (NULL);
    loge ("bt_server_thread exit 2");

    return (NULL);                                                      // Compiler friendly ; never reach
  }
Exemple #15
0
void enumerate(const ComType com, const Enumerate *data) {
	logd("Returning Enumeration for Brick: %d\n\r", com);

	// Enumerate Brick
	EnumerateCallback ec = MESSAGE_EMPTY_INITIALIZER;
	make_brick_enumerate(&ec);

	ec.enumeration_type = ENUMERATE_TYPE_AVAILABLE;

	send_blocking_with_timeout(&ec, sizeof(EnumerateCallback), com);

	// Enumerate Bricklet
	for(uint8_t i = 0; i < BRICKLET_NUM; i++) {
		if(bs[i].uid == 0 || bricklet_attached[i] == BRICKLET_INIT_CO_MCU) {
			continue;
		}

		logd("Returning Enumeration for Bricklet %c\n\r", 'a' + i);

		EnumerateCallback ec = MESSAGE_EMPTY_INITIALIZER;
		make_bricklet_enumerate(&ec, i);

		ec.enumeration_type = ENUMERATE_TYPE_AVAILABLE;

		send_blocking_with_timeout(&ec, sizeof(EnumerateCallback), com);
	}

	com_info.current = com;
}
Exemple #16
0
  bt_vendor_interface_t * shim_start () {
    logd ("shim_start veno_handle: %p", veno_handle);

    if (veno_handle != NULL && veno_if != NULL)
      return (veno_if);

    shim_stop ();

    veno_handle = dlopen (veno_lib, RTLD_LAZY);
    if (veno_handle != NULL)
      veno_if = dlsym (veno_handle, "BLUETOOTH_VENDOR_LIB_INTERFACE");
    if (veno_if != NULL)
      veno_init = veno_if->init;
    if (veno_init != NULL)
      veno_op = veno_if->op;
    if (veno_op != NULL)
      veno_cleanup = veno_if->cleanup;

    if (veno_handle == NULL || veno_if == NULL || veno_init == NULL || veno_op == NULL || veno_cleanup == NULL) {
      shim_stop ();
      loge ("shim_start done veno_if: %p", veno_if);
    }
    else
      logd ("shim_start done veno_if: %p", veno_if);

    return (veno_if);
  }
static void dock_switch_work_func(struct work_struct *work) 
{
	int state = 0, value;
	struct dock_switch_device *dock_switch  = container_of(work, 
			struct dock_switch_device, work);
	
	logd("dock_switch_work_func\n");

	if (dock_switch->gpio_desktop) {
		value = gpio_get_value(dock_switch->gpio_desktop);
		logd("desktop_dock = %d", value);
		if (dock_switch->gpio_desktop_active_low) 
			value = !value;
		state |= (value & 0x1) << BIT_DESKTOP;
	}

	if (dock_switch->gpio_car) {
		value = gpio_get_value(dock_switch->gpio_car);
		if (dock_switch->gpio_car_active_low)
			value = !value;
		state |= (value & 0x1) << BIT_CAR;
	}

	logd("state = %d\n", state);

	if (dock_switch->state != state) {
		dock_switch->state = state;
		switch_set_state(&dock_switch->sdev, state ? 1 : 0);
	}
}
Exemple #18
0
/*
 * This method may be access by multiple thread, and it may be block.
 */
static int isl29023_set_enable(struct isl29023_dev *dev, int enable)
{
	if(dev->input_dev==NULL) return 0;
	down(&dev->sem);
	if (enable == dev->enable) {
		logd("isl29023_set_enable() not change.");
		up(&dev->sem);
		return 0;
	}

	if (enable) {
		/* open sensor and start schedule timer */
		logd("isl29023_set_enable() enbale\r\n");
		if (isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_I, ISL29023_ALS_CONTINUE)
			|| isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_II, ISL29023_MODE_RANGE)) {
			up(&dev->sem);
			logd("isl29023_set enable failed\r\n");
			return -EINVAL;
		}
		dev->enable = enable;
		dev->mode = ISL29023_MODE_RANGE;
		schedule_delayed_work(&dev->update_work, msecs_to_jiffies(dev->update_interval));
	} else {
		/* stop the schedule timer and try to close the device */
		logd("isl29023_enable() disable\r\n");
		dev->enable = enable;
		cancel_delayed_work_sync(&dev->update_work);
		isl29023_i2c_write_byte(dev, ISL29023_REG_COMMAND_I, ISL29023_POWER_DOWN);
	}
	up(&dev->sem);
	return 0;
}
Exemple #19
0
  int iusb_deinit () {                                              // !!!! Need to better reset and wait a while to kill transfers in progress and auto-restart properly

    //if (ctrl_transfer != NULL)
    //  libusb_free_transfer (ctrl_transfer);                           // Free all transfers individually

    if (iusb_dev_hndl == NULL) {
      loge ("Done iusb_dev_hndl: %p", iusb_dev_hndl);
      return (-1);
    }

    int usb_err = libusb_release_interface (iusb_dev_hndl, 0);          // Can get a crash inside libusb_release_interface()
    if (usb_err != 0)
      loge ("Done libusb_release_interface usb_err: %d (%s)", usb_err, iusb_error_get (usb_err));
    else
      logd ("Done libusb_release_interface usb_err: %d (%s)", usb_err, iusb_error_get (usb_err));

    libusb_close (iusb_dev_hndl);
    logd ("Done libusb_close");
    iusb_dev_hndl = NULL;

    libusb_exit (NULL); // Put here or can get a crash from pulling cable

    logd ("Done");

    return (0);
  }
Exemple #20
0
  void HUServer::hu_thread_main()
  {
    pthread_setname_np(pthread_self(), "hu_thread_main");

    int transportFD = transport->GetReadFD();
    int errorfd = transport->GetErrorFD();
    while(!hu_thread_quit_flag)
    {
      fd_set sock_set;
      FD_ZERO(&sock_set);
      FD_SET(command_read_fd, &sock_set);
      FD_SET(transportFD, &sock_set);
      int maxfd = std::max(command_read_fd, transportFD);
      if (errorfd >= 0)
      {
        maxfd = std::max(maxfd, errorfd);
        FD_SET(errorfd, &sock_set);
      }

      int ret = select(maxfd+1, &sock_set, NULL, NULL, NULL);
      if (ret <= 0)
      {
        loge("Select failed %d", ret);
        return;
      }
      if (errorfd >= 0 && FD_ISSET(errorfd, &sock_set))
      {
        logd("Got errorfd");
        hu_thread_quit_flag = true;
        callbacks.DisconnectionOrError();
      }
      else
      {
        if (FD_ISSET(command_read_fd, &sock_set))
        {
          logd("Got command_read_fd");
          IHUAnyThreadInterface::HUThreadCommand* ptr = nullptr;
          if(ptr = hu_pop_command())
          {
            logd("Running %p", ptr);
            (*ptr)(*this);
            delete ptr;
          }
        }
        if (FD_ISSET(transportFD, &sock_set))
        {
          //data ready
          logd("Got transportFD");
          ret = hu_aap_recv_process(iaap_tra_recv_tmo);
          if (ret < 0)
          {
            loge("hu_aap_recv_process failed %d", ret);
            hu_aap_stop();
          }
        }
      }
    }
    logd("hu_thread_main exit");
  }
Exemple #21
0
void update_dirfile(const char * dir, const char * name, const char * user){
  dirscan scan = {0};
  ensure_directory("shares/");
  {
    char * dir_filename = fmtstr("shares/%s.dir", name);
    size_t size0;
    void * buf = read_file_to_buffer(dir_filename, &size0);
    if(buf != NULL){
      logd("Size: %i\n", size0);
      scan = dirscan_from_buffer(buf);
      dealloc(buf);
    }
    logd("SCAN: %i\n", scan.cnt);
    udpc_dirscan_update(dir, &scan, false);
    logd("SCAN2: %i\n", scan.cnt);
    size_t size = 0;
    buf = dirscan_to_buffer(scan,&size);
    
    write_buffer_to_file(buf, size, dir_filename);
    dealloc(buf);
  }
  
  {
    void * buffer = NULL;
    size_t cnt = 0;
    udpc_pack_string(dir, &buffer, &cnt);
    udpc_pack_string(name, &buffer, &cnt);
    udpc_pack_string(user, &buffer, &cnt);
    char * shareinfo_filename = fmtstr("shareinfo/%s", name);
    FILE * f = fopen(shareinfo_filename, "w");
    fwrite(buffer, 1, cnt, f);
    fclose(f);
    dealloc(shareinfo_filename);
  }
  
  char * bin_filename = fmtstr("shares/%s.bin", name);
  size_t s = 0;
  void * b = dirscan_to_buffer(scan, &s);
  FILE * f = fopen(bin_filename, "w");
  fwrite(b, 1, s, f);
  fclose(f);
  dealloc(bin_filename);
  
  char * filename = fmtstr("shares/%s.json", name);
  FILE * jsonfile = fopen(filename, "w");
  fprintf(jsonfile, "{\"dir\": \"%s\", \"files\": [\n", dir);
  for(size_t i = 0; i < scan.cnt; i++){
    fprintf(jsonfile, "{ \"path\": \"%s\", \"md5\":\"", scan.files[i]);
    udpc_fprintf_md5(jsonfile, scan.md5s[i]);
    if(i != scan.cnt -1){
      fprintf(jsonfile, "\"},\n");
    }else{
      fprintf(jsonfile, "\"}\n");
    }
  }
  fprintf(jsonfile, "]}\n");
  fclose(jsonfile);
  dealloc(filename);
}
Exemple #22
0
 int hu_usb_stop () {
   iusb_state = hu_STATE_STOPPIN;
   logd ("  SET: iusb_state: %d (%s)", iusb_state, state_get (iusb_state));
   int ret = iusb_deinit ();
   iusb_state = hu_STATE_STOPPED;
   logd ("  SET: iusb_state: %d (%s)", iusb_state, state_get (iusb_state));
   return (ret);
 }
Exemple #23
0
  int hu_aap_start (byte ep_in_addr, byte ep_out_addr) {                // Starts USB/ACC/OAP, then AA protocol w/ VersReq(1), SSL handshake, Auth Complete

    if (iaap_state == hu_STATE_STARTED) {
      loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (0);
    }

    iaap_state = hu_STATE_STARTIN;
    logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));

    int ret = hu_usb_start (ep_in_addr, ep_out_addr);                   // Start USB/ACC/OAP
    if (ret) {
      iaap_state = hu_STATE_STOPPED;
      logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (ret);                                                     // Done if error
    }

    byte vr_buf [] = {0, 3, 0, 6, 0, 1, 0, 1, 0, 1};                    // Version Request
    ret = hu_aap_usb_set (0, 3, 1, vr_buf, sizeof (vr_buf));
    ret = hu_aap_usb_send (vr_buf, sizeof (vr_buf), 1000);              // Send Version Request
    if (ret < 0) {
      loge ("Version request send ret: %d", ret);
      hu_aap_stop ();
      return (-1);
    }  

    byte buf [DEFBUF] = {0};
    errno = 0;
    ret = hu_aap_usb_recv (buf, sizeof (buf), 1000);                    // Get Rx packet from USB:    Wait for Version Response
    if (ret <= 0) {
      loge ("Version response recv ret: %d", ret);
      hu_aap_stop ();
      return (-1);
    }  
    logd ("Version response recv ret: %d", ret);

//*
    ret = hu_ssl_handshake ();                                          // Do SSL Client Handshake with AA SSL server
    if (ret) {
      hu_aap_stop ();
      return (ret);
    }

    byte ac_buf [] = {0, 3, 0, 4, 0, 4, 8, 0};                          // Status = OK
    ret = hu_aap_usb_set (0, 3, 4, ac_buf, sizeof (ac_buf));
    ret = hu_aap_usb_send (ac_buf, sizeof (ac_buf), 1000);              // Auth Complete, must be sent in plaintext
    if (ret < 0) {
      loge ("hu_aap_usb_send() ret: %d", ret);
      hu_aap_stop ();
      return (-1);
    }  
    hu_ssl_inf_log ();

    iaap_state = hu_STATE_STARTED;
    logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
//*/
    return (0);
  }
static void dump_regs(void)
{
    int i;

    logd("address    %d\n",  mods_self.addr);
    for (i = 0; i < MODS_NUM_REGS; i++)
    {
        logd("%d 0x%02x\n", i, mods_self.regs[i]);
    }
}
Exemple #25
0
 void shim_stop () {
   logd ("shim_stop veno_handle: %p", veno_handle);
   if (veno_handle != NULL)
     dlclose (veno_handle);
   veno_handle = NULL;
   veno_if = NULL;
   veno_init = NULL;
   veno_op = NULL;
   veno_cleanup = NULL;
   logd ("shim_stop done");
 }
Exemple #26
0
  int HUServer::hu_aap_start (HU_TRANSPORT_TYPE transportType, bool waitForDevice) {                // Starts Transport/USBACC/OAP, then AA protocol w/ VersReq(1), SSL handshake, Auth Complete

    if (iaap_state == hu_STATE_STARTED || iaap_state == hu_STATE_STARTIN) {
      loge ("CHECK: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (0);
    }

    pthread_setname_np(pthread_self(), "main_thread");

    iaap_state = hu_STATE_STARTIN;
    logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));

    int ret = ihu_tra_start (transportType, waitForDevice);                   // Start Transport/USBACC/OAP
    if (ret) {
      iaap_state = hu_STATE_STOPPED;
      logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));
      return (ret);                                                     // Done if error
    }

    byte vr_buf [] = { 0, 1, 0, 1};                    // Version Request
    ret = hu_aap_unenc_send_blob(0, AA_CH_CTR, HU_INIT_MESSAGE::VersionRequest, vr_buf, sizeof (vr_buf), 2000);
    if (ret < 0) {
      loge ("Version request send ret: %d", ret);
      return (-1);
    }

    while(iaap_state == hu_STATE_STARTIN)
    {
      ret = hu_aap_recv_process(2000);
      if (ret < 0) {
        hu_aap_shutdown();
        return (ret);
      }
    }


    int pipefd[2];
    ret = pipe2(pipefd, O_DIRECT);
    if (ret < 0)
    {
      loge ("pipe2 failed ret: %d %i", ret, errno);
      hu_aap_shutdown ();
      return (-1);
    }

    logw("Starting HU thread");
    command_read_fd = pipefd[0];
    command_write_fd = pipefd[1];
    hu_thread_quit_flag = false;
    hu_thread = std::thread([this] { this->hu_thread_main(); });


    return (0);
  }
Exemple #27
0
  int hu_aap_stop () {                                                  // Sends Byebye, then stops USB/ACC/OAP
    // Send Byebye
    iaap_state = hu_STATE_STOPPIN;
    logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));

    int ret = hu_usb_stop ();                                           // Stop USB/ACC/OAP
    iaap_state = hu_STATE_STOPPED;
    logd ("  SET: iaap_state: %d (%s)", iaap_state, state_get (iaap_state));

    return (ret);
  }
Exemple #28
0
static ssize_t
isl29023_write_sysfs_debug(struct device *device, struct device_attribute *attr, const char *buffer, size_t count)
{
	struct isl29023_dev *dev = &s_isl29023_dev;

	logd("isl29023_write_sysfs_debug\r\n");
	input_report_abs(dev->input_dev, ABS_MISC, dev->mlux);
	input_sync(dev->input_dev);
	logd("trace1\r\n");

	return count;
}
static int __init h2w_switch_init()
{
	int ret;
	
	logd("h2w_switch_init() IN\r\n");
	
	ret = platform_driver_register(&h2w_switch_driver);
	
	logd("h2w_switch_init() OUT\r\n");

	return ret;
}
Exemple #30
0
  int jni_aa_cmd (int cmd_len, char * cmd_buf, int res_max, char * res_buf) {
    if (ena_log_extra || cmd_len >= 1)
      logd ("cmd_len: %d  cmd_buf %p  res_max: %d  res_buf: %p", cmd_len, cmd_buf, res_max, res_buf);
    int res_len = 0;
    int ret = 0;

    if (cmd_buf != NULL && cmd_len == 3 && cmd_buf [0] == 121) {        // If onCreate() hu_tra:transport_start()
      byte ep_in_addr  = cmd_buf [1];
      byte ep_out_addr = cmd_buf [2];
      ret = hu_aap_start (ep_in_addr, ep_out_addr);                    // Start USB/ACC/OAP, AA Protocol
      aap_state_starts ++;  // Count error starts too
      if (ret == 0) {
        logd ("hu_aap_start() success aap_state_starts: %d", aap_state_starts);
      }
      else {
        loge ("hu_aap_start() error aap_state_starts: %d", aap_state_starts);
        aap_state_start_error = 1;
        return (-1);
      }
    }

    if (cmd_buf != NULL && cmd_len >= 4) {                              // If encrypted command to send...
      int chan = cmd_buf [0];
      ret = hu_aap_enc_send (chan, & cmd_buf [4], cmd_len - 4);        // Send

      if (cmd_buf != NULL && cmd_len  >= 8 && cmd_buf [5] == 15) {  // If byebye...
        loge ("Byebye");
        ms_sleep (100);
        ret = hu_aap_stop ();
      }

    }
    else {
      ret = hu_aap_recv_process ();                                    // Process 1 message
    }
    if (ret < 0) {
      return (ret);
    }

    byte * dq_buf = read_head_buffer_get (& res_len);
    if (ena_log_extra || (ena_log_verbo && dq_buf != NULL))
      logd ("dq_buf: %p", dq_buf);
    if (dq_buf == NULL || res_len <= 0) {
      if (ena_log_extra)
        logd ("No data dq_buf: %p  res_len: %d", dq_buf, res_len);
      return (0);
    }
    memcpy (res_buf, dq_buf, res_len);

    if (ena_log_verbo)
      logd ("res_len: %d", res_len);
    return (res_len);
  }