diff --git a/Makefile.vars b/Makefile.vars index a6b3719..6921b7e 100755 --- a/Makefile.vars +++ b/Makefile.vars @@ -21,8 +21,8 @@ LICENSE := GPLv2 # Project version. - MAJOR := 3 - MINOR := 1 + MAJOR := 4 + MINOR := 0 INDEV := y # Project version string. diff --git a/README.md b/README.md index 80b859f..3d81b2b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Available utilities are: ### Making and runtime dependencies | Name | Version | | -------------------------------------------------- | --------- | -| [libp7](https://p7.planet-casio.com/en.html) | >= 3.0 | +| [libp7](https://p7.planet-casio.com/en.html) | >= 4.0 | | [libg1m](https://github.com/cakeisalie5/libg1m) | >= 0.1 | | [libsdl](https://libsdl.org/) | == 1.2.15 | diff --git a/doc/p7.1.txt b/doc/p7.1.txt index 0ff3ed6..6cec3fb 100644 --- a/doc/p7.1.txt +++ b/doc/p7.1.txt @@ -51,11 +51,12 @@ value next to them. Display command/subcommand help page and quit. *-v, --version*:: Display version and quit. -*--com *:: - The USB-serial port, if you want to communicate with a calculator connected - using a USB-to-serial cable. (1 to 20) - If this option isn't used, the program will look for a directly connected - USB calculator. +*--com *:: + The serial device, if you want to communicate with a calculator connected + using a USB-to-serial cable. + :: + If this option isn't used, the program will look for a calculator connected + using direct USB. *--storage abc0*:: The storage device with which to interact. *--no-term, --no-exit*:: diff --git a/doc/p7os.1.txt b/doc/p7os.1.txt index 9a50ba4..cef2fb7 100644 --- a/doc/p7os.1.txt +++ b/doc/p7os.1.txt @@ -43,11 +43,12 @@ value next to them. Display command/subcommand help page and quit. *-v, --version*:: Display version and quit. -*--com *:: - The USB-serial port, if you want to communicate with a calculator connected - using a USB-to-serial cable. (1 to 20) - If this option isn't used, the program will look for a directly connected - USB calculator. +*--com *:: + The serial device, if you want to communicate with a calculator connected + using a USB-to-serial cable. + :: + If this option isn't used, the program will look for a calculator connected + using direct USB. *--no-prepare*:: Use the current environment, instead of uploading one. *--uexe *:: diff --git a/doc/p7screen.1.txt b/doc/p7screen.1.txt index 2d19b39..c12010f 100644 --- a/doc/p7screen.1.txt +++ b/doc/p7screen.1.txt @@ -30,11 +30,12 @@ value next to them. Display help page and quit. *-v, --version*:: Display version and quit. -*--com *:: - The USB-serial port, if you want to communicate with a calculator connected - using a USB-to-serial cable. (1 to 20) - If this option isn't used, the program will look for a directly connected - USB calculator. +*--com *:: + The serial device, if you want to communicate with a calculator connected + using a USB-to-serial cable. + :: + If this option isn't used, the program will look for a calculator connected + using direct USB. *-z ZOOM, --zoom=ZOOM*:: Change the zoom (will change the window size too). diff --git a/src/p7/args.c b/src/p7/args.c index be4cbf8..ea470ad 100644 --- a/src/p7/args.c +++ b/src/p7/args.c @@ -30,7 +30,7 @@ QUOTE(BIN) " - from " QUOTE(NAME) " v" QUOTE(VERSION) /* Main help message */ static const char help_main[] = "Usage: " QUOTE(BIN) " [--version|-v] [--help|-h] [--no-init] [--no-exit]\n" -" [--storage ] [--com ]\n" +" [--storage ] [--com ]\n" " [options...]\n" "\n" "Subcommands you can use are:\n" @@ -46,10 +46,10 @@ static const char help_main[] = "General options:\n" " -h, --help Display the help page of the (sub)command and quit.\n" " -v, --version Display the version message and quit.\n" -" --com The USB-serial port, if you want to communicate with a\n" -" calculator connected using a USB-to-serial cable. (1 to 20)\n" +" --com The serial device, if you want to communicate with a\n" +" calculator connected using a USB-to-serial cable.\n" " If this option isn't used, the program will look for a\n" -" directly connected USB calculator.\n" +" calculator connected using direct USB.\n" " --storage The storage device with which to interact (fls0, crd0).\n" " Default storage device is '" QUOTE(DEFAULT_STORAGE) "'.\n" " --no-exit Does not terminate connection when action is completed.\n" @@ -194,7 +194,7 @@ int parse_args(int ac, char **av, args_t *args) /* get all options */ int c; opterr = 0; int help = 0; - const char *s_out = NULL, *s_dir = NULL, *s_todir = NULL, *s_com = NULL; + const char *s_out = NULL, *s_dir = NULL, *s_todir = NULL; while ((c = getopt_long(ac, av, short_options, long_options, NULL)) != -1) { switch (c) { /* help */ @@ -214,7 +214,7 @@ int parse_args(int ac, char **av, args_t *args) case 't': s_todir = optarg; break; /* com port */ - case 'c': s_com = optarg; break; + case 'c': args->com = optarg; break; /* storage */ case 's': args->storage = optarg; break; /* force no initialization */ @@ -241,19 +241,6 @@ int parse_args(int ac, char **av, args_t *args) } } - /* check com port */ - if (s_com) { - if (!isdigit(s_com[0])) { - log("-c, --com: expected a number\n"); - return (0); - } - args->com = atoi(s_com); - if (args->com < 1 || args->com > 20) { - log("-c, --com: COM port number should be between 1 and 20\n"); - return (0); - } - } - /* get non-option arguments (subcommand and parameters) */ int aac = ac - optind; char **aav = &av[optind]; diff --git a/src/p7/main.c b/src/p7/main.c index 4d225e5..a970eff 100644 --- a/src/p7/main.c +++ b/src/p7/main.c @@ -10,6 +10,7 @@ #include "main.h" #include #include +#include /* ************************************************************************** */ /* Error messages */ @@ -210,6 +211,14 @@ int main(int ac, char **av) return (1); } + /* Try faster serial */ + /*if ((err = p7_setlink(handle, P7_B19200, P7_PARITY_NONE, P7_TWOSTOPBITS)) + && err != p7_error_unsupported) { + log(error_unplanned, p7_strerror(err)); + p7_exit(handle); + return (1); + }*/ + /* Check according to menu */ switch (args.menu) { case mn_send: diff --git a/src/p7/main.h b/src/p7/main.h index ac7be2b..db14863 100644 --- a/src/p7/main.h +++ b/src/p7/main.h @@ -35,7 +35,8 @@ typedef struct { /* other options */ unsigned int initflags; - int com; const char *storage; + const char *com; + const char *storage; } args_t; /* Parsing function */ diff --git a/src/p7os/args.c b/src/p7os/args.c index 9ceb74a..6e439c2 100644 --- a/src/p7os/args.c +++ b/src/p7os/args.c @@ -28,7 +28,7 @@ QUOTE(BIN) " - from " QUOTE(NAME) " v" QUOTE(VERSION) " (licensed under GPLv2)\n /* Main help message */ static const char help_main[] = -"Usage: " QUOTE(BIN) " [--version|-v] [--help|-h] [--com ]\n" +"Usage: " QUOTE(BIN) " [--version|-v] [--help|-h] [--com ]\n" " [--no-prepare] [--uexe ]\n" " [options...]\n" "\n" @@ -40,10 +40,10 @@ static const char help_main[] = "General options:\n" " -h, --help Display the help page of the (sub)command and quit.\n" " -v, --version Display the version message and quit.\n" -" --com The USB-serial port, if you want to communicate with a\n" -" calculator connected using a USB-to-serial cable. (1 to 20)\n" +" --com The serial device, if you want to communicate with a\n" +" calculator connected using a USB-to-serial cable.\n" " If this option isn't used, the program will look for a\n" -" directly connected USB calculator.\n" +" calculator connected using direct USB.\n" " --no-prepare Use the current environment, instead of uploading one.\n" " --uexe Use a custom update program.\n" "\n" @@ -119,14 +119,14 @@ int parse_args(int ac, char **av, args_t *args) /* get all options */ int c; opterr = 0; int help = 0, version = 0; - const char *s_out = "os.bin", *s_com = 0, *s_uexe = NULL; + const char *s_out = "os.bin", *s_uexe = NULL; while ((c = getopt_long(ac, av, shopts, longopts, NULL)) != -1) switch (c) { /* help */ case 'h': help = 1; break; /* version */ case 'v': version = 1; break; /* com port */ - case 'c': s_com = optarg; break; + case 'c': args->com = optarg; break; /* no prepare */ case 'n': args->noprepare = 1; break; /* uexe */ @@ -183,19 +183,6 @@ int parse_args(int ac, char **av, args_t *args) return (1); } - /* check com port */ - if (s_com) { - if (!isdigit(s_com[0])) { - log("-c, --com: expected a number\n"); - return (0); - } - args->com = atoi(s_com); - if (args->com < 1 || args->com > 20) { - log("-c, --com: COM port number should be between 1 and 20\n"); - return (0); - } - } - /* open destination file */ if (args->localpath) { args->local = fopen(args->localpath, fpmode); diff --git a/src/p7os/main.h b/src/p7os/main.h index 733ab86..9037ce3 100644 --- a/src/p7os/main.h +++ b/src/p7os/main.h @@ -28,7 +28,8 @@ typedef struct { int menu; /* communication and tweaks */ - int com, noprepare; + const char *com; + int noprepare; FILE *uexe; /* others */ diff --git a/src/p7screen/args.c b/src/p7screen/args.c index 2f6a55a..1f923ee 100644 --- a/src/p7screen/args.c +++ b/src/p7screen/args.c @@ -27,17 +27,17 @@ QUOTE(BIN) " - from " QUOTE(NAME) " v" QUOTE(VERSION) " (licensed under GPLv2)\n /* Help message */ static const char help_main[] = "Usage: " QUOTE(BIN) " [--help|-h] [--version|-v]\n" -" [--com ]\n" +" [--com ]\n" "\n" "Displays the streamed screen from a CASIO fx calculator.\n" "\n" "Options are:\n" " -h, --help Display this help page\n" " -v, --version Displays the version\n" -" --com The USB-serial port, if you want to communicate with a\n" -" calculator connected using a USB-to-serial cable. (1 to 20)\n" +" --com The serial device, if you want to communicate with a\n" +" calculator connected using a USB-to-serial cable.\n" " If this option isn't used, the program will look for a\n" -" directly connected USB calculator.\n" +" calculator connected using direct USB.\n" " -z ZOOM Change the zoom (1 to 16)\n" " By default, the zoom will be " QUOTE(DEFAULT_ZOOM) ".\n" "\n" @@ -61,7 +61,7 @@ static const char help_main[] = * @return 0 if ok, other if not. */ -int parse_args(int ac, char **av, int *com, int *zoom) +int parse_args(int ac, char **av, const char **com, int *zoom) { /* initialize args */ *com = 0; @@ -80,7 +80,6 @@ int parse_args(int ac, char **av, int *com, int *zoom) /* get all options */ int c; opterr = 0; int help = 0, version = 0; - const char *s_com = NULL; while ((c = getopt_long(ac, av, short_options, long_options, NULL)) != -1) { switch (c) { /* help */ @@ -88,7 +87,7 @@ int parse_args(int ac, char **av, int *com, int *zoom) /* version */ case 'v': version = 1; break; /* com port */ - case 'c': s_com = optarg; break; + case 'c': *com = optarg; break; /* zoom */ case 'z': *zoom = atoi(optarg); @@ -110,19 +109,6 @@ int parse_args(int ac, char **av, int *com, int *zoom) } } - /* check com port */ - if (s_com) { - if (!isdigit(s_com[0])) { - log("-c, --com: expected a number\n"); - return (0); - } - *com = atoi(s_com); - if (*com < 1 || *com > 20) { - log("-c, --com: COM port number should be between 1 and 20\n"); - return (0); - } - } - /* check if there is any parameter */ if (ac - optind) help = 1; diff --git a/src/p7screen/main.c b/src/p7screen/main.c index e89a17c..f6b2542 100644 --- a/src/p7screen/main.c +++ b/src/p7screen/main.c @@ -122,7 +122,7 @@ static int display_callback(int w, int h, uint32_t **pixels) int main(int ac, char **av) { /* parse args */ - int com; + const char *com; if (parse_args(ac, av, &com, &zoom)) return (0); diff --git a/src/p7screen/main.h b/src/p7screen/main.h index 0fe964a..68c9f9f 100644 --- a/src/p7screen/main.h +++ b/src/p7screen/main.h @@ -15,6 +15,6 @@ # define log(S, ...) fprintf(stderr, S, ##__VA_ARGS__) /* all functions */ -int parse_args(int ac, char **av, int *com, int *zoom); +int parse_args(int ac, char **av, const char **com, int *zoom); #endif /* MAIN_H */