Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
0e094a73
Commit
0e094a73
authored
Oct 22, 2019
by
José López Jiménez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrs_spll_tune: new tool to modify the kp/ki constants in runtime from userspace
parent
10bef13d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
209 additions
and
0 deletions
+209
-0
rt_cpu.elf
binaries/rt_cpu.elf
+0
-0
rt_ipc.h
userspace/include/rt_ipc.h
+28
-0
rt_client.c
userspace/libwr/rt_client.c
+24
-0
Makefile
userspace/tools/Makefile
+1
-0
wrs_spll_tune.c
userspace/tools/wrs_spll_tune.c
+156
-0
No files found.
binaries/rt_cpu.elf
View file @
0e094a73
No preview for this file type
userspace/include/rt_ipc.h
View file @
0e094a73
...
...
@@ -120,6 +120,10 @@ int rts_enable_ptracker(int channel, int enable);
/* Enabled/disables phase tracking on a particular port */
int
rts_debug_command
(
int
param
,
int
value
);
int
rts_spll_get_constants
(
int
loop
,
int
param
,
int
value
);
int
rts_spll_set_constants
(
int
loop
,
int
param
,
int
value
);
#ifdef RTIPC_EXPORT_STRUCTURES
static
struct
minipc_pd
rtipc_rts_get_state_struct
=
{
...
...
@@ -179,6 +183,30 @@ static struct minipc_pd rtipc_rts_debug_command_struct = {
},
};
static
struct
minipc_pd
rtipc_rts_spll_set_constants_struct
=
{
.
name
=
"gggg"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
},
};
static
struct
minipc_pd
rtipc_rts_spll_get_constants_struct
=
{
.
name
=
"hhhh"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
},
};
#endif
#endif
userspace/libwr/rt_client.c
View file @
0e094a73
...
...
@@ -125,6 +125,30 @@ int rts_debug_command(int command, int value)
return
rval
;
}
int
rts_spll_set_constants
(
int
loop
,
int
param
,
int
value
)
{
int
rval
;
int
ret
=
minipc_call
(
client
,
RTS_TIMEOUT
,
&
rtipc_rts_spll_set_constants_struct
,
&
rval
,
loop
,
param
,
value
);
if
(
ret
<
0
)
return
ret
;
return
rval
;
}
int
rts_spll_get_constants
(
int
loop
,
int
param
,
int
value
)
{
int
rval
;
int
ret
=
minipc_call
(
client
,
RTS_TIMEOUT
,
&
rtipc_rts_spll_get_constants_struct
,
&
rval
,
loop
,
param
,
value
);
if
(
ret
<
0
)
return
ret
;
return
rval
;
}
int
rts_connect
(
char
*
logfilename
)
{
static
FILE
*
f
;
...
...
userspace/tools/Makefile
View file @
0e094a73
...
...
@@ -10,6 +10,7 @@ TOOLS += wrs_status_led
TOOLS
+=
mkpasswd
TOOLS
+=
wrs_sfp_dump
TOOLS
+=
wrs_throttling
TOOLS
+=
wrs_spll_tune
PPSI_CONFIG
=
../ppsi/include/generated/autoconf.h
WR_INSTALL_ROOT
?=
/usr/lib/white-rabbit
...
...
userspace/tools/wrs_spll_tune.c
0 → 100644
View file @
0e094a73
#include <sys/time.h>
#include <signal.h>
#include <rt_ipc.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#define SPLL_MAIN_LOOP 0
#define SPLL_HELPER_LOOP 1
#define SPLL_KP 0
#define SPLL_KI 1
void
error
(
char
*
msg
)
{
perror
(
msg
);
exit
(
0
);
}
void
printHelp
(
char
*
name
)
{
printf
(
"WRS SoftPLL tune
\n\n
"
);
printf
(
"This tool enables the user to change the proportional and integral constants
\n
"
);
printf
(
"of the SoftPLL helper and main loops.
\n\n
"
);
printf
(
"Usage: %s -s/-g main/helper -c kp/ki -v value
\n
"
,
name
);
exit
(
0
);
}
void
sigintHandler
(
int
sig_num
)
{
exit
(
0
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
c
=
0
;
char
s_loop
[
7
];
char
s_constant
[
3
];
int
set
=
-
1
,
get
=
-
1
;
int
loop
=-
1
,
constant
=-
1
;
int
value
=
-
1
;
int
check_kp
=-
1
,
check_ki
=-
1
;
while
((
c
=
getopt
(
argc
,
argv
,
"hs:g:c:v:"
))
!=
-
1
)
switch
(
c
)
{
case
'h'
:
printHelp
(
argv
[
0
]);
break
;
case
's'
:
set
=
1
;
strcpy
(
s_loop
,
optarg
);
break
;
case
'g'
:
get
=
1
;
strcpy
(
s_loop
,
optarg
);
break
;
case
'c'
:
strcpy
(
s_constant
,
optarg
);
break
;
case
'v'
:
value
=
atoi
(
optarg
);
break
;
case
'?'
:
if
(
optopt
==
's'
||
optopt
==
'g'
)
fprintf
(
stderr
,
"Option -%c requires
\"
main
\"
or
\"
helper
\"
loop to be defined.
\n
"
,
optopt
);
else
if
(
optopt
==
'c'
)
fprintf
(
stderr
,
"Option -%c requires
\"
kp
\"
or
\"
ki
\"
to be defined.
\n
"
,
optopt
);
else
if
(
optopt
==
'v'
)
fprintf
(
stderr
,
"Option -%c requires the value of the constant to be provided."
,
optopt
);
else
if
(
isprint
(
optopt
))
{
fprintf
(
stderr
,
"Unknown option '-%c'.
\n
"
,
optopt
);
printHelp
(
argv
[
0
]);
}
else
{
fprintf
(
stderr
,
"Unknown option character '
\\
x%x'.
\n
"
,
optopt
);
printHelp
(
argv
[
0
]);
}
return
1
;
default:
abort
();
}
if
(
!
strcmp
(
s_loop
,
"helper"
))
{
loop
=
SPLL_HELPER_LOOP
;
}
else
if
(
!
strcmp
(
s_loop
,
"main"
))
{
loop
=
SPLL_MAIN_LOOP
;
}
else
{
fprintf
(
stderr
,
"'main' or 'helper' option must be provided.
\n
"
);
printHelp
(
argv
[
0
]);
}
if
(
get
!=
1
)
{
if
(
!
strcmp
(
s_constant
,
"kp"
))
{
constant
=
SPLL_KP
;
}
else
if
(
!
strcmp
(
s_constant
,
"ki"
))
{
constant
=
SPLL_KI
;
}
else
{
fprintf
(
stderr
,
"'kp' or 'ki' option must be provided.
\n
"
);
printHelp
(
argv
[
0
]);
}
}
if
(
rts_connect
(
NULL
)
<
0
){
printf
(
"Can't connect to the RT subsys
\n
"
);
}
if
(
set
==
1
)
{
rts_spll_set_constants
(
loop
,
constant
,
value
);
do
{
check_kp
=
rts_spll_get_constants
(
loop
,
SPLL_KP
,
0
);
check_ki
=
rts_spll_get_constants
(
loop
,
SPLL_KI
,
0
);
}
while
(
check_ki
==
-
1
||
check_kp
==
-
1
);
usleep
(
100
);
printf
(
"%s constants: kp=%d ki=%d
\n
"
,
s_loop
,
check_kp
,
check_ki
);
return
0
;
}
else
if
(
get
==
1
)
{
do
{
check_kp
=
rts_spll_get_constants
(
loop
,
SPLL_KP
,
0
);
check_ki
=
rts_spll_get_constants
(
loop
,
SPLL_KI
,
0
);
}
while
(
check_ki
==
-
1
||
check_kp
==
-
1
);
usleep
(
100
);
printf
(
"%s constants: kp=%d ki=%d
\n
"
,
s_loop
,
check_kp
,
check_ki
);
return
0
;
}
return
-
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment