1
0
Fork 0
umcumgr/src/main.c

37 lines
805 B
C
Raw Normal View History

#include <stdio.h>
2019-05-08 07:48:39 -04:00
#include <string.h>
#include <unistd.h>
2019-04-25 12:47:53 -04:00
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
#include "image.h"
#include "serial_util.h"
2019-04-25 12:47:53 -04:00
#define DEFAULT_SERIAL_PORT "/dev/ttyUSB0"
int main(int argc, char **argv) {
int c;
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) {
switch (c) {
case 'c':
serial_port = optarg;
2019-04-25 12:47:53 -04:00
break;
case 's':
speed = optarg;
default:
break;
}
}
int serial_fd = serial_init(serial_port, speed);
2019-04-25 12:47:53 -04:00
uint8_t rem = (uint8_t)(argc - optind);
if (rem) {
if (strcmp(argv[optind], "image") == 0) {
image_main(serial_fd, rem-1, &argv[optind+1]);
}
}
}