本文整理汇总了C++中param_name函数的典型用法代码示例。如果您正苦于以下问题:C++ param_name函数的具体用法?C++ param_name怎么用?C++ param_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了param_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_to_shmem
/*update value and param's change bit in shared memory*/
void update_to_shmem(param_t param, union param_value_u value)
{
unsigned int byte_changed, bit_changed;
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
PX4_ERR("Could not get shmem lock");
return;
}
shmem_info_p->params_val[param] = value;
byte_changed = param / 8;
bit_changed = 1 << param % 8;
shmem_info_p->krait_changed_index[byte_changed] |= bit_changed;
PX4_DEBUG("set %d bit on krait changed index[%d] to %d", bit_changed, byte_changed,
shmem_info_p->krait_changed_index[byte_changed]);
#ifdef SHMEM_DEBUG
if (param_type(param) == PARAM_TYPE_INT32) {
PX4_INFO("Set value %d for param %s to shmem, set krait index %d:%d",
value.i, param_name(param), byte_changed, bit_changed);
} else if (param_type(param) == PARAM_TYPE_FLOAT) {
PX4_INFO("Set value %f for param %s to shmem, set krait index %d:%d",
(double)value.f, param_name(param), byte_changed, bit_changed);
}
#endif
release_shmem_lock();
}
示例2: update_value_from_shmem
static void update_value_from_shmem(param_t param, union param_value_u *value)
{
unsigned int byte_changed, bit_changed;
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
PX4_ERR("Could not get shmem lock");
return;
}
*value = shmem_info_p->params_val[param];
/*also clear the index since we are holding the lock*/
byte_changed = param / 8;
bit_changed = 1 << param % 8;
shmem_info_p->adsp_changed_index[byte_changed] &= ~bit_changed;
release_shmem_lock();
#ifdef SHMEM_DEBUG
if (param_type(param) == PARAM_TYPE_INT32) {
PX4_INFO(
"Got value %d for param %s from shmem, cleared adsp index %d:%d",
value->i, param_name(param), byte_changed, bit_changed);
} else if (param_type(param) == PARAM_TYPE_FLOAT) {
PX4_INFO(
"Got value %f for param %s from shmem, cleared adsp index %d:%d",
(double)value->f, param_name(param), byte_changed, bit_changed);
}
#endif
}
示例3: copy_params_to_shmem
void copy_params_to_shmem(struct param_info_s *param_info_base)
{
param_t param;
unsigned int i;
if (get_shmem_lock(__FILE__, __LINE__) != 0) {
PX4_ERR("Could not get shmem lock");
return;
}
PX4_DEBUG("%d krait params allocated", param_count());
for (param = 0; param < param_count(); param++) {
struct param_wbuf_s *s = param_find_changed(param);
if (s == NULL) {
shmem_info_p->params_val[param] = param_info_base[param].val;
} else {
shmem_info_p->params_val[param] = s->val;
}
#ifdef SHMEM_DEBUG
if (param_type(param) == PARAM_TYPE_INT32) {
{
PX4_INFO("%d: written %d for param %s to shared mem",
param, shmem_info_p->params_val[param].i, param_name(param));
}
} else if (param_type(param) == PARAM_TYPE_FLOAT) {
{
PX4_INFO("%d: written %f for param %s to shared mem",
param, (double)shmem_info_p->params_val[param].f, param_name(param));
}
}
#endif
}
//PX4_DEBUG("written %u params to shmem offset %lu", param_count(), (unsigned char*)&shmem_info_p->params_count-(unsigned char*)shmem_info_p);
for (i = 0; i < MAX_SHMEM_PARAMS / 8 + 1; i++) {
shmem_info_p->krait_changed_index[i] = 0;
adsp_changed_index[i] = 0;
}
release_shmem_lock();
}
示例4: Slo_GetArgByName
/** Return pointer to shader symbol definition for argument specified by symbol name */
SLO_VISSYMDEF* Slo_GetArgByName ( char* name )
{
std::string param_name(name);
if (slovissymdef_data.find(std::string(name)) == slovissymdef_data.end())
{
SLX_VISSYMDEF* slxdef = SLX_GetArgByName(name);
param_name = slxdef->svd_name;
// convert SLX_VISSYMDEF to SLO_VISSYMDEF
SLO_VISSYMDEF slodef;
initParamStruct(&slodef);
if (SlxLastError == RIE_NOERROR)
{
convertVISSYMDEFStruct (slxdef, &slodef);
}
else
{
return NULL;
}
slovissymdef_data[param_name] = slodef;
// slovissymdef_namemap becomes out of sync here as we don't have an id
// for this param, Slo_GetArgById will catch this
}
return &slovissymdef_data[param_name];
}
示例5: Slo_GetArgById
/** Return pointer to shader symbol definition for argument specified by symbol ID */
SLO_VISSYMDEF* Slo_GetArgById ( int id )
{
// check to see if we have converted this yet
if (slovissymdef_namemap.find(id) == slovissymdef_namemap.end())
{
SLX_VISSYMDEF* slxdef = SLX_GetArgById(id - 1); // SLX_* is 0 based
std::string param_name(slxdef->svd_name);
// catch the case where the namemap might be out of sync because of
// other calls to Slo_GetArgByName which can't update the namemap
if (slovissymdef_data.find(param_name) != slovissymdef_data.end())
{
slovissymdef_namemap[id] = param_name;
return &slovissymdef_data[slovissymdef_namemap[id]];
}
// convert SLX_VISSYMDEF to SLO_VISSYMDEF
SLO_VISSYMDEF slodef;
initParamStruct(&slodef);
if (SlxLastError == RIE_NOERROR) {
convertVISSYMDEFStruct (slxdef, &slodef);
} else {
return NULL;
}
slovissymdef_data[param_name] = slodef;
slovissymdef_namemap[id] = param_name;
}
return &slovissymdef_data[slovissymdef_namemap[id]];
}
示例6: param_reset_excludes
void
param_reset_excludes(const char *excludes[], int num_excludes)
{
param_lock();
param_t param;
for (param = 0; handle_in_range(param); param++) {
const char *name = param_name(param);
bool exclude = false;
for (int index = 0; index < num_excludes; index ++) {
int len = strlen(excludes[index]);
if ((excludes[index][len - 1] == '*'
&& strncmp(name, excludes[index], len - 1) == 0)
|| strcmp(name, excludes[index]) == 0) {
exclude = true;
break;
}
}
if (!exclude) {
param_reset(param);
}
}
param_unlock();
param_notify_changes();
}
示例7: param_get
int
param_get(param_t param, void *val)
{
int result = -1;
param_lock();
if (!handle_in_range(param)) {
return result;
}
union param_value_u value;
if (update_from_shmem(param, &value)) {
set_called_from_get = 1;
param_set_internal(param, &value, true, false, false);
set_called_from_get = 0;
}
const void *v = param_get_value_ptr(param);
if (val != NULL) {
memcpy(val, v, param_size(param));
result = 0;
}
#ifdef ENABLE_SHMEM_DEBUG
if (param_type(param) == PARAM_TYPE_INT32) {
PX4_INFO("param_get for %s : %d\n", param_name(param), ((union param_value_u *)val)->i);
}
else if (param_type(param) == PARAM_TYPE_FLOAT) {
PX4_INFO("param_get for %s : %f\n", param_name(param), (double)((union param_value_u *)val)->f);
}
else {
PX4_INFO("Unknown param type for %s\n", param_name(param));
}
#endif
param_unlock();
return result;
}
示例8: do_show_print
static void
do_show_print(void *arg, param_t param)
{
int32_t i;
float f;
const char *search_string = (const char*)arg;
/* print nothing if search string valid and not matching */
if (arg != NULL && (strcmp(search_string, param_name(param) != 0)))
return;
printf("%c %s: ",
param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'),
param_name(param));
/*
* This case can be expanded to handle printing common structure types.
*/
switch (param_type(param)) {
case PARAM_TYPE_INT32:
if (!param_get(param, &i)) {
printf("%d\n", i);
return;
}
break;
case PARAM_TYPE_FLOAT:
if (!param_get(param, &f)) {
printf("%4.4f\n", (double)f);
return;
}
break;
case PARAM_TYPE_STRUCT ... PARAM_TYPE_STRUCT_MAX:
printf("<struct type %d size %u>\n", 0 + param_type(param), param_size(param));
return;
default:
printf("<unknown type %d>\n", 0 + param_type(param));
return;
}
printf("<error fetching parameter %d>\n", param);
}
示例9: orb_subscribe
bool
MavlinkParametersManager::send_untransmitted()
{
bool sent_one = false;
// Check for untransmitted system parameters
if (_mavlink_parameter_sub < 0) {
_mavlink_parameter_sub = orb_subscribe(ORB_ID(parameter_update));
}
bool param_ready;
orb_check(_mavlink_parameter_sub, ¶m_ready);
if (param_ready) {
// Clear the ready flag
struct parameter_update_s value;
orb_copy(ORB_ID(parameter_update), _mavlink_parameter_sub, &value);
// Schedule an update if not already the case
if (_param_update_time == 0) {
_param_update_time = value.timestamp;
_param_update_index = 0;
}
}
if ((_param_update_time != 0) && ((_param_update_time + 5 * 1000) < hrt_absolute_time())) {
param_t param = 0;
// send out all changed values
do {
// skip over all parameters which are not invalid and not used
do {
param = param_for_index(_param_update_index);
++_param_update_index;
} while (param != PARAM_INVALID && !param_used(param));
// send parameters which are untransmitted while there is
// space in the TX buffer
if ((param != PARAM_INVALID) && param_value_unsaved(param)) {
int ret = send_param(param);
char buf[100];
strncpy(&buf[0], param_name(param), MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN);
sent_one = true;
if (ret != PX4_OK) {
break;
}
}
} while ((_mavlink->get_free_tx_buf() >= get_size()) && (_param_update_index < (int) param_count()));
// Flag work as done once all params have been sent
if (_param_update_index >= (int) param_count()) {
_param_update_time = 0;
}
}
return sent_one;
}
示例10: do_set
static void
do_set(const char* name, const char* val)
{
int32_t i;
float f;
param_t param = param_find(name);
/* set nothing if parameter cannot be found */
if (param == PARAM_INVALID) {
/* param not found */
errx(1, "Error: Parameter %s not found.", name);
}
printf("%c %s: ",
param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'),
param_name(param));
/*
* Set parameter if type is known and conversion from string to value turns out fine
*/
switch (param_type(param)) {
case PARAM_TYPE_INT32:
if (!param_get(param, &i)) {
printf("curr: %d", i);
/* convert string */
char* end;
i = strtol(val,&end,10);
param_set(param, &i);
printf(" -> new: %d\n", i);
}
break;
case PARAM_TYPE_FLOAT:
if (!param_get(param, &f)) {
printf("curr: %4.4f", (double)f);
/* convert string */
char* end;
f = strtod(val,&end);
param_set(param, &f);
printf(" -> new: %4.4f\n", (double)f);
}
break;
default:
errx(1, "<unknown / unsupported type %d>\n", 0 + param_type(param));
}
exit(0);
}
示例11: setPPstyle
void
setPPstyle (ppOption pps, int i, const char *argv)
{
static int setBy = 0;
static const char *setArg = NULL;
if (argv == NULL) {
printf ("Set by arg %d (%-10s), PrettyPrint style = %s\n",
setBy, setArg, getPPStyleStr());
return;
}
// if the style has already been set, and is trying to be reset by default
// rules, override the default (i.e., don't make a change)
if (setBy != 0 && i == 0)
return;
// If -long or -xml or -format are specified, do not reset to
// "normal" style when followed by a flag such as -startd.
if( ppStyle == PP_XML || ppStyle == PP_VERBOSE || ppStyle == PP_CUSTOM )
{
if( pps != PP_XML && pps != PP_VERBOSE && pps != PP_CUSTOM ) {
// ignore this style setting and keep our existing setting
return;
}
}
// If setting a 'normal' output, check to see if there is a user-defined normal output
if ( ! disable_user_print_files && ! explicit_format
&& pps != PP_XML && pps != PP_VERBOSE && pps != PP_CUSTOM && pps != ppStyle) {
MyString param_name("STATUS_DEFAULT_"); param_name += getTypeStr(); param_name += "_PRINT_FORMAT_FILE";
char * pf_file = param(param_name.c_str());
if (pf_file) {
struct stat stat_buff;
if (0 != stat(pf_file, &stat_buff)) {
// do nothing, this is not an error.
} else if (set_status_print_mask_from_stream(pf_file, true) < 0) {
fprintf(stderr, "Warning: default %s select file '%s' is invalid\n", getTypeStr(), pf_file);
} else {
using_print_format = true;
}
free(pf_file);
}
}
if ( (PP_XML == pps) || PP_VERBOSE == pps || (ppStyle <= pps || setBy == 0) ) {
ppStyle = pps;
setBy = i;
setArg = argv;
} else {
fprintf (stderr, "Error: arg %d (%s) contradicts arg %d (%s)\n",
i, argv, setBy, setArg);
exit (1);
}
}
示例12: at_i
static void
at_i(void)
{
switch (at_cmd[3]) {
case '\0':
case '0':
printf("%s\n", g_banner_string);
return;
case '1':
printf("%s\n", g_version_string);
return;
case '2':
printf("%u\n", BOARD_ID);
break;
case '3':
printf("%u\n", g_board_frequency);
break;
case '4':
printf("%u\n", g_board_bl_version);
return;
case '5': {
register enum ParamID id;
register uint8_t start = 0;
register uint8_t end = PARAM_MAX-1;
if (at_cmd[4] == ':' && isdigit(at_cmd[5])) {
idx = 5;
at_parse_number();
start = at_num;
if (at_cmd[idx] == ':' && isdigit(at_cmd[idx+1])) {
idx++;
at_parse_number();
end = at_num;
}
}
// convenient way of showing all parameters
for (id = start; id <= end; id++) {
printf("S%u:%s=%lu\n",
(unsigned)id,
param_name(id),
(unsigned long)param_get(id));
}
return;
}
case '6':
tdm_report_timing();
return;
case '7':
tdm_show_rssi();
return;
default:
at_error();
return;
}
}
示例13: param_type
int Mavlink::mavlink_pm_send_param(param_t param)
{
if (param == PARAM_INVALID) { return 1; }
/* buffers for param transmission */
char name_buf[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN];
float val_buf;
mavlink_message_t tx_msg;
/* query parameter type */
param_type_t type = param_type(param);
/* copy parameter name */
strncpy((char *)name_buf, param_name(param), MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN);
/*
* Map onboard parameter type to MAVLink type,
* endianess matches (both little endian)
*/
uint8_t mavlink_type;
if (type == PARAM_TYPE_INT32) {
mavlink_type = MAVLINK_TYPE_INT32_T;
} else if (type == PARAM_TYPE_FLOAT) {
mavlink_type = MAVLINK_TYPE_FLOAT;
} else {
mavlink_type = MAVLINK_TYPE_FLOAT;
}
/*
* get param value, since MAVLink encodes float and int params in the same
* space during transmission, copy param onto float val_buf
*/
int ret;
if ((ret = param_get(param, &val_buf)) != OK) {
return ret;
}
mavlink_msg_param_value_pack_chan(mavlink_system.sysid,
mavlink_system.compid,
_channel,
&tx_msg,
name_buf,
val_buf,
mavlink_type,
param_count(),
param_get_index(param));
send_message(&tx_msg);
return OK;
}
示例14: do_show_index
static int
do_show_index(const char *index, bool used_index)
{
char *end;
int i = strtol(index, &end, 10);
param_t param;
int32_t ii;
float ff;
if (used_index) {
param = param_for_used_index(i);
} else {
param = param_for_index(i);
}
if (param == PARAM_INVALID) {
PX4_ERR("param not found for index %u", i);
return 1;
}
PARAM_PRINT("index %d: %c %c %s [%d,%d] : ", i, (param_used(param) ? 'x' : ' '),
param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'),
param_name(param), param_get_used_index(param), param_get_index(param));
switch (param_type(param)) {
case PARAM_TYPE_INT32:
if (!param_get(param, &ii)) {
PARAM_PRINT("%ld\n", (long)ii);
}
break;
case PARAM_TYPE_FLOAT:
if (!param_get(param, &ff)) {
PARAM_PRINT("%4.4f\n", (double)ff);
}
break;
default:
PARAM_PRINT("<unknown type %d>\n", 0 + param_type(param));
}
return 0;
}
示例15: param_count_used
int
MavlinkParametersManager::send_param(param_t param)
{
if (param == PARAM_INVALID) {
return 1;
}
mavlink_param_value_t msg;
/*
* get param value, since MAVLink encodes float and int params in the same
* space during transmission, copy param onto float val_buf
*/
if (param_get(param, &msg.param_value) != OK) {
return 2;
}
msg.param_count = param_count_used();
msg.param_index = param_get_used_index(param);
/* copy parameter name */
strncpy(msg.param_id, param_name(param), MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN);
/* query parameter type */
param_type_t type = param_type(param);
/*
* Map onboard parameter type to MAVLink type,
* endianess matches (both little endian)
*/
if (type == PARAM_TYPE_INT32) {
msg.param_type = MAVLINK_TYPE_INT32_T;
} else if (type == PARAM_TYPE_FLOAT) {
msg.param_type = MAVLINK_TYPE_FLOAT;
} else {
msg.param_type = MAVLINK_TYPE_FLOAT;
}
_mavlink->send_message(MAVLINK_MSG_ID_PARAM_VALUE, &msg);
return 0;
}