Esempio n. 1
0
static usb_speed
usb_hub_port_speed(usbdev_t *const dev, const int port)
{
	unsigned short buf[2];
	int ret = get_status (dev, port, DR_PORT, sizeof(buf), buf);
	if (ret >= 0 && (buf[0] & PORT_ENABLE)) {
		/* bit  10  9
		 *      0   0  full speed
		 *      0   1  low speed
		 *      1   0  high speed
		 *      1   1  super speed (hack, not in spec!)
		 */
		ret = (buf[0] >> 9) & 0x3;
	} else {
Esempio n. 2
0
static gboolean bt_connected_to_playing(const gchar *type,
        const gchar *path,
        enum bt_state prev_state,
        enum bt_state new_state)
{
    (void) prev_state;
    (void) new_state;

    if (strcmp(type, BT_TYPE_HSP) == 0) {
        dres_arg_t arg;
        char value[5];

#if 0
        snprintf(value, 20, "hsp=%s,hfp=%s",
                get_status(bt_get_connected(path), "hsp") ? "yes" : "no",
                get_status(bt_get_connected(path), "hfp") ? "yes" : "no");
#endif

        /* TODO: The policy decision is now done here. Refactor to the
         * rule files. The rule is that if "hsp" profile is available,
         * use it, otherwise use "hfp".
         * */

        snprintf(value, sizeof(value), "%s",
                get_status(bt_get_connected(path), "hsp") ? "-hsp" : "-hfp");

        arg.sig = 's';
        arg.key = "hwid";
        arg.value.s_value = (char *) value;
        
        OHM_DEBUG(DBG_BT, "%s goes from connected to playing!", type);
        return run_policy_hook("bthsp_start_audio", 1, &arg);
    }

    /* no need to run dres afterwards */
    return FALSE;
}
Esempio n. 3
0
File: decor.c Progetto: damaru/zwm
void zwm_decor_init(void)
{
	int i;
	XGlyphInfo info;

	cmap = DefaultColormap(dpy, scr);
	gc = XCreateGC(dpy, root, 0, NULL);

	memset(icons,0,64);

	xfont = XftFontOpenName (dpy, scr, "DejaVu Sans-9:bold");
	if(!xfont)xfont = XftFontOpenXlfd(dpy, scr, config.font);

	ifont = XftFontOpenName (dpy, scr, "DejaVu Sans-16:bold");
	if(!ifont)ifont = XftFontOpenXlfd(dpy, scr, config.icons);

	XftColorAllocValue(dpy, DefaultVisual(dpy, scr), cmap, &xcolor.color, &xcolor);

	config.xcolor_nborder = alloc_color(config.normal_border_color);
	config.xcolor_fborder = alloc_color(config.focus_border_color);
	config.xcolor_nbg = alloc_color(config.normal_bg_color);
	config.xcolor_fbg = alloc_color(config.focus_bg_color);
	config.xcolor_flbg = alloc_color(config.float_bg_color);
	config.xcolor_nshadow = alloc_color(config.normal_shadow_color);
	config.xcolor_fshadow = alloc_color(config.focus_shadow_color);
	config.xcolor_ntitle = alloc_color(config.normal_title_color);
	config.xcolor_ftitle = alloc_color(config.focus_title_color);
	config.xcolor_root = alloc_color(config.root_bg_color);

	get_status(icons, 64);
	XftTextExtentsUtf8(dpy, xfont, (FcChar8*)" [000] ", 7, &info);
	char_width = info.width;
	XftTextExtentsUtf8(dpy, xfont, (FcChar8*)icons, strlen(icons), &info);
	date_width = info.width;
	icons[0] = 0;

	for(i=0; i<32 && config.buttons[i].func; i++){
		strcat(icons, config.buttons[i].c);
		config.button_count = i+1;
	}

	if(config.button_count){
		XftTextExtentsUtf8(dpy, ifont, (FcChar8*)icons, strlen(icons), &info);
		config.button_width = info.width / config.button_count;
		config.icon_y = info.height + (config.title_height - info.height)/2 + 1;
	}

	config.title_y = config.title_height - xfont->descent - 2;
}
Esempio n. 4
0
int
Connected_OPEN(client_t *client, textbuf *buf, CTP_head_t head)
{
    CTP_OPEN_t mesg;
    int rv = recv_mesg(client->sockfd, &mesg, head);
    if (rv < 1)
        return rv;

    /* check for correct client id */
    if (mesg.client_id != client->id) {
        free_mesg(mesg);
        return -1;
    }

    /* check file id
     * this server only supports a "default" file */
    if (mesg.file_id != 0) {
        free_mesg(mesg);
        send_err(client, BAD_FILE_ID);
        return 1;
    }

    free_mesg(mesg);

    /* transient... */
    client->state = Opening;

    /* build ACKOPEN response */
    CTP_ACKOPEN_t response;
    response.options = new_options();

    /* send response */
    rv = send_ACKOPEN(client->sockfd, response);
    free_options(response.options);
    client->state = Open;
    if (rv < 1)
        return rv;

    /* send STATUS message to all clients */
    CTP_STATUS_t status = get_status(buf);
    client_t *c;
    for (c = clients; c <= max_active_client; ++c) {
        if (c->active)
            send_STATUS(c->sockfd, status);
    }
    free_options(status.options);

    return 1;
}
char * hustdb_ha_get_status()
{
    if (!g_libsync)
    {
        return NULL;
    }
    typedef char * (*libsync_get_status_t)(int hosts_size);
    libsync_get_status_t get_status = dlsym(g_libsync, "get_status");
    char * error = dlerror();
    if(!error)
    {
        return get_status(ngx_http_get_backend_count());
    }
    return NULL;
}
Esempio n. 6
0
int
do_rmdir(struct sftp_conn *conn, char *path)
{
	u_int status, id;

	id = conn->msg_id++;
	send_string_request(conn->fd_out, id, SSH2_FXP_RMDIR, path,
	    strlen(path));

	status = get_status(conn->fd_in, id);
	if (status != SSH2_FX_OK)
		error("Couldn't remove directory: %s", fx2txt(status));

	return(status);
}
Esempio n. 7
0
void
tsession_reaper::reap()
{
	LOG_T(__PRETTY_FUNCTION__, ".\n");

	auto itor = sessions_.begin();
	while(itor != sessions_.end()) {
		if(itor->get_status() == tsession::tstatus::reapable) {
			LOG_D("Session reaper: reaping.\n");
			itor = sessions_.erase(itor);
		} else {
			++itor;
		}
	}
}
Esempio n. 8
0
//Get the program to exec from the command line
int main(int argc, char* argv[]){

int status;
char ini[3]="./", vector[50]="",rubish[20]="";

strcpy(rubish,argv[1]);
strcpy(vector,ini);
strcat(vector,rubish);

//Check for CTRL + C
signal(SIGINT, sigintHandler);

//Access the device
access_button();

while(1){

	status = get_status();

	usleep(20000);

	//Check if the button is pressed
	if(status == 22) //Value in decimal

		system(vector);
	
		//While pressed do nothing
		while(status == 22){

			status = get_status();		

		}
	}

return 0;
}
Esempio n. 9
0
int
do_rm(struct sftp_conn *conn, char *path)
{
	u_int status, id;

	debug2("Sending SSH2_FXP_REMOVE \"%s\"", path);

	id = conn->msg_id++;
	send_string_request(conn->fd_out, id, SSH2_FXP_REMOVE, path,
	    strlen(path));
	status = get_status(conn->fd_in, id);
	if (status != SSH2_FX_OK)
		error("Couldn't delete file: %s", fx2txt(status));
	return(status);
}
Esempio n. 10
0
int
do_mkdir(struct sftp_conn *conn, char *path, Attrib *a)
{
	u_int status, id;

	id = conn->msg_id++;
	send_string_attrs_request(conn->fd_out, id, SSH2_FXP_MKDIR, path,
	    strlen(path), a);

	status = get_status(conn->fd_in, id);
	if (status != SSH2_FX_OK)
		error("Couldn't create directory: %s", fx2txt(status));

	return(status);
}
Esempio n. 11
0
void cmd_get(int argc,char **argv)
{
  int psec;

  if (argc < 3) 
    usage();

  if (!strcmp(argv[2],"power")) {
    Dprintf("power\n");
    if (argc  < 4 ) {
      psec =10;
    } else {
      psec = atoi(argv[3]);
    }
    get_power(psec);

    
  } else if (!strcmp(argv[2],"state")){
    Dprintf("state");
    if (argc < 4)
      usage();

    if (!strcmp(argv[3],"all")) {
      get_status(1);
      get_status(2);
      get_status(3);

    }else if (!(!strcmp(argv[3],"1") | !strcmp(argv[3],"2") | !strcmp(argv[3],"3" ))){
      usage();
    }else {
      get_status(atoi(argv[3]));
    }
  }else{
    usage();
  }
}
Esempio n. 12
0
void bhvm::execute_program (void)
{
    try{


        while (program_counter < int(program.size()))
        {
	    //std::cout << program[program_counter] << std::endl;    // debug... traza todo
            exec_instruction(program[program_counter]);
            ++program_counter;
        }
        signal_debug(Alarm(MTK_HERE, "bhvm",  MTK_SS("end of program." << std::endl << get_status()), alPriorDebug));


    } catch(const mtk::Alarm& error) {
        Alarm al(MTK_HERE, "bhvm",  get_status(), alPriorCritic);
        al.Add(error);
        signal_error(al);
    } catch (std::exception& e) {
        signal_error(Alarm(MTK_HERE, "bhvm",  MTK_SS("c++ exception " << e.what()  << get_status()), alPriorCritic));
    } catch(...) {
        signal_error(Alarm(MTK_HERE, "bhvm",  MTK_SS("unknown error  " << get_status()), alPriorCritic));
    }
}
bool NRF24L01p::transmit(void* buf, uint8_t length) {

    write_tx_payload(buf, length);

    // Pulse CE to start TX mode
    spi.set_ce_pin(1);

    // Pulse add least 10 us to start TX mode
    // Thce = 10us
    TimeUtil::delay_microseconds(11);

    // We are transmitting only one packet
    spi.set_ce_pin(0);

    TimeUtil::delay_microseconds(130);

    uint8_t status = get_status();

    while (!(status & (1 << STATUS_TX_DS | 1 << STATUS_MAX_RT))) {
        status = get_status();
    }

    reset_tx_interrupts();

    if (status & 1 << STATUS_TX_DS) {
        // Other party needs 130 us to get to RX mode again.
        // Tstby2a = 130us
        TimeUtil::delay_microseconds(130);

        return 1;
    }

    flush_tx();

    return 0;
}
Esempio n. 14
0
File: msrr.c Progetto: iamedu/armdev
void msrr_inst(ARMProc *proc, UWord instruction) {
#ifdef DEBUG
        printf("Ejecutaste un msrr\n");
#endif
        UWord mask;
        Word operand, _bit_immediate, rotate_imm, Rm, field_mask, R, status_mode, byte_mask, byte1, byte2, byte3, byte4;
        if( !cond(proc, instruction) )
                return;
        _bit_immediate = get_bits(instruction, 0, 8);
        rotate_imm = get_bits(instruction, 8, 4);
        Rm = get_bits(instruction, 0, 4);
        field_mask = get_bits(instruction, 16, 4);
        R = get_bits(instruction, 22, 1);
        if( get_bits(instruction, 25, 1, 0))
                operand = ror(_bit_immediate, rotate_imm * 2);
        else
                operand = Rm;
        if( (operand & 0x06FFFF00) != 0 )
#ifdef DEBUG
                printf("UNPREDICTABLE\n");
#endif
        if( get_bits(field_mask, 0, 1) ) byte1 = 0x000000FF; else byte1 = 0x00000000;
        if( get_bits(field_mask, 1, 1) ) byte2 = 0x0000FF00; else byte2 = 0x00000000;
        if( get_bits(field_mask, 2, 1) ) byte3 = 0x00FF0000; else byte3 = 0x00000000;
        if( get_bits(field_mask, 3, 1) ) byte4 = 0xFF000000; else byte4 = 0x00000000;
        byte_mask = byte1 | byte2 | byte3 | byte4;
        status_mode = get_status(proc, status_m);
        if( !R ){
                if( status_mode == mode_fiq || status_mode == mode_irq || status_mode == mode_svc || status_mode == mode_abt || status_mode == mode_und )
                        if( (operand & 0x01000020) != 0){
#ifdef DEBUG
                                printf("UNPREDICTABLE\n");
#endif
                        }else
                                mask = byte_mask & (0xF8000000 | 0x0000000F);
                else
                        mask = byte_mask & 0xF8000000;
                *proc->cpsr = ( *proc->cpsr & ~mask ) | (operand & mask);
        }else
                if( proc->spsr != NULL ){
                        mask = byte_mask & (0xF8000000 | 0x0000000F | 0x01000020);
                        *proc->spsr = (*proc->spsr & ~mask) | (operand & mask);
                }else{
#ifdef DEBUG
                        printf("UNPREDICTABLE\n");
#endif
                }
}
Esempio n. 15
0
DSTATUS disk_initialize (void)
{
	DSTATUS sta;


	if (WaitForSingleObject(hMutex, 5000) != WAIT_OBJECT_0) return STA_NOINIT;

	get_status(&Stat[0]);
	sta = Stat[0].status;
	if (Stat[0].sz_sector != 512)
		sta = STA_NOINIT;
	Stat[0].wip = 0;

	ReleaseMutex(hMutex);
	return sta;
}
Esempio n. 16
0
void set_interface(interface *inter, struct ifaddrs *ifa)
{
  get_name(inter,ifa->ifa_name);
  get_status(inter,ifa);
  if (ifa->ifa_addr->sa_family == AF_INET)
  {
    get_ipv4(inter,ifa);
    get_mask(inter,ifa);
  }

  if (ifa->ifa_addr->sa_family == AF_INET6)
    get_ipv6(inter,ifa);

  if (ifa->ifa_addr->sa_family == AF_PACKET)
    get_hwaddr(inter,ifa);
}
Esempio n. 17
0
int
do_fsetstat(struct sftp_conn *conn, char *handle, u_int handle_len,
    Attrib *a)
{
	u_int status, id;

	id = conn->msg_id++;
	send_string_attrs_request(conn->fd_out, id, SSH2_FXP_FSETSTAT, handle,
	    handle_len, a);

	status = get_status(conn->fd_in, id);
	if (status != SSH2_FX_OK)
		error("Couldn't fsetstat: %s", fx2txt(status));

	return(status);
}
Esempio n. 18
0
int
do_setstat(struct sftp_conn *conn, char *path, Attrib *a)
{
	u_int status, id;

	id = conn->msg_id++;
	send_string_attrs_request(conn->fd_out, id, SSH2_FXP_SETSTAT, path,
	    strlen(path), a);

	status = get_status(conn->fd_in, id);
	if (status != SSH2_FX_OK)
		error("Couldn't setstat on \"%s\": %s", path,
		    fx2txt(status));

	return(status);
}
Esempio n. 19
0
static int get_process_array(char * page, int pid, int type)
{
    switch (type) {
    case PROC_PID_STATUS:
        return get_status(pid, page);
    case PROC_PID_ENVIRON:
        return get_env(pid, page);
    case PROC_PID_CMDLINE:
        return get_arg(pid, page);
    case PROC_PID_STAT:
        return get_stat(pid, page);
    case PROC_PID_STATM:
        return get_statm(pid, page);
    }
    return -EBADF;
}
Esempio n. 20
0
 bool done() {
    //rankprintf("last_snt = %d\n", last_sent);
    if (-1 == last_sent) return true;
    //task_list[last_sent].display();
    if (true != task_list[last_sent].sent) throw_error("Task never sent");
    if (true == task_list[last_sent].complete) return true;
    else {
       int data = get_status(this_comm);
       rankprintf("Rec'd status %d from node 1\n", data);
       if (STATUS_IDLE == data) {
          task_list[last_sent].complete = true;
          return true;
       }
       else return false;
    }
 }
Esempio n. 21
0
qstatus
PlProxy::readQueryReply()
{ flush();

  switch(int c = ios->get())
  { case 'f':				/* failure */
      debug("fail");
      set_status(QSTAT_FAIL);
      break;
    case 'l':				/* last (only) answer */
      debug("true (det)");
      set_status(QSTAT_TRUE);
      break;
    case 'm':				/* non-deterministic answer */
    { debug("true (nondet)");
      set_status(QSTAT_MORE);
      break;
    }
    case 'e':				/* Query execution error */
    { string s;
      debug("error");
      set_status(QSTAT_EXCEPT);

      receive_atom(s);
      closeQuery();
      throw(PlException(s.c_str()));
    }
    case 'E':				/* Communication/system error */
    { string s;
      debug("system error");
      set_status(QSTAT_COMMERROR);

      receive_atom(s);
      closeQuery();
      throw(PlException(s.c_str()));
    }
    default:
    { closeQuery();

      string s = "Unexpected query reply: ";
      s += c;
      throw(PlException(s.c_str()));
    }
  }

  return get_status();
}
Esempio n. 22
0
/*
 * status_packet - process status packet, return 0 on success processing, -1 on error
 * @inpack: received packet
 * @outpack:response packet
 * @sockfd: the socket that receive packet
 */
int status_packet(struct packet *inpack, struct packet *outpack, int sockfd)
{
    uint16_t num;

    assert(inpack && outpack);
    stat_dbg("Status_packet: processing packet --->\n");

    switch (inpack->cmd) {
    case CMD_STATUS_CHANGE: //status chage request
        stat_dbg("STATUS_CHANGE type: uin %d, stat: %d port %d\n", *PARAM_UIN(inpack), \
                *PARAM_TYPE(inpack), *PARAM_PORT(inpack));
        if (set_status(*PARAM_UIN(inpack), *PARAM_IP(inpack), *PARAM_PORT(inpack), \
                    *PARAM_TYPE(inpack)))
            return -1;
        
        fill_packet_header(outpack, PACKET_HEADER_LEN, REP_STATUS_CHANGED, \
                *PARAM_UIN(inpack));
        break;
    case CMD_GET_STATUS: //user status request
        *PARAM_UIN(outpack) = *PARAM_UIN(inpack);
        if (get_status(*PARAM_UIN(inpack), PARAM_IP(outpack), PARAM_PORT(outpack), \
                    PARAM_TYPE(outpack)))
            return -1;

        stat_dbg("GET_STATUS: uin %d, stat %d port %d\n", *PARAM_UIN(inpack), \
                *PARAM_TYPE(outpack), *PARAM_PORT(outpack));
        fill_packet_header(outpack, PACKET_HEADER_LEN+12, REP_STATUS, inpack->uin);
        break;
    case CMD_MULTI_STATUS: //multi-user status request
        num = *(uint16_t *)inpack->params;
        stat_dbg("%d uins to got status\n", num);

        *(uint16_t *)outpack->params = num;
        fill_packet_header(outpack, PACKET_HEADER_LEN + 2 + num * 6, \
                REP_MULTI_STATUS, inpack->uin);
        get_multi_status((uint32_t *)(inpack->params + 2), num, \
                (struct user_status *)(outpack->params + 2));
        break;
    default:
        return -1;
    }

    /* send back response packet */
    write(sockfd, outpack, outpack->len);

    return 0;
}
Esempio n. 23
0
    bool enter_elif_block(bool new_status)
    {
        if (!is_inside_ifpart())
            return false;       // #elif without matching #if

        if (get_enclosing_status()) {
            if (get_status()) {
            // entered a (false) #elif block from a true block
                this->top().set_status(false);
            }
            else if (new_status && !this->top().get_some_part_status()) {
            // Entered true #elif block and no previous block was true
                this->top().set_status(new_status);
            }
        }
        return true;
    }
Esempio n. 24
0
void vrpn_Tracker_Dyna::reset() {
    //static int numResets = 0;	// How many resets have we tried?;
  static char T_PDYN_C_CTL_C[4] ="\003\003\003";
  static int T_PDYN_RECORD_LENGTH = 8;

  vrpn_write_characters(serial_fd, (unsigned char*)T_PDYN_C_CTL_C, strlen(T_PDYN_C_CTL_C));
  vrpn_write_characters(serial_fd,(const unsigned char *) "4", 1); // set to polling mode;
      
  /* pause 1 second to allow the Dynasight buffer to stabilize	*/
  vrpn_SleepMsecs(1000.0*1);

  status = get_status();
      
  if ( status != T_OK ) {

    /* if no data, tracker probably not connected.  just bag it.    */
    if ( status == T_PDYN_NO_DATA )
    {
      fprintf(stderr, "vrpn_Tracker_Dyna::reset(): no data (is tracker turned on?)\n"); 
      status = vrpn_TRACKER_RESETTING;
      return;

    } 
    
  }else {
    fprintf(stderr, "vrpn_Tracker_Dyna: return valid status report\n");
    reportLength = T_PDYN_RECORD_LENGTH;
    
    // set it to continues mode;
    /* clear any leftover data	*/
   my_flush();

   /* set the Dynasight to continuous mode    */
   vrpn_write_characters(serial_fd, (unsigned char*)T_PDYN_C_CTL_C, strlen(T_PDYN_C_CTL_C));
   //vrpn_write_characters(serial_fd, (const unsigned char *)"V", 1);
   vrpn_write_characters(serial_fd, (const unsigned char *)"0", 1);
   //T_PDYN_C_CONTINUOUS = "V"
   vrpn_SleepMsecs(1000.0*1);
   //vrpn_gettimeofday(&timestamp, NULL);	// Set watchdog now;
   timestamp.tv_sec = -1;
   status = vrpn_TRACKER_SYNCING;	// We are trying for a new reading;
   return;
  }
				     
}
Esempio n. 25
0
void BuyChipLayer::click_btn_confirm(Ref* sender)
{
    //    int amount = PDM->get_room()->get_buyin_max() - PDM->get_room()->get_buyin_min();
    //    int buy_count = PDM->get_room()->get_buyin_min() + amount * slider_chip_->getPercent() / 100.0f;
    PDM->send_poker_add_chips(amount_, GetRoom()->get_id());
    
    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user( GDM->get_user_id()));
    if(user->get_status() == msg::SittingStatus::PLAYING)
    {
        PokerRoomLayer * prl = dynamic_cast<PokerRoomLayer *>(getParent()->getParent());
        if(prl&&prl->get_is_playing())
        {
            TipView::showAlertView(tools::local_string("offer_chip","这手牌打完后会给筹码。"));
        }
        
    }
    removeFromParent();
}
Esempio n. 26
0
DictionaryDatum
Node::get_status_base()
{
  DictionaryDatum dict = get_status_dict_();

  assert( dict.valid() );

  // add information available for all nodes
  ( *dict )[ names::local ] = is_local();
  ( *dict )[ names::model ] = LiteralDatum( get_name() );

  // add information available only for local nodes
  if ( is_local() )
  {
    ( *dict )[ names::global_id ] = get_gid();
    ( *dict )[ names::frozen ] = is_frozen();
    ( *dict )[ names::node_uses_wfr ] = node_uses_wfr();
    ( *dict )[ names::thread ] = get_thread();
    ( *dict )[ names::vp ] = get_vp();
    if ( parent_ )
    {
      ( *dict )[ names::parent ] = parent_->get_gid();

      // LIDs are only sensible for nodes with parents.
      // Add 1 as we count lids internally from 0, but from
      // 1 in the user interface.
      ( *dict )[ names::local_id ] = get_lid() + 1;
    }
  }

  ( *dict )[ names::thread_local_id ] = get_thread_lid();
  ( *dict )[ names::supports_precise_spikes ] = is_off_grid();

  // This is overwritten with a corresponding value in the
  // base classes for stimulating and recording devices, and
  // in other special node classes
  ( *dict )[ names::element_type ] = LiteralDatum( names::neuron );

  // now call the child class' hook
  get_status( dict );

  assert( dict.valid() );
  return dict;
}
Esempio n. 27
0
void 
FindSCU
::find(DcmDataset const * query, Callback callback) const
{
    CFindRequest request(
        this->_association->get_association()->nextMsgID++,
        this->_affected_sop_class, DIMSE_PRIORITY_MEDIUM, query);
    this->_send(request, this->_affected_sop_class);
    
    // Receive the responses
    bool done = false;
    while(!done)
    {
        // FIXME: include progress callback
        auto response = this->_receive<CFindResponse>();

        if(response.get_message_id_being_responded_to() != request.get_message_id())
        {
            std::ostringstream message;
            message << "DIMSE: Unexpected Response MsgId: "
                    << response.get_message_id_being_responded_to()
                    << "(expected: " << request.get_message_id() << ")";
            throw Exception(message.str());
        }
        if(response.has_affected_sop_class_uid() &&
           response.get_affected_sop_class_uid() != request.get_affected_sop_class_uid())
        {
            std::ostringstream message;
            message << "DIMSE: Unexpected Response Affected SOP Class UID: "
                    << response.get_affected_sop_class_uid()
                    << " (expected: " << request.get_affected_sop_class_uid() << ")";
            throw Exception(message.str());
        }

        done = !DICOM_PENDING_STATUS(response.get_status());
        if(!done)
        {
            callback(response.get_data_set());
            // Response dataset is allocated in this->_receive,
            // free it now.
            response.delete_data_set();
        }
    }
}
Esempio n. 28
0
bool Radio::txStandBy(uint32_t timeout) {
  uint32_t elapsed = 0;

  while (!(read_register(FIFO_STATUS) & _BV(TX_EMPTY))) {
    if (get_status() & _BV(MAX_RT)) {
      write_register(STATUS, _BV(MAX_RT));

      if (elapsed >= timeout) {
        flush_tx();
        return 0;
      }
    }

    elapsed += 200;
    _delay_ms(200);
  }

  return 1;
}
Esempio n. 29
0
int AndGate::compute()
{
#ifdef DEBUG
	fprintf( stdout, "AndGate::compute computing %lu: ", _inputs.size() );
#endif

	// Checking if this gate has some issues
	if( get_status() == GateStatus::correct )
	{
		_value = _inputs.at( 0 )->get_value();

#ifdef DEBUG
		fprintf( stdout, "%d ", _value );
#endif

		for( size_t i = 1; i < _inputs.size(); i++ )
		{
			// Short circuit evaluation
			if( _value == 0 )
				break;

			_value &= _inputs.at( i )->get_value();

#ifdef DEBUG
			fprintf( stdout, "%d(%d) ", _inputs.at( i )->get_value(), _value );
#endif
		}
	}
	else
	{
		_value = get_status_value();

#ifdef DEBUG
		fprintf( stdout, "stuck to %d ", _value );
#endif
	}

#ifdef DEBUG
	fprintf( stdout, "= computed %d\n", _value );
#endif

	return _value;
}
Esempio n. 30
0
static enum fw_update_state s5_read_status(struct fw_update_ctrl *fw_update)
{
	int rv = get_status(&fw_update->status);

	if (rv) {
		fw_update->rv = -1;
		log_msg(fw_update, S5_READ_STATUS, "Interface Error");
		return S10_TERMINAL;
	}
	if (fw_update->status.fw_update_mode == 0)
		return S2_WRITE_PREPARE;

	/* Init Write Block Loop Controls */
	fw_update->ptr += fw_update->fw_img_hdr->fw_binary_offset;
	fw_update->size -= fw_update->fw_img_hdr->fw_binary_offset;
	fw_update->offset = 0;

	return S6_WRITE_BLOCK;
}