/* update the state of the sensor */ void AP_RangeFinder_LightWareSerial::update(void) { if (get_reading(state.distance_cm)) { // update range_valid state based on distance measured last_reading_ms = hal.scheduler->millis(); update_status(); } else if (hal.scheduler->millis() - last_reading_ms > 200) { set_status(RangeFinder::RangeFinder_NoData); } }
void configure_package(deb_file_t *deb_file) { const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name]; const char *package_version = name_hashtable[package_hashtable[deb_file->package]->version]; const int status_num = search_status_hashtable(package_name); int return_value; printf("Setting up %s (%s)\n", package_name, package_version); /* Run the preinst prior to extracting */ return_value = run_package_script(package_name, "postinst"); if (return_value == -1) { /* TODO: handle failure gracefully */ error_msg_and_die("postrm failure.. set status to what?"); } /* Change status to reflect success */ set_status(status_num, "install", 1); set_status(status_num, "installed", 3); }
static void move_to_top (MaintainrProjectbox *box, MaintainrShell *item) { MaintainrProjectconf *conf; conf = maintainr_projectbox_get_conf (box); maintainr_config_force_top (item->priv->conf, conf); set_status (item); maintainr_config_save (item->priv->conf); gtk_box_reorder_child (GTK_BOX (item->priv->projects_box), GTK_WIDGET (box), 0); }
/* update the state of the sensor */ void AP_RangeFinder_LeddarOne::update(void) { if (get_reading(state.distance_cm)) { // update range_valid state based on distance measured last_reading_ms = AP_HAL::millis(); update_status(); } else if (AP_HAL::millis() - last_reading_ms > 200) { set_status(RangeFinder::RangeFinder_NoData); } }
int set_last_status(alphabet_game_t *alphabet_game, status_t status) { alphabet_game_t *ag=alphabet_game; status_t stts=status; if(NULL==ag){ return RET_FAILED; } return set_status(&ag->last_status,stts); }
/** * if we are not moving for a while, set we are ready to punch */ void set_ready_to_punch_if_standing_long(int *standing_cycles_count) { // standing for long enough if (*standing_cycles_count > CALIBRATION_CALM_COUNTER_LIMIT) { // get ready to punch! *standing_cycles_count = 0; set_status(STATE_PUNCH_READY); } }
static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface, DWORD dwReserved, IBinding *pib) { set_status(IDS_DOWNLOADING); IBinding_AddRef(pib); dwl_binding = pib; return S_OK; }
/* * Messages incoming from the phone */ void received_message(DictionaryIterator *received, void *context) { Event temp_event; Tuple *tuple = dict_find(received, RECONNECT_KEY); if (tuple) { vibes_short_pulse(); calendar_request(); } // Gather the bits of a calendar together tuple = dict_find(received, CALENDAR_RESPONSE_KEY); if (tuple) { set_status(STATUS_REPLY); uint8_t i, j; if (g_count > g_received_rows) { i = g_received_rows; j = 0; } else { g_count = tuple->value->data[0]; i = 0; j = 1; } while (i < g_count && j < tuple->length) { memcpy(&temp_event, &tuple->value->data[j], sizeof(Event)); if (temp_event.index < MAX_EVENTS) memcpy(&g_events[temp_event.index], &temp_event, sizeof(Event)); i++; j += sizeof(Event); } g_received_rows = i; if (g_count == g_received_rows) { g_max_entries = g_count; process_rot_events(); if (nothing_showing) { nothing_showing = false; show_next_event(); } battery_request(); } } tuple = dict_find(received, BATTERY_RESPONSE_KEY); if (tuple) { memcpy(&g_battery_status, &tuple->value->data[0], sizeof(BatteryStatus)); set_battery(g_battery_status.state, g_battery_status.level); } }
void rcv_arp(void) { if ((ARP_P->hw_type != ARETH) || (ARP_P->protocol != ARIP)) goto leave; if (ARP_P->his_proto_addr != tcpipcfg.c_myip) { //rprintf("[ARP:NOT FOR ME]"); goto leave; } //rprintf("[ARP]"); //print_packet(ARP_P, 0); switch (ARP_P->opcode) { case ARREQ : // Incomming Request statistics.arpInRequests++; copy_hw_addr(ETH_P->destination, ARP_P->my_hw_addr); ARP_P->his_proto_addr = ARP_P->my_proto_addr; copy_hw_addr(ARP_P->his_hw_addr, ARP_P->my_hw_addr); copy_hw_addr(ARP_P->my_hw_addr, ARP_STUB.my_hw_addr); ARP_P->my_proto_addr = tcpipcfg.c_myip; ARP_P->opcode = ARREP; snd_packet(ARP_P, ARP_PLEN); break; case ARREP : { // Response for my ARP Request struct TCB *tp; int i; //rprintf("[R_A-REP]"); for (tp = tcb, i = 0; i < num_socket; i++, tp++) { if (!(IP_STUB(tp)->transport)) continue; // Update All TCB's with matching IP address if ((tp->status & TCB_ARP_ING) && (arp_target(tp) == ARP_P->my_proto_addr)) { //rprintf("[ARP-OK %d]", i); copy_hw_addr(ETH_STUB(tp)->destination, ARP_P->my_hw_addr); if (tp->status & TCB_ARP_ING) { tp->arp_retrytimer = 0; // Stop timer tp->timeout_count = 0; clr_status(tp, TCB_ARP_ING); set_status(tp, TCB_ARP_ED); statistics.arpInReplys++; } check_tcp_send(tp); check_udp_send(tp); } } break; } default : break; } leave: ; }
int jfetch_initialize( jfetch_status *status, const char *input, bool is_file ) { int result = JFETCH_ERR_NONE; TRACE_ENTRY(); if(!status) { result = JFETCH_ERR_INVALID; goto exit; } memset(status, 0, sizeof(jfetch_status)); if(!input) { result = JFETCH_ERR_INVALID; goto exit; } if(g_manager) { result = jfetch_destroy(status); if(JFETCH_FAILURE(result)) { goto exit; } } try { g_library = json::acquire(); if(!g_library) { result = JFETCH_ERR_UNINIT; goto exit; } g_library->initialize(input, is_file); g_manager = g_library->acquire_manager(); if(!g_manager) { result = JFETCH_ERR_UNINIT; goto exit; } } catch(std::runtime_error &exc) { set_status(status, exc.what()); result = JFETCH_ERR_FAIL; goto exit; } exit: TRACE_EXIT("Return Value: 0x%x", result); return result; }
void set_status_from_gdb(const string& text) { if (private_gdb_input) return; if (!show_next_line_in_status && !text.contains(gdb->prompt(), -1)) return; // Fetch line before prompt in GDB window String s = XmTextGetString(gdb_w); string message = s + messagePosition; XtFree(s); if (message.empty() && text.contains('\n')) message = text; if (show_next_line_in_status && (message.empty() || message[message.length() - 1] != '\n')) return; // Skip prompt and uncomplete lines int idx = message.index('\n', -1); if (idx >= 0) message = message.before(idx); strip_trailing_newlines(message); if (message.empty() && text.contains('\n')) message = text; if (show_next_line_in_status) { messagePosition = XmTextGetLastPosition(gdb_w) + text.length(); show_next_line_in_status = false; message.gsub('\n', ' '); } else { // Show first line only while (!message.empty() && message[0] == '\n') message = message.after('\n'); if (message.contains('\n')) message = message.before('\n'); } strip_trailing_newlines(message); message.gsub('\t', ' '); if (message.empty()) return; // Don't log this stuff - it's already logged bool old_log_status = log_status; log_status = false; set_status(message); log_status = old_log_status; }
int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg ) { char *c = msg && msg[0] ? mir_utf8encodeT(msg) : NULL; debugLogA("[YahooSetAwayMessage] Status: %S, Msg: %s", pcli->pfnGetStatusModeDescription(status, 0), (char*)c); if (!m_bLoggedIn) { if (m_iStatus == ID_STATUS_OFFLINE) { debugLogA("[YahooSetAwayMessage] WARNING: WE ARE OFFLINE!"); mir_free(c); return 1; } else { if (m_startMsg) free(m_startMsg); m_startMsg = c ? strdup(c) : NULL; mir_free(c); return 0; } } /* need to tell ALL plugins that we are changing status */ BroadcastStatus(status); if (m_startMsg) free(m_startMsg); /* now decide what we tell the server */ if (c != 0) { m_startMsg = strdup(c); if (status == ID_STATUS_ONLINE) { set_status(YAHOO_CUSTOM_STATUS, c, 0); } else if (status != ID_STATUS_INVISIBLE) { set_status(YAHOO_CUSTOM_STATUS, c, 1); } } else { set_status(status, NULL, 0); m_startMsg = NULL; } mir_free(c); return 0; }
int PrefixInfo::set_read_write_status(uint64_t prefix, int status) { int err = 0; tbsys::CWLock lock(&rw_lock_); if (status == 0) { err = set_status(prefix, 0); if (0 != err) { TBSYS_LOG(WARN, "failed to set status, prefix=%lu, err=%d", prefix, err); } } else { lock.lock(); int ori_status = 0; err = get_status(prefix, ori_status); if (0 != err) { TBSYS_LOG(WARN, "failed to get ori status, prefix=%lu, err=%d", prefix, err); } else { if (ori_status != 0) { err = READ_WRITE_CONFLICT; } else { err = set_status(prefix, status); if (0 != err) { TBSYS_LOG(WARN, "failed to set status, prefix=%lu, status=%d, err=%d", prefix, status, err); } } } lock.unlock(); } return err; }
/*- -------------------------------------------------------------- -*/ ResearchRobot::ResearchRobot(int id, int width, int height) : Vehicle(width, height) { set_type('S'); set_num_id(id); // setting the robot status def_status = 50; set_status(def_status); // initially the robot hasn't deployed any flags flagsDeployed = 0; }
void CompassCalibrator::start(bool retry, float delay, uint16_t offset_max) { if(running()) { return; } _offset_max = offset_max; _attempt = 1; _retry = retry; _delay_start_sec = delay; _start_time_ms = AP_HAL::millis(); set_status(COMPASS_CAL_WAITING_TO_START); }
// Select a source; show the full path name in the status line static void SelectSourceCB(Widget w, XtPointer, XtPointer call_data) { XmListCallbackStruct *cbs = (XmListCallbackStruct *)call_data; int pos = cbs->item_position; ListSetAndSelectPos(w, pos); pos--; if (pos < 0) pos = all_sources.size() - 1; set_status(all_sources[pos]); }
void BattleResultRequest::MergeFrom(const BattleResultRequest& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_did()) { set_did(from.did()); } if (from.has_status()) { set_status(from.status()); } } }
static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError) { if(FAILED(hresult)) { ERR("Binding failed %08x\n", hresult); return S_OK; } set_status(IDS_INSTALLING); return S_OK; }
BOOL InitInstance (int CmdShow) { WNDCLASS wc; wc.style = 0; wc.lpfnWndProc = (WNDPROC) MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hinst; wc.hIcon = LoadIcon(g_hinst, MAKEINTRESOURCE(IDI_ICON)); wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = _T("Osmophone"); RegisterClass(&wc); #ifdef _WIN32_WCE int style = WS_VISIBLE; #else int style = WS_POPUP; #endif g_hwnd = CreateWindow(_T("Osmophone"), _T("Osmophone"), style, 0, caption_h, disp_w, disp_h, NULL, NULL, g_hinst, NULL); if (!g_hwnd) return FALSE; ShowWindow(g_hwnd, CmdShow); refresh_recent_files(); ::SetTimer(g_hwnd, STATE_TIMER_ID, STATE_TIMER_DUR, NULL); do_layout(1); set_status("Loading Terminal"); PostMessage(g_hwnd, WM_LOADTERM, 0, 0); set_status("Ready"); return TRUE; }
void adc_inst(ARMProc *proc, UWord instruction) { #ifdef DEBUG printf("Ejecutaste un adc\n"); #endif //Instrucciones de DP ARMAddr *modes = addr_modes_dp(); ARMAddr *mode; Word S; Word Rn; Word Rd; Word carry; Word last_rd; ARMAddrDPReturn result; if(!cond(proc, instruction)) return; S = get_bits(instruction,20,1); Rn = get_bits(instruction,16,4); Rd = get_bits(instruction,12,4); //---Parte indispensable para obtener el result mode = fetch_addr(modes, instruction); if(mode != NULL) mode->execute(proc, instruction, &result); //--- last_rd = *proc->r[Rd]; *proc->r[Rd] = AddCarryFrom(*proc->r[Rn],result.shifter_operand + get_bits(*proc->cpsr,29,1),&carry); if(S && Rd == 15) { if(proc->cpsr != NULL) { *proc->cpsr = *proc->spsr; } } else if(S == 1) { set_status(proc, status_n, get_bits(*proc->r[Rd], 31, 1)); set_status(proc, status_z, *proc->r[Rd] == 0); set_status(proc, status_c, carry); set_status(proc, status_v, OverflowFrom(last_rd,*proc->r[Rd])); } }
void DBServer::endpoint_query(const msgpack::object& request, Packer* reply_header, Packer* reply_data) { reply_header->pack_map(header_sizes::QUERY); MsgType msg; try { request.convert(msg); } catch (msgpack::type_error& e) { // TODO: log error, message cannot be deserialized set_status(status_codes::DESERIALIZATION_ERROR, "Deserialization failed.", e.what(), reply_header); write_query_header_defaults(reply_header); return; } if (!databases_.count(msg.database)) { set_status(status_codes::DATABASE_NOT_FOUND, "Database not found.", msg.database, reply_header); return; } Database& db = *databases_.at(msg.database); try { db.query(msg.operation, msg.query, msg.parameters, reply_header, reply_data); } catch (sqlite_error& e) { // TODO: log error, invalid query set_status(status_codes::INVALID_QUERY, e.what(), e.extended(), reply_header); write_query_header_defaults(reply_header); return; } set_status(status_codes::OK, response_messages::OK, "", reply_header); }
/* update the state of the sensor */ void AP_RangeFinder_MAVLink::update(void) { //Time out on incoming data; if we don't get new //data in 500ms, dump it if(AP_HAL::millis() - last_update_ms > AP_RANGEFINDER_MAVLINK_TIMEOUT_MS) { set_status(RangeFinder::RangeFinder_NoData); state.distance_cm = 0; } else { state.distance_cm = distance_cm; update_status(); } }
// Same, but issue messages in status line void create_session_dir(const string& session) { std::ostringstream messages; create_session_dir(session, messages); string msg(messages); while (!msg.empty()) { string line = msg.before('\n'); set_status(line); msg = msg.after('\n'); } }
void Webserver::onHttp(connection_hdl handle){ auto con = socketServer.get_con_from_hdl(handle); std::string path = con->get_resource().substr(1); if(path.length() == 0){ // Default file to serve path = "index.html"; } auto resourcePath = webUtils::pathToResource(path); std::ifstream fin(resourcePath, std::ios::in | std::ios::binary); if(!fin.is_open()){ con->set_status(websocketpp::http::status_code::not_found); return; } std::ostringstream oss; oss << fin.rdbuf(); std::string fileContent = oss.str(); con->set_status(websocketpp::http::status_code::ok); con->set_body(fileContent); }
/** * The head should be down or moves to this state. "wait" until * the HEAD_UP signal is false. don't literally wait, just * see if the head is down. If it is, begin retracting and set * RETRACT state. */ void control_punch(int * hole_to_punch) { uint32_t input; inport_byte(0x7071, input); if ((input & 1) == 0){ // is head down? outport_byte(OUT_PUNCH_IRQ, 0b10); // begin retract set_status(STATE_RETRACT); // status "head is moving up" *hole_to_punch += 1; // loop to the next hole newdest = 1; } }
static int rmi_f05_initialize(struct rmi_function_container *fn_dev) { struct f05_data *f05; u16 query_base_addr; u16 control_base_addr; u8 num_of_rx_electrodes; u8 num_of_tx_electrodes; int rc; struct rmi_device *rmi_dev = fn_dev->rmi_dev; f05 = devm_kzalloc(&fn_dev->dev, sizeof(struct f05_data), GFP_KERNEL); if (!f05) { dev_err(&fn_dev->dev, "Failed to allocate fn_05_data.\n"); return -ENOMEM; } fn_dev->data = f05; f05->fn_dev = fn_dev; query_base_addr = fn_dev->fd.query_base_addr; control_base_addr = fn_dev->fd.control_base_addr; rc = rmi_read_block(rmi_dev, query_base_addr, (u8 *) &f05->dev_query, sizeof(struct f05_device_queries)); if (rc < 0) { dev_err(&fn_dev->dev, "Failed to read f05 query register, code: %d.\n", rc); return rc; } rc = rmi_read(rmi_dev, control_base_addr, (u8 *) &f05->dev_control); if (rc < 0) { dev_err(&fn_dev->dev, "Failed to read f05 control register, code: %d.\n", rc); return rc; } num_of_rx_electrodes = f05->dev_query.num_of_rx_electrodes; num_of_tx_electrodes = f05->dev_query.num_of_tx_electrodes + 1; f05->max_report_size = num_of_tx_electrodes * num_of_rx_electrodes * 2; f05->report_data = devm_kzalloc(&fn_dev->dev, f05->max_report_size, GFP_KERNEL); f05->tmp_buffer = devm_kzalloc(&fn_dev->dev, f05->max_report_size, GFP_KERNEL); mutex_init(&f05->status_mutex); mutex_lock(&f05->status_mutex); set_status(f05, F05_STATE_IDLE); mutex_unlock(&f05->status_mutex); f05->data_ready = false; init_waitqueue_head(&f05->wq); f05_raw_data_char_dev_register(f05); return 0; }
//+------------------------------------------------------------------ void UviewCCD::setIvsTROI(short ROIid, unsigned long color, short x1, short y1, short x2, short y2) { try { //--Calling function to set each IvsT ROI on camera object--// short response = m_camera-> setIvsTROI(ROIid, color, x1, y1, x2, y2); //--If response is -1, setIvsTROI didn't work--// if (response == -1) { Tango::Except::throw_exception( static_cast<const char*> ("TANGO_DEVICE_ERROR"), static_cast<const char*> ("Problem to set ROI"), static_cast<const char*> ("UviewCCD::setIvsTROI")); } //--Else set status--// else { //--Stringstream used to convert ROIid into a string--// std::stringstream roiStringStream; roiStringStream << ROIid; if (m_roiId == "") m_roiId = roiStringStream.str(); else if(m_roiId.find(roiStringStream.str())==std::string::npos) { m_roiId = m_roiId+" ,"+roiStringStream.str(); } //--Set state/status--// set_status("ROI : " + m_roiId + " set.."); set_state(Tango::STANDBY); } } catch (Tango::DevFailed& df) { ERROR_STREAM << df << endl; //- rethrow exception Tango::Except::re_throw_exception(df, static_cast<const char*> ("TANGO_DEVICE_ERROR"), static_cast<const char*> (string(df.errors[0].desc).c_str()), static_cast<const char*> ("UviewCCD::setIvsTROI")); } catch (Exception& e) { ERROR_STREAM << e.getErrMsg() << endl; //- throw exception Tango::Except::throw_exception( static_cast<const char*> ("TANGO_DEVICE_ERROR"), static_cast<const char*> (e.getErrMsg().c_str()), static_cast<const char*> ("UviewCCD::setIvsTROI")); } }
/*! \brief Re-initializes the BDirectory to the directory referred to by the supplied node_ref. \param nref the node_ref referring to the directory \return - \c B_OK: Everything went fine. - \c B_BAD_VALUE: \c NULL \a nref. - \c B_ENTRY_NOT_FOUND: Directory not found. - \c B_PERMISSION_DENIED: Directory permissions didn't allow operation. - \c B_NO_MEMORY: Insufficient memory for operation. - \c B_LINK_LIMIT: Indicates a cyclic loop within the file system. - \c B_BUSY: A node was busy. - \c B_FILE_ERROR: A general file error. - \c B_NO_MORE_FDS: The application has run out of file descriptors. */ status_t BDirectory::SetTo(const node_ref* nref) { Unset(); status_t error = (nref ? B_OK : B_BAD_VALUE); if (error == B_OK) { entry_ref ref(nref->device, nref->node, "."); error = SetTo(&ref); } set_status(error); return error; }
// keep 'available' and game name ('location') for backward compatibility void wesnothd::player::mark_available(const int game_id, const std::string& location) { if (game_id == 0) { cfg_.set_attr("available", "yes"); set_status(LOBBY); } else { cfg_.set_attr("available", "no"); } cfg_.set_attr_dup("game_id", lexical_cast<std::string>(game_id).c_str()); cfg_.set_attr_dup("location", location.c_str()); }
int start_arp(struct TCB *tp, unsigned long addr) { struct TCB *sp; int i; if ((addr == IP_STUB(tp)->destination) && (tp->status & TCB_ARP_ED)) return(1); if (driver_type == SLIP_DRIVER) // We dont need ARP goto arp_ed; if ((tp->option & SO_BROADCAST) && (addr == INADDR_BROADCAST)) { // Copy Broadcast Address copy_hw_addr(ETH_STUB(tp)->destination, ARP_STUB.ether_pkt.destination); goto arp_ed; }; for (sp = tcb, i = 0; i < num_socket; i++, sp++) { if ((sp->status & TCB_ARP_ED) && (IP_STUB(sp)->destination == addr)) { copy_hw_addr(ETH_STUB(tp)->destination, ETH_STUB(sp)->destination); arp_ed: IP_STUB(tp)->destination = addr; set_status(tp, TCB_ARP_ED); return(1); } } IP_STUB(tp)->destination = addr; arp_target(tp) = samenet(addr) ? addr : tcpipcfg.c_defgw; // Failed to find Matched Address, Now do the ARP ARP_STUB.his_proto_addr = arp_target(tp); clr_status(tp, TCB_ARP_ED); set_status(tp, TCB_ARP_ING); statistics.arpOutRequests++; tp->arp_retrytimer = ONE_SECOND; tp->timeout_count = 1; //rprintf("[ARP_S]"); //print_packet(&ARP_STUB, 0); snd_packet(&ARP_STUB, ARP_PLEN); return(0); }