cake
/
p7utils
Archived
1
0
Fork 0

Adapted for libp7 4.0-indev

This commit is contained in:
Thomas Touhey 2017-02-08 14:04:11 +01:00
parent ab877f2a39
commit 9bff06d2f1
13 changed files with 54 additions and 80 deletions

View File

@ -21,8 +21,8 @@
LICENSE := GPLv2
# Project version.
MAJOR := 3
MINOR := 1
MAJOR := 4
MINOR := 0
INDEV := y
# Project version string.

View File

@ -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 |

View File

@ -51,11 +51,12 @@ value next to them.
Display command/subcommand help page and quit.
*-v, --version*::
Display version and quit.
*--com <port>*::
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 <device>*::
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*::

View File

@ -43,11 +43,12 @@ value next to them.
Display command/subcommand help page and quit.
*-v, --version*::
Display version and quit.
*--com <port>*::
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 <device>*::
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 <path>*::

View File

@ -30,11 +30,12 @@ value next to them.
Display help page and quit.
*-v, --version*::
Display version and quit.
*--com <port>*::
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 <device>*::
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).

View File

@ -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 <fls0>] [--com <port>]\n"
" [--storage <fls0>] [--com <device>]\n"
" <subcommand> [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 <port> 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 <device> 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 <abc0> 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];

View File

@ -10,6 +10,7 @@
#include "main.h"
#include <stdlib.h>
#include <string.h>
#include <libp7/stream.h>
/* ************************************************************************** */
/* 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:

View File

@ -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 */

View File

@ -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 <port>]\n"
"Usage: " QUOTE(BIN) " [--version|-v] [--help|-h] [--com <device>]\n"
" [--no-prepare] [--uexe <path>]\n"
" <subcommand> [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 <port> 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 <device> 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 <path> 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);

View File

@ -28,7 +28,8 @@ typedef struct {
int menu;
/* communication and tweaks */
int com, noprepare;
const char *com;
int noprepare;
FILE *uexe;
/* others */

View File

@ -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 <port>]\n"
" [--com <device>]\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 <port> 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 <device> 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;

View File

@ -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);

View File

@ -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 */