Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
b70065ce
Commit
b70065ce
authored
Aug 05, 2021
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
motor-control: add command line options for gpio pins
parent
8116841e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
src/motor-control/src/slave.c
src/motor-control/src/slave.c
+19
-3
No files found.
src/motor-control/src/slave.c
View file @
b70065ce
...
...
@@ -54,6 +54,11 @@ typedef struct main_params {
int
verbose
;
}
main_param_t
;
typedef
struct
gpio_params
{
int
direction_pin
;
int
pulse_pin
;
}
gpio_param_t
;
static
void
process_options
(
int
argc
,
char
*
argv
[]);
static
void
sighand
(
int
sig_num
);
...
...
@@ -61,6 +66,7 @@ static void sighand(int sig_num);
static
main_param_t
main_params
;
static
thread_param_t
thread_params
;
static
gpio_param_t
gpio_params
;
static
ingress_param_t
ingress_params
;
static
ingress_stat_t
ingress_stats
=
{.
min_interval
=
INT_MAX
};
static
enum
TSNTask
tsn_task
;
...
...
@@ -87,6 +93,8 @@ static void help(char *argv[]) {
" -p PRIO RT thread priority
\n
"
" -r USEC non-RT main thread refresh interval
\n
"
" -s NS Common start time reference
\n
"
" -d GPIO Set the gpio pin to be used for motor direction
\n
"
" -u GPIO Set the gpio pin to be used for motor pulse
\n
"
" -x Use AF_XDP sockets
\n
"
" -v Verbose
\n
"
"
\n
"
,
...
...
@@ -287,6 +295,8 @@ int main(int argc, char *argv[]) {
main_params
.
verbose
=
0
;
tsn_task
=
RECV_PACKET_TASK
;
ingress_params
.
tx_buffer_len
=
1024
;
gpio_params
.
direction_pin
=
GPIO_DIRECTION_NUMBER
;
gpio_params
.
pulse_pin
=
GPIO_PULSE_NUMBER
;
// Process bash options
process_options
(
argc
,
argv
);
...
...
@@ -305,8 +315,8 @@ int main(int argc, char *argv[]) {
pthread_mutex_init
(
&
emit_signal_mutex
,
NULL
);
pthread_cond_init
(
&
emit_signal_ts_received
,
NULL
);
gpio_pulse_state
=
enable_gpio
(
&
gpio_pulse_fd
,
GPIO_PULSE_NUMBER
);
gpio_direction_state
=
enable_gpio
(
&
gpio_direction_fd
,
GPIO_DIRECTION_NUMBER
);
gpio_pulse_state
=
enable_gpio
(
&
gpio_pulse_fd
,
gpio_params
.
pulse_pin
);
gpio_direction_state
=
enable_gpio
(
&
gpio_direction_fd
,
gpio_params
.
direction_pin
);
create_thread
(
tsn_thread
);
create_thread
(
emit_signal_thread
);
...
...
@@ -353,7 +363,7 @@ static void process_options(int argc, char *argv[]) {
int
network_if_specified
=
0
;
for
(;;)
{
int
c
=
getopt
(
argc
,
argv
,
"a:s:f:hp:r:vx"
);
int
c
=
getopt
(
argc
,
argv
,
"a:s:f:hp:r:
d:u:
vx"
);
if
(
c
==
-
1
)
break
;
...
...
@@ -378,6 +388,12 @@ static void process_options(int argc, char *argv[]) {
case
'r'
:
main_params
.
refresh_rate
=
atoi
(
optarg
);
break
;
case
'd'
:
gpio_params
.
direction_pin
=
atoi
(
optarg
);
break
;
case
'u'
:
gpio_params
.
pulse_pin
=
atoi
(
optarg
);
break
;
case
'v'
:
main_params
.
verbose
=
1
;
break
;
...
...
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