Commit b70065ce authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

motor-control: add command line options for gpio pins

parent 8116841e
......@@ -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;
......
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