2019-03-26 14:24:36 -04:00
|
|
|
#include <stdio.h>
|
2019-05-08 07:48:39 -04:00
|
|
|
#include <string.h>
|
2019-03-26 14:24:36 -04:00
|
|
|
#include <unistd.h>
|
2019-04-25 12:47:53 -04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <termios.h>
|
2019-03-26 14:24:36 -04:00
|
|
|
|
|
|
|
#include "image.h"
|
2019-05-21 08:45:47 -04:00
|
|
|
#include "serial_util.h"
|
2019-03-26 14:24:36 -04:00
|
|
|
|
2019-04-25 12:47:53 -04:00
|
|
|
#define DEFAULT_SERIAL_PORT "/dev/ttyUSB0"
|
|
|
|
|
2019-03-26 14:24:36 -04:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
int c;
|
2019-05-01 12:25:19 -04:00
|
|
|
char *speed = NULL;
|
2019-04-25 12:47:53 -04:00
|
|
|
char *serial_port = DEFAULT_SERIAL_PORT;
|
|
|
|
while ((c = getopt(argc, argv, "c:s:")) != -1) {
|
2019-03-26 14:24:36 -04:00
|
|
|
switch (c) {
|
|
|
|
case 'c':
|
|
|
|
serial_port = optarg;
|
2019-04-25 12:47:53 -04:00
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
speed = optarg;
|
2019-03-26 14:24:36 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 08:45:47 -04:00
|
|
|
int serial_fd = serial_init(serial_port, speed);
|
2019-04-25 12:47:53 -04:00
|
|
|
|
2019-03-26 14:24:36 -04:00
|
|
|
uint8_t rem = (uint8_t)(argc - optind);
|
|
|
|
if (rem) {
|
|
|
|
if (strcmp(argv[optind], "image") == 0) {
|
2019-05-02 08:48:43 -04:00
|
|
|
image_main(serial_fd, rem-1, &argv[optind+1]);
|
2019-03-26 14:24:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|