示例#1
0
文件: usb_io.c 项目: q-bits/Antares
/* Optimised packet handling to reduce overhead during bulk file transfers. */
int send_cancel(libusb_device_handle* fd)
{
	trace(3, printf("send_cancel\n"));
    return usb_bulk_write(fd, 0x01, cancel_packet, 8, default_timeout());


}
示例#2
0
void init(int argc, char* argv[]) {
    // set global data
    default_config();
    default_timeout();
    default_systray();
    memset(&server, 0, sizeof(Server_global));
#ifdef ENABLE_BATTERY
    default_battery();
#endif
    default_clock();
    default_launcher();
    default_taskbar();
    default_tooltip();
    default_panel();

    // read options
    for (int i = 1; i < argc; ++i) {
        if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
            DIE("Usage: tinto [-c] <config_file>\n");
        } else if (strcmp(argv[i], "-v") == 0 ||
                   strcmp(argv[i], "--version") == 0) {
            DIE("tinto version %s\n", VERSION_STRING);
        } else if (strcmp(argv[i], "-c") == 0) {
            if (++i < argc) config_path = strdup(argv[i]);
        } else if (strcmp(argv[i], "-s") == 0) {
            if (++i < argc) snapshot_path = strdup(argv[i]);
        }
    }

    // Set signal handler
    signal_pending = 0;
    struct sigaction sa = {.sa_handler = signal_handler};
    struct sigaction sa_chld = {.sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT};
    sigaction(SIGUSR1, &sa, NULL);
    sigaction(SIGINT, &sa, NULL);
    sigaction(SIGTERM, &sa, NULL);
    sigaction(SIGHUP, &sa, NULL);
    sigaction(SIGCHLD, &sa_chld, NULL);

    // BSD does not support pselect(), therefore we have to use select and hope
    // that we do not
    // end up in a race condition there (see 'man select()' on a linux machine for
    // more information)
    // block all signals, such that no race conditions occur before pselect in our
    // main loop
    //	sigset_t block_mask;
    //	sigaddset(&block_mask, SIGINT);
    //	sigaddset(&block_mask, SIGTERM);
    //	sigaddset(&block_mask, SIGHUP);
    //	sigaddset(&block_mask, SIGUSR1);
    //	sigprocmask(SIG_BLOCK, &block_mask, 0);
}
示例#3
0
文件: usb_io.c 项目: q-bits/Antares
/* Given a Topfield protocol packet, this function will calculate the required
 * CRC and send the packet out over a bulk pipe. */
int send_tf_packet(libusb_device_handle* fd, struct tf_packet *packet)
{


    unsigned int pl = get_u16(&packet->length);


    size_t byte_count = (pl + 1) & ~1;

    put_u16(&packet->crc, get_crc(packet));
    if (verbose>2) print_packet(packet, "OUT>");
    swap_out_packet(packet);
	if (fd==0)  return -1;

    return usb_bulk_write(fd, 0x01, (__u8 *) packet, byte_count,
                          default_timeout());
	
}
示例#4
0
void
tinto_init (int argc, char *argv[]) {
  default_config ();
  default_timeout ();
  default_systray();
  memset (&server, 0, sizeof (Server_global));
#ifdef ENABLE_BATTERY
  default_battery ();
#endif // ENABLE_BATTERY
  default_clock ();
  default_launcher ();
  default_taskbar ();
  default_tooltip ();
  panel_default ();

  for (int i = 1; i < argc; ++i) {
    if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "--help") == 0) {
      tinto_usage ();
    }

    else if (strcmp (argv[i], "-v") == 0 ||
	     strcmp (argv[i], "--version") == 0) {
      MSG ("%s version %s\n", PROJECT_NAME, PROJECT_VERSION);
      exit (EXIT_SUCCESS);
    }
    else if (strcmp (argv[i], "-c") == 0
	     || strcmp (argv[i], "--config-file") == 0) {
      if (++i < argc) config_path = strdup (argv[i]);
    }
    else if (strcmp (argv[i], "-s") == 0
	     || strcmp (argv[i], "--panel-snapshot") == 0) {
      if (++i < argc) snapshot_path = strdup (argv[i]);
    }
    else {
      MSG ("Invalid argument!");
      tinto_usage ();
    }
  }

  // Isn't this initialization redundant? Since `pending_signal'
  // is static and all?
  pending_signal = 0;
  struct sigaction sa = { .sa_handler = tinto_signal_handler };
  struct sigaction sa_chld = {
    .sa_handler = SIG_DFL,
    .sa_flags = SA_NOCLDWAIT
  };
  sigaction(SIGUSR1, &sa, NULL);
  sigaction(SIGINT, &sa, NULL);
  sigaction(SIGTERM, &sa, NULL);
  sigaction(SIGHUP, &sa, NULL);
  sigaction(SIGCHLD, &sa_chld, NULL);

  // BSD does not support pselect(), therefore we have to use select and hope that we do not
  // end up in a race condition there (see 'man select()' on a linux machine for more information)
  // block all signals, such that no race conditions occur before pselect in our main loop
  //	sigset_t block_mask;
  //	sigaddset(&block_mask, SIGINT);
  //	sigaddset(&block_mask, SIGTERM);
  //	sigaddset(&block_mask, SIGHUP);
  //	sigaddset(&block_mask, SIGUSR1);
  //	sigprocmask(SIG_BLOCK, &block_mask, 0);

  tinto_init_x11 ();
}
示例#5
0
文件: usb_io.c 项目: q-bits/Antares
/* Like get_tf_packet2, but using default timeout */
int get_tf_packet1(libusb_device_handle* fd, struct tf_packet * packet, int noreply)
{

	return get_tf_packet2(fd, packet,default_timeout(), noreply);

}
示例#6
0
文件: usb_io.c 项目: q-bits/Antares
int send_success(libusb_device_handle* fd)
{
	trace(3, printf("send_success\n"));
    return usb_bulk_write(fd, 0x01, success_packet, 8, default_timeout());
}
示例#7
0
文件: trace.hpp 项目: QuLogic/jot-lib
    static TRACEptr get_active_instance() {
        return isa(_active) ? (TRACE*)&*_active : nullptr;
    }

    //******** RUN-TIME TYPE ID ********
    DEFINE_RTTI_METHODS2("TRACE", DrawWidget, CDATA_ITEM*);

    //******** SETTING UP ********

    //! Returns true if the gesture is valid for beginning a
    //! trace session:
    static bool init(CGESTUREptr& g);

    //! After a successful call to init(), this turns on a TRACE
    //! to handle the trace session:
    static bool go(double dur = default_timeout());

    //******** DRAW FSA METHODS ********
    virtual int  stroke_cb(CGESTUREptr& gest, DrawState*&);
    virtual int  tap_cb(CGESTUREptr& gest, DrawState*&);
    virtual int  cancel_cb(CGESTUREptr& gest, DrawState*&);

    //******** GEL METHODS ********
    virtual int draw(CVIEWptr& v);
    virtual bool needs_blend() const {
        return true;
    }

    //******** TRACE specific methods ***********

    //! Force the trace widget to go into calibration mode