Commit e63c05d6 authored by Adam Wujek's avatar Adam Wujek

tools/ppsi_conf: support change of alpha

Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent cc101d87
......@@ -14,6 +14,9 @@
#define PPSIEXP_PARAM_PRIORITY1_CMD 1
#define PPSIEXP_PARAM_PRIORITY2_CMD 2
/* Commands for ppsiexp_update_param64_cmd */
#define PPSIEXP_PARAM64_ALPHA_CMD 1
/* Export structures, shared by server and client for argument matching */
#ifdef PPSI_EXPORT_STRUCTURES
......@@ -38,6 +41,16 @@ struct minipc_pd ppsiexp_update_param_cmd = {
},
};
struct minipc_pd ppsiexp_update_param64_cmd = {
.name = "params64",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), /* Command/parameter */
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT64, int64_t), /* New value */
MINIPC_ARG_END,
},
};
#endif /* PPSI_EXPORT_STRUCTURES */
#endif /* __PPSI_EXPORTS_H */
......@@ -89,6 +89,44 @@ static int update_param_cmd(const struct minipc_pd *pd, uint32_t *args,
return 0;
}
static int update_param64_cmd(const struct minipc_pd *pd, uint32_t *args,
void *ret)
{
int rval = PPSIEXP_RET_OK;
int param_type = args[0];
int64_t param_val = *((int64_t *)&args[1]);
switch (param_type) {
case PPSIEXP_PARAM64_ALPHA_CMD:
printf("%s: cmd %d (PPSIEXP_PARAM64_ALPHA_CMD) value %lld\n",
__func__, param_type, param_val);
{
struct pp_instance *ppi;
int i;
for (i = 0; i < get_numberPorts(GDSDEF(ppg_local)); i++) {
ppi = INST(ppg_local, i);
ppi->asymmetryCorrectionPortDS.scaledDelayCoefficient =
param_val;
ppi->portDS->delayAsymCoeff =
pp_servo_calculateDelayAsymCoefficient(
ppi->asymmetryCorrectionPortDS.scaledDelayCoefficient);
}
}
break;
default:
printf("%s: not found cmd %d value %lld\n",
__func__, param_type, param_val);
rval = PPSIEXP_RET_ERROR_CMD;
break;
}
*(int *)ret = rval;
return 0;
}
/* To be called at startup, right after the creation of server channel */
void wrs_init_ipcserver(struct pp_globals *ppg, struct minipc_ch *ppsi_ch)
......@@ -96,7 +134,9 @@ void wrs_init_ipcserver(struct pp_globals *ppg, struct minipc_ch *ppsi_ch)
ppg_local = ppg;
__rpcdef_cmd.f = export_cmd;
ppsiexp_update_param_cmd.f = update_param_cmd;
ppsiexp_update_param64_cmd.f = update_param64_cmd;
minipc_export(ppsi_ch, &__rpcdef_cmd);
minipc_export(ppsi_ch, &ppsiexp_update_param_cmd);
minipc_export(ppsi_ch, &ppsiexp_update_param64_cmd);
}
......@@ -25,6 +25,7 @@ static struct minipc_ch *ptp_ch;
enum input_arg {
arg_help = 'Z' + 1, /* avoid conflicts with short options */
arg_alpha,
arg_prio1,
arg_prio2,
arg_tracking,
......@@ -33,6 +34,7 @@ enum input_arg {
static struct option long_opts[] = {
{"help", no_argument, NULL, arg_help},
{"alpha", required_argument, NULL, arg_alpha},
{"prio1", required_argument, NULL, arg_prio1},
{"priority1", required_argument, NULL, arg_prio1},
{"prio2", required_argument, NULL, arg_prio2},
......@@ -51,6 +53,8 @@ void help(char *prgname)
" -h|--help - print help\n"
" -v|--verbose - verbose output\n"
"Global parameters:\n"
" --alpha=<alpha64bit>\n"
" - change the currently used alpha\n"
" --prio1=<num>\n"
" --priority1=<num> - set priority 1 to <num>\n"
" --prio2=<num>\n"
......@@ -101,6 +105,17 @@ static int ppsi_set_param(int param, int val) {
return rval;
}
static int ppsi_set_param64(int param, int64_t val64) {
int rval = 0;
printf("%s: set param %d val %lld\n", __func__, param, val64);
minipc_call(ptp_ch, MINIPC_TIMEOUT, &ppsiexp_update_param64_cmd, &rval,
param, val64);
return rval;
}
int main(int argc, char *argv[])
{
int opt;
......@@ -143,6 +158,19 @@ int main(int argc, char *argv[])
while ((opt = getopt_long(argc, argv, "vh", long_opts, NULL)) != -1) {
switch (opt) {
case arg_alpha:
if (verbose)
printf("Setting alpha to %lld\n",
atoll(optarg));
ret = ppsi_set_param64(PPSIEXP_PARAM64_ALPHA_CMD,
atoll(optarg));
if (ret) {
fprintf(stderr, "Error setting alpha to %lld\n",
atoll(optarg));
exit (1);
}
break;
case arg_prio1:
tmp = atoi(optarg);
if (verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment