int AxisCam::set_iris(int iris, bool relative, bool blocking) { ostringstream oss; int target_iris = iris; if (relative) { int tmp_iris; get_iris(&tmp_iris); target_iris = tmp_iris + iris; } printf("target iris = %d\n", target_iris); if (iris == 0 && !relative) oss << "autoiris=on"; else oss << string("autoiris=off&") << (relative ? "r" : "") << string("iris=") << iris; int ret = send_params(oss.str()); if (ret != 0) return ret; if (!blocking || iris == 0) return 0; int tmp_iris; return get_iris(&tmp_iris); // this appears to force a block on the camera side }
int main(int argc, char **argv) { BB_SYS_PARAM bb_param; int param_opt; while (-1 != (param_opt = getopt(argc, argv, "sd"))) { switch(param_opt) { case 's' : printf("BB_Setup---------------------------------------\n"); BB_Setup(&bb_param); printf("BB_Setup---------------------------------------\n"); break; case 'd' : while(1) { printf("BB KGC Daemon Running..\n"); receive_ip_url(); printf("BB_Keygen Start\n"); BB_Keygen(URL, &bb_param); printf("BB_Keygen END\n"); sleep(1); printf("Sending Parameters...\n"); send_params(); printf("Parameters Sent, Configuring...\n"); named_conf(); printf("Configure END.\n\n"); } break; case '?' : printf("Usage : %s <mode (sd)> [option]\n", argv[0]); return 0; } } return 0; }
int AxisCam::set_focus(int focus, bool relative) { ostringstream oss; if (focus == 0 && !relative) oss << string("autofocus=on"); else { last_autofocus_enabled = false; oss << string("autofocus=off&") << (relative ? "r" : "") << string("focus=") << focus; } return send_params(oss.str()); }
int AxisCam::set_ptz(double pan, double tilt, double zoom, bool relative) { ostringstream oss; if (relative) oss << "rpan=" << pan << "&rtilt=" << tilt << "&rzoom=" << zoom; else oss << "pan=" << clamp(pan, -175, 175) << "&tilt=" << clamp(tilt, -45, 90) << "&zoom=" << clamp(zoom, 0, 50000); // not sure of upper bound return send_params(oss.str()); }
void MavlinkParametersManager::send(const hrt_abstime t) { int max_num_to_send; if (_mavlink->get_protocol() == SERIAL && !_mavlink->is_usb_uart()) { max_num_to_send = 3; } else { // speed up parameter loading via UDP, TCP or USB: try to send 20 at once max_num_to_send = 20; } int i = 0; // Send while burst is not exceeded, we still have buffer space and still something to send while ((i++ < max_num_to_send) && (_mavlink->get_free_tx_buf() >= get_size()) && send_params()); }
/* * Reuse existing connection */ static bool connect_using_existing_connection(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, StartupPacket *sp) { int i, freed = 0; /* * Save startup packet info */ for (i = 0; i < NUM_BACKENDS; i++) { if (VALID_BACKEND(i)) { if (!freed) { pool_free_startup_packet(backend->slots[i]->sp); freed = 1; } backend->slots[i]->sp = sp; } } /* Reuse existing connection to backend */ if (pool_do_reauth(frontend, backend)) { pool_close(frontend); connection_count_down(); return false; } if (MAJOR(backend) == 3) { char command_buf[1024]; /* If we have received application_name in the start up * packet, we send SET command to backend. Also we add or * replace existing application_name data. */ if (sp->application_name) { snprintf(command_buf, sizeof(command_buf), "SET application_name TO '%s'", sp->application_name); for (i=0;i<NUM_BACKENDS;i++) { if (VALID_BACKEND(i)) if (do_command(frontend, CONNECTION(backend, i), command_buf, MAJOR(backend), MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) { pool_error("connect_using_existing_connection: do_command failed. command: %s", command_buf); return false; } } pool_add_param(&MASTER(backend)->params, "application_name", sp->application_name); } if (send_params(frontend, backend)) { pool_close(frontend); connection_count_down(); return false; } } /* Send ReadyForQuery to frontend */ pool_write(frontend, "Z", 1); if (MAJOR(backend) == 3) { int len; char tstate; len = htonl(5); pool_write(frontend, &len, sizeof(len)); tstate = TSTATE(backend, MASTER_NODE_ID); pool_write(frontend, &tstate, 1); } if (pool_flush(frontend) < 0) { pool_close(frontend); connection_count_down(); return false; } return true; }