本文整理汇总了C++中cli_err函数的典型用法代码示例。如果您正苦于以下问题:C++ cli_err函数的具体用法?C++ cli_err怎么用?C++ cli_err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cli_err函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: object_put
bool object_put(struct client *cli)
{
const char *user = cli->user;
uint64_t content_len = le64_to_cpu(cli->creq.data_len);
enum chunk_errcode err;
if (!user)
return cli_err(cli, che_AccessDenied, true);
cli->out_ce = objcache_get_dirty(&chunkd_srv.actives,
cli->key, cli->key_len);
if (!cli->out_ce)
return cli_err(cli, che_InternalError, true);
cli->out_bo = fs_obj_new(cli->table_id, cli->key, cli->key_len,
content_len, &err);
if (!cli->out_bo)
return cli_err(cli, err, true);
SHA1_Init(&cli->out_hash);
cli->out_len = content_len;
cli->out_user = strdup(user);
if (!cli->out_len)
return object_put_end(cli);
cli->state = evt_data_in;
return true;
}
开发者ID:henrich,项目名称:hail,代码行数:30,代码来源:object.c
示例2: object_get
bool object_get(struct client *cli, bool want_body)
{
int rc;
enum chunk_errcode err = che_InternalError;
struct backend_obj *obj;
struct chunksrv_resp_get *get_resp = NULL;
get_resp = calloc(1, sizeof(*get_resp));
if (!get_resp) {
cli->state = evt_dispose;
return true;
}
resp_init_req(&get_resp->resp, &cli->creq);
cli->in_obj = obj = fs_obj_open(cli->table_id, cli->user, cli->key,
cli->key_len, &err);
if (!obj) {
free(get_resp);
return cli_err(cli, err, true);
}
cli->in_len = obj->size;
get_resp->resp.data_len = cpu_to_le64(obj->size);
memcpy(get_resp->resp.hash, obj->hash, sizeof(obj->hash));
get_resp->mtime = cpu_to_le64(obj->mtime);
rc = cli_writeq(cli, get_resp, sizeof(*get_resp), cli_cb_free, get_resp);
if (rc) {
free(get_resp);
return true;
}
if (!want_body) {
cli_in_end(cli);
goto start_write;
}
if (!cli->in_len) {
applog(LOG_INFO, "zero-sized object");
cli_in_end(cli);
goto start_write;
}
if (!object_read_bytes(cli)) {
cli_in_end(cli);
return cli_err(cli, err, false);
}
start_write:
return cli_write_start(cli);
}
开发者ID:henrich,项目名称:hail,代码行数:54,代码来源:object.c
示例3: handle_params
static int handle_params(struct cli_state *s, int argc, char **argv, bool is_tx)
{
int i, status;
char *val;
char file_mode[3];
struct common_cfg *common;
if (is_tx) {
strcpy(file_mode, "r");
common = &s->rxtx_data->tx.common;
} else {
strcpy(file_mode, "w");
common = &s->rxtx_data->rx.common;
}
for(i = 2; i < argc; i++) {
val = strchr(argv[i], '=');
if (!val) {
cli_err(s, argv[0],
"No value provided for parameter \"%s\"", argv[i]);
return CMD_RET_INVPARAM;
}
*val++ = '\0';
if (!strcasecmp(RXTX_PARAM_FILE, argv[i])) {
status = set_sample_file_path(common, val);
} else if (!strcasecmp(RXTX_PARAM_FILEFORMAT, argv[i])) {
common->file_fmt = str2fmt(val);
if (common->file_fmt == RXTX_FMT_INVALID) {
cli_err(s, argv[0], "Invalid format provided (%s)", val);
return CMD_RET_INVPARAM;
}
} else {
if (is_tx) {
status = handle_tx_param(s, argv[i], val);
if (status)
return status;
} else {
status = handle_rx_param(s, argv[i], val);
if (status)
return status;
}
}
}
return 0;
}
开发者ID:lunixbochs,项目名称:bladeRF,代码行数:50,代码来源:rxtx.c
示例4: parse_cmdline
int parse_cmdline(int argc, char **argv, struct params *p, struct cli_state *s)
{
int i;
int status = 0;
char *sep;
memset(p, 0, sizeof(*p));
memset(p->serial, '0', BLADERF_SERIAL_LENGTH - 1);
p->type = BLADERF_IMAGE_TYPE_INVALID;
assert(argc >= 2);
for (i = 1; i < argc && status == 0; i++) {
/* Check for input file */
sep = strchr(argv[i], '=');
if (!sep) {
if (p->img_file) {
cli_err(s, argv[0],
"Only one image file parameter is permitted.");
status = CMD_RET_INVPARAM;
} else {
p->img_file = interactive_expand_path(argv[i]);
}
} else {
*sep = '\0';
sep++;
status = handle_param(argv[i], sep, p, s, argv[0]);
}
}
if (status == 0) {
if (!p->img_file) {
cli_err(s, argv[0], "An image file parameter is required.");
status = CMD_RET_INVPARAM;
} else if (p->type == BLADERF_IMAGE_TYPE_RAW &&
!(p->override_address || p->max_length == 0)) {
cli_err(s, argv[0],
"An address and a length are required for type=raw.");
status = CMD_RET_INVPARAM;
} else if (argc > 2 && !p->data_file) {
cli_err(s, argv[0],
"A data input file is required when creating an image.");
status = CMD_RET_INVPARAM;
}
}
return status;
}
开发者ID:kaysin,项目名称:bladeRF,代码行数:49,代码来源:flash_image.c
示例5: load_fx3
static int load_fx3(struct cli_state *s, char *file)
{
char *expanded_path;
int cmd_status = 0;
int lib_status;
if ((expanded_path = interactive_expand_path(file)) == NULL) {
cli_err(s, "Unable to expand firmware file path: \"%s\"", file);
cmd_status = CMD_RET_INVPARAM;
} else {
printf("Flashing firmware from %s...\n", expanded_path);
lib_status = bladerf_flash_firmware(s->dev, expanded_path);
if (lib_status < 0) {
s->last_lib_error = lib_status;
cmd_status = CMD_RET_LIBBLADERF;
} else {
printf("Done. Cycle power on the device.\n");
}
free(expanded_path);
}
return cmd_status;
}
开发者ID:kaysin,项目名称:bladeRF,代码行数:25,代码来源:load.c
示例6: load_fpga
static int load_fpga(struct cli_state *s, char *file)
{
char *expanded_path;
int cmd_status = 0;
int lib_status;
if ((expanded_path = interactive_expand_path(file)) == NULL) {
cli_err(s, "Unable to expand FPGA file path: \"%s\"", file);
cmd_status = CMD_RET_INVPARAM;
} else {
printf("Loading fpga from %s...\n", expanded_path);
lib_status = bladerf_load_fpga(s->dev, expanded_path);
if (lib_status < 0) {
s->last_lib_error = lib_status;
cmd_status = CMD_RET_LIBBLADERF;
} else {
printf("Done.\n");
}
free(expanded_path);
}
return cmd_status;
}
开发者ID:kaysin,项目名称:bladeRF,代码行数:25,代码来源:load.c
示例7: stat_root
static bool stat_root(struct client *cli)
{
GList *content = NULL;
char *str;
bool rcb;
if (asprintf(&str,
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n"
"<html>\r\n"
" <head> <title>Status</title> </head>\r\n"
" <body>\r\n") < 0)
goto out_err;
content = g_list_append(content, str);
if (!stat_status(cli, content))
goto out_err;
if (!stor_status(cli, content))
goto out_err;
if (!rep_status(cli, content))
goto out_err;
if (asprintf(&str,
" </body>\r\n"
"</html>\r\n") < 0)
goto out_err;
content = g_list_append(content, str);
rcb = cli_resp_html(cli, 200, content);
g_list_free(content);
return rcb;
out_err:
strlist_free(content);
return cli_err(cli, InternalError);
}
开发者ID:jgarzik,项目名称:tabled,代码行数:35,代码来源:status.c
示例8: rxtx_cmd_start_check
int rxtx_cmd_start_check(struct cli_state *s, struct rxtx_data *rxtx,
const char *argv0)
{
int status = CLI_RET_UNKNOWN;
bool have_file;
if (rxtx_get_state(rxtx) != RXTX_STATE_IDLE) {
return CLI_RET_STATE;
} else {
MUTEX_LOCK(&rxtx->file_mgmt.file_meta_lock);
have_file = (rxtx->file_mgmt.path != NULL);
MUTEX_UNLOCK(&rxtx->file_mgmt.file_meta_lock);
if (!have_file) {
cli_err(s, argv0, "File not configured\n");
status = CLI_RET_INVPARAM;
} else {
status = validate_stream_params(s, rxtx, argv0);
}
if (status == 0) {
check_samplerate(s, rxtx);
}
}
return status;
}
开发者ID:HKingz,项目名称:bladeRF,代码行数:27,代码来源:rxtx.c
示例9: check_samplerate
/* Require a 10% margin on the sample rate to ensure we can keep up, and
* warn if this margin is violated
*/
static void check_samplerate(struct cli_state *s, struct rxtx_data *rxtx)
{
int status;
uint64_t samplerate_min; /* Min required sample rate */
unsigned int samplerate_dev; /* Device's current sample rate */
unsigned int n_xfers, samp_per_buf;
pthread_mutex_lock(&rxtx->data_mgmt.lock);
n_xfers = (unsigned int)rxtx->data_mgmt.num_transfers;
samp_per_buf = (unsigned int)rxtx->data_mgmt.samples_per_buffer;
pthread_mutex_unlock(&rxtx->data_mgmt.lock);
samplerate_min = (uint64_t)n_xfers * samp_per_buf;
samplerate_min += (samplerate_min + 9) / 10;
status = bladerf_get_sample_rate(s->dev, rxtx->module, &samplerate_dev);
if (status < 0) {
cli_err(s, "Error", "Failed read device's current sample rate. "
"Unable to perform sanity check.");
} else if (samplerate_dev < samplerate_min) {
if (samplerate_min <= 40000000) {
printf("\n Warning: The current sample rate may be too low. "
"For %u transfers and\n"
" %u samples per buffer, a sample rate >= %"
PRIu64" Hz is\n recommended to avoid timeouts.\n\n",
n_xfers, samp_per_buf, samplerate_min);
} else {
printf("\n Warning: The current configuraion with %u transfers and"
"%u samples per buffer requires a sample rate above 40MHz.\n"
"Timeouts will likely occur with these settings.\n",
n_xfers, samp_per_buf);
}
}
}
开发者ID:DanielG,项目名称:bladeRF,代码行数:37,代码来源:rxtx.c
示例10: object_del
bool object_del(struct client *cli)
{
int rc;
enum chunk_errcode err = che_InternalError;
bool rcb;
struct chunksrv_resp *resp = NULL;
resp = malloc(sizeof(*resp));
if (!resp) {
cli->state = evt_dispose;
return true;
}
resp_init_req(resp, &cli->creq);
rcb = fs_obj_delete(cli->table_id, cli->user,
cli->key, cli->key_len, &err);
if (!rcb)
return cli_err(cli, err, true);
rc = cli_writeq(cli, resp, sizeof(*resp), cli_cb_free, resp);
if (rc) {
free(resp);
return true;
}
return cli_write_start(cli);
}
开发者ID:henrich,项目名称:hail,代码行数:28,代码来源:object.c
示例11: cmd_load
int cmd_load(struct cli_state *state, int argc, char **argv)
{
/* Valid commands:
load fpga <filename>
load fx3 <filename>
*/
int rv = CMD_RET_OK ;
if (!cli_device_is_opened(state)) {
return CMD_RET_NODEV;
} else if (cli_device_is_streaming(state)) {
return CMD_RET_BUSY;
}
if ( argc == 3 ) {
if( strcasecmp( argv[1], "fpga" ) == 0 ) {
rv = load_fpga(state, argv[2]);
} else if( strcasecmp( argv[1], "fx3" ) == 0 ) {
rv = load_fx3(state, argv[2]);
} else {
cli_err(state, argv[0],
"\"%s\" is not a valid programming target\n", argv[1]) ;
rv = CMD_RET_INVPARAM;
}
} else {
rv = CMD_RET_NARGS;
}
return rv;
}
开发者ID:kaysin,项目名称:bladeRF,代码行数:30,代码来源:load.c
示例12: handle_tx_param
static int handle_tx_param(struct cli_state *s,
const char *param, const char *value)
{
bool ok = false;
unsigned int tmp_uint;
if (!strcasecmp(RXTX_PARAM_REPEAT, param)) {
tmp_uint = str2uint(value, 0, UINT_MAX, &ok);
if (ok) {
s->rxtx_data->tx.repeat = tmp_uint;
}
} else if (!strcasecmp(RXTX_PARAM_REPEATDLY, param)) {
tmp_uint = str2uint(value, 0, UINT_MAX, &ok);
if (ok) {
s->rxtx_data->tx.repeat_delay = tmp_uint;
}
}
if (!ok) {
cli_err(s, "tx", RXTX_ERRMSG_VALUE(param, value));
return CMD_RET_INVPARAM;
} else {
return 0;
}
}
开发者ID:lunixbochs,项目名称:bladeRF,代码行数:26,代码来源:rxtx.c
示例13: cmd_recover
/* Usage:
* recover <devinfo> <FX3 firmware>
* recover
*/
int cmd_recover(struct cli_state *state, int argc, char **argv)
{
int status;
const char *expanded_path;
bool ok;
uint8_t bus, addr;
if (argc == 1) {
return list_bootloader_devs(state);
} else if (argc != 4) {
return CMD_RET_NARGS;
}
bus = str2uint(argv[1], 0, UINT8_MAX, &ok);
if (!ok) {
cli_err(state, argv[0], "Invalid bus: %s\n", bus);
return CMD_RET_INVPARAM;
}
addr = str2uint(argv[2], 0, UINT8_MAX, &ok);
if (!ok) {
cli_err(state, argv[0], "Invalid address: %s\n", addr);
return CMD_RET_INVPARAM;
}
if ((expanded_path = interactive_expand_path(argv[3])) == NULL) {
cli_err(state,
"Unable to expand FX3 firmware file path: \"%s\"", argv[2]);
return CMD_RET_INVPARAM;
}
status = perform_recovery(state, bus, addr, expanded_path);
if (status == 0) {
printf("\n");
printf("Success! Use \"open\" to switch to this device.\n");
printf("Note that a \"load fx3 <firmware>\" is required to "
"write the firmware to flash.\n");
printf("\n");
return CMD_RET_OK;
} else if (status == CMD_RET_NODEV) {
printf("No devices in bootloader mode were found.\n");
return CMD_RET_OK;
} else {
return status;
}
}
开发者ID:chenjiefeng,项目名称:bladeRF,代码行数:51,代码来源:recover.c
示例14: cmd_probe
/* Todo move to cmd_probe.c */
int cmd_probe(struct cli_state *s, int argc, char *argv[])
{
struct bladerf_devinfo *devices = NULL;
int n_devices, i;
n_devices = bladerf_get_device_list(&devices);
if (n_devices < 0) {
if (n_devices == BLADERF_ERR_NODEV) {
cli_err(s, argv[0], "No devices found.");
} else {
cli_err(s, argv[0], "Failed to probe for devices: %s",
bladerf_strerror(n_devices));
}
s->last_lib_error = n_devices;
return CLI_RET_LIBBLADERF;
}
printf("\n");
for (i = 0; i < n_devices; i++) {
printf(" Backend: %s\n", backend2str(devices[i].backend));
/* printf(" Serial: 0x%016lX\n", devices[i].serial); */
/* TODO: Fix OTP support for serial readback! */
printf(" Serial: %s\n", devices[i].serial);
printf(" USB Bus: %d\n", devices[i].usb_bus);
printf(" USB Address: %d\n", devices[i].usb_addr);
/*printf(" Firmware: v%d.%d\n", devices[i].fw_ver_maj,
devices[i].fw_ver_min);
if (devices[i].fpga_configured) {
printf(" FPGA: v%d.%d\n",
devices[i].fpga_ver_maj, devices[i].fpga_ver_min);
} else {
printf(" FPGA: not configured\n");
}*/
printf("\n");
}
if (devices) {
assert(n_devices != 0);
bladerf_free_device_list(devices);
}
return 0;
}
开发者ID:DINKIN,项目名称:bladeRF,代码行数:47,代码来源:probe.c
示例15: rx_cmd_config
static int rx_cmd_config(struct cli_state *s, int argc, char **argv)
{
int i;
char *val;
int status;
struct rx_params *rx_params = s->rx->params;
assert(argc >= 2);
if (argc == 2) {
rx_print_config(s->rx);
return 0;
}
for (i = 2; i < argc; i++) {
status = rxtx_handle_config_param(s, s->rx, argv[0], argv[i], &val);
if (status < 0) {
return status;
} else if (status == 0) {
if (!strcasecmp("n", argv[i])) {
/* Configure number of samples to receive */
unsigned int n;
bool ok;
n = str2uint_suffix(val, 0, UINT_MAX, rxtx_kmg_suffixes,
(int)rxtx_kmg_suffixes_len, &ok);
if (ok) {
pthread_mutex_lock(&s->rx->param_lock);
rx_params->n_samples = n;
pthread_mutex_unlock(&s->rx->param_lock);
} else {
cli_err(s, argv[0], RXTX_ERRMSG_VALUE(argv[1], val));
return CMD_RET_INVPARAM;
}
} else {
cli_err(s, argv[0], "Unrecognized command: %s", argv[1]);
return CMD_RET_INVPARAM;
}
}
}
return 0;
}
开发者ID:amberadams,项目名称:bladeRF,代码行数:46,代码来源:rx.c
示例16: write_image
static int write_image(struct cli_state *s, struct params *p, const char *argv0)
{
int status;
FILE *f;
long data_size;
struct bladerf_image *image = NULL;
f = expand_and_open(p->data_file, "rb");
if (!f) {
return CMD_RET_FILEOP;
}
if (fseek(f, 0, SEEK_END) != 0) {
status = CMD_RET_FILEOP;
goto write_image_out;
}
data_size = ftell(f);
if (data_size < 0) {
status = CMD_RET_FILEOP;
goto write_image_out;
}
if ((uint32_t)data_size > p->max_length) {
status = CMD_RET_INVPARAM;
cli_err(s, argv0, "The provided data file is too large for the specified flash region.");
goto write_image_out;
}
if (fseek(f, 0, SEEK_SET) != 0) {
status = CMD_RET_FILEOP;
goto write_image_out;
}
image = bladerf_alloc_image(p->type, p->address, data_size);
if (!image) {
status = CMD_RET_MEM;
goto write_image_out;
}
if (fread(image->data, 1, data_size, f) != (size_t)data_size) {
status = CMD_RET_FILEOP;
goto write_image_out;
}
memcpy(image->serial, p->serial, BLADERF_SERIAL_LENGTH - 1);
status = bladerf_image_write(image, p->img_file);
if (status != 0) {
s->last_lib_error = status;
status = CMD_RET_LIBBLADERF;
}
write_image_out:
fclose(f);
bladerf_free_image(image);
return status;
}
开发者ID:kaysin,项目名称:bladeRF,代码行数:58,代码来源:flash_image.c
示例17: cli_start_tasks
int cli_start_tasks(struct cli_state *s)
{
int status;
status = rxtx_startup(cli_state, BLADERF_MODULE_RX);
if (status != 0) {
cli_err(s, "Error", "Failed to start RX task.\n");
return CLI_RET_UNKNOWN;
}
status = rxtx_startup(cli_state, BLADERF_MODULE_TX);
if (status != 0) {
cli_err(s, "Error", "Failed to start TX task.\n");
return CLI_RET_UNKNOWN;
}
return 0;
}
开发者ID:anew5tart,项目名称:bladeRF,代码行数:18,代码来源:common.c
示例18: cmd_probe
/* Todo move to cmd_probe.c */
int cmd_probe(struct cli_state *s, int argc, char *argv[])
{
bool error_on_no_dev = false;
struct bladerf_devinfo *devices = NULL;
int n_devices, i;
n_devices = bladerf_get_device_list(&devices);
if (argc > 1 && !strcasecmp(argv[1], "strict")) {
error_on_no_dev = true;
}
if (n_devices < 0) {
if (n_devices == BLADERF_ERR_NODEV) {
cli_err(s, argv[0], "No devices found.\n");
if (error_on_no_dev) {
return CLI_RET_CMD_HANDLED;
} else {
return 0;
}
} else {
cli_err(s, argv[0], "Failed to probe for devices: %s\n",
bladerf_strerror(n_devices));
s->last_lib_error = n_devices;
return CLI_RET_LIBBLADERF;
}
}
putchar('\n');
for (i = 0; i < n_devices; i++) {
printf(" Backend: %s\n", backend2str(devices[i].backend));
printf(" Serial: %s\n", devices[i].serial);
printf(" USB Bus: %d\n", devices[i].usb_bus);
printf(" USB Address: %d\n", devices[i].usb_addr);
putchar('\n');
}
if (devices) {
assert(n_devices != 0);
bladerf_free_device_list(devices);
}
return 0;
}
开发者ID:ryankurte,项目名称:bladeRF,代码行数:45,代码来源:probe.c
示例19: cmd_mimo
int cmd_mimo(struct cli_state *state, int argc, char **argv)
{
int status = 0;
if (argc != 2) {
return CLI_RET_NARGS;
}
if (!strcasecmp(argv[1], "slave")) {
status = bladerf_si5338_write(state->dev, 6, 4);
if (status != 0) {
goto out;
}
status |= bladerf_si5338_write(state->dev, 28, 0x2b);
if (status != 0) {
goto out;
}
status |= bladerf_si5338_write(state->dev, 29, 0x28);
if (status != 0) {
goto out;
}
status |= bladerf_si5338_write(state->dev, 30, 0xa8);
if (status != 0) {
goto out;
}
printf("\n Successfully set device to slave MIMO mode.\n\n");
} else if (!strcmp(argv[1], "master")) {
status |= bladerf_si5338_write(state->dev, 39, 1);
if (status != 0) {
goto out;
}
status |= bladerf_si5338_write(state->dev, 34, 0x22);
if (status != 0) {
goto out;
}
printf("\n Successfully set device to master MIMO mode.\n\n");
} else {
cli_err(state, argv[0], "Invalid mode: %s\n", argv[1]);
}
out:
if (status != 0) {
state->last_lib_error = status;
status = CLI_RET_LIBBLADERF;
}
return status;
}
开发者ID:anew5tart,项目名称:bladeRF,代码行数:55,代码来源:mimo.c
示例20: validate_config
static int validate_config(struct cli_state *s, const char *cmd,
struct rxtx_data *d, bool is_tx)
{
int status = CMD_RET_OK;
struct common_cfg *common = is_tx ? &d->tx.common : &d->rx.common;
bool file_path_set;
pthread_mutex_lock(&common->file_lock);
file_path_set = common->file_path != NULL;
pthread_mutex_unlock(&common->file_lock);
if (!file_path_set) {
cli_err(s, cmd, "File parameter has not been configured");
status = CMD_RET_INVPARAM;
} else if (common->file_fmt == RXTX_FMT_INVALID) {
cli_err(s, cmd, "File format parameter has not been configured");
status = CMD_RET_INVPARAM;
}
return status;
}
开发者ID:lunixbochs,项目名称:bladeRF,代码行数:21,代码来源:rxtx.c
注:本文中的cli_err函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论