Adapted to new lib version.
This commit is contained in:
parent
4e33cf4e98
commit
3f46c7a7c1
|
@ -30,15 +30,10 @@ value next to them.
|
|||
Display help page and quit.
|
||||
*-v, --version*::
|
||||
Display version and quit.
|
||||
*--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).
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*p7*(1),
|
||||
*libp7*(3)
|
||||
|
|
|
@ -191,7 +191,8 @@ int main(int ac, char **av)
|
|||
|
||||
/* Initialize libp7 and communication */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if (args.com) err = p7_cominit(&handle, args.initflags, args.com);
|
||||
if (args.com) err = p7_cominit(&handle, args.initflags, args.com,
|
||||
&p7_default_settings);
|
||||
else err = p7_init(&handle, args.initflags);
|
||||
if (err) {
|
||||
/* display error */
|
||||
|
|
|
@ -114,7 +114,8 @@ int main(int ac, char **av)
|
|||
|
||||
/* Initialize libp7 and communication */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com,
|
||||
&p7_default_settings);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) goto fail;
|
||||
|
||||
|
@ -139,7 +140,8 @@ int main(int ac, char **av)
|
|||
sleep(1);
|
||||
|
||||
/* re-open the handle */
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com);
|
||||
if (args.com) err = p7_cominit(&handle, initflags, args.com,
|
||||
&p7_default_settings);
|
||||
else err = p7_init(&handle, initflags);
|
||||
if (err) {
|
||||
p7_exit(handle);
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
/* ************************************************************************** */
|
||||
/* Embedded update.exe */
|
||||
/* ************************************************************************** */
|
||||
#define cake_exe_str (_binary_cake_exe_bin_start)
|
||||
#define cake_exe_end (_binary_cake_exe_bin_end)
|
||||
#define cake_exe_str ((char*)&_binary_cake_exe_bin_start)
|
||||
#define cake_exe_end ((char*)&_binary_cake_exe_bin_end)
|
||||
extern char _binary_cake_exe_bin_start[];
|
||||
extern char _binary_cake_exe_bin_end[];
|
||||
|
||||
|
@ -38,7 +38,7 @@ int prepare_ops(p7_handle_t *handle, FILE *uexe, p7_disp_t disp)
|
|||
err = p7_sendexe_file(handle, uexe, 0x88030000, 0x88030000, disp);
|
||||
else {
|
||||
err = p7_sendexe_mem(handle, cake_exe_str,
|
||||
(size_t)((char*)&cake_exe_end - (char*)&cake_exe_str),
|
||||
(size_t)(cake_exe_end - cake_exe_str),
|
||||
0x88030000, 0x88030000, disp);
|
||||
fclose(uexe);
|
||||
}
|
||||
|
|
|
@ -27,17 +27,12 @@ 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 <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 <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"
|
||||
" 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"
|
||||
|
@ -55,16 +50,13 @@ static const char help_main[] =
|
|||
*
|
||||
* @arg ac the arguments count
|
||||
* @arg av the arguments values
|
||||
* @arg device pointer to the device
|
||||
* @arg zoom pointer the zoom
|
||||
* @arg args the parsed args pointer
|
||||
* @return 0 if ok, other if not.
|
||||
*/
|
||||
|
||||
int parse_args(int ac, char **av, const char **com, int *zoom)
|
||||
int parse_args(int ac, char **av, int *zoom)
|
||||
{
|
||||
/* initialize args */
|
||||
*com = 0;
|
||||
*zoom = DEFAULT_ZOOM;
|
||||
|
||||
/* define options */
|
||||
|
@ -72,7 +64,6 @@ int parse_args(int ac, char **av, const char **com, int *zoom)
|
|||
const struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{"com", required_argument, NULL, 'c'},
|
||||
{"zoom", required_argument, NULL, 'z'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
@ -86,8 +77,6 @@ int parse_args(int ac, char **av, const char **com, int *zoom)
|
|||
case 'h': help = 1; break;
|
||||
/* version */
|
||||
case 'v': version = 1; break;
|
||||
/* com port */
|
||||
case 'c': *com = optarg; break;
|
||||
/* zoom */
|
||||
case 'z':
|
||||
*zoom = atoi(optarg);
|
||||
|
@ -101,8 +90,6 @@ int parse_args(int ac, char **av, const char **com, int *zoom)
|
|||
case '?':
|
||||
if (optopt == 'z')
|
||||
log("-z, --zoom: expected an argument\n");
|
||||
else if (optopt == 'c')
|
||||
log("--com: expected an argument\n");
|
||||
else
|
||||
break;
|
||||
return (1);
|
||||
|
|
|
@ -122,14 +122,12 @@ static int display_callback(int w, int h, uint32_t **pixels)
|
|||
int main(int ac, char **av)
|
||||
{
|
||||
/* parse args */
|
||||
const char *com;
|
||||
if (parse_args(ac, av, &com, &zoom))
|
||||
if (parse_args(ac, av, &zoom))
|
||||
return (0);
|
||||
|
||||
/* Initialize libp7 */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if (com) err = p7_cominit(&handle, 0, com);
|
||||
else err = p7_init(&handle, 0);
|
||||
err = p7_init(&handle, 0);
|
||||
if (err) {
|
||||
/* display error */
|
||||
switch (err) {
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
# define log(S, ...) fprintf(stderr, S, ##__VA_ARGS__)
|
||||
|
||||
/* all functions */
|
||||
int parse_args(int ac, char **av, const char **com, int *zoom);
|
||||
int parse_args(int ac, char **av, int *zoom);
|
||||
|
||||
#endif /* MAIN_H */
|
||||
|
|
|
@ -17,7 +17,7 @@ void run_client(int in, int out)
|
|||
/* make the handle */
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if ((err = p7_fdinit(&handle, P7_ACTIVE | P7_CHECK | P7_TERM, "client",
|
||||
in, out))) {
|
||||
in, out, &p7_default_settings))) {
|
||||
fprintf(stderr, "Client initialization encountered an error: %s\n",
|
||||
p7_strerror(err));
|
||||
return ;
|
||||
|
|
|
@ -84,7 +84,8 @@ static p7_filesystem_t server_filesystems[] = {
|
|||
void run_server(int in, int out)
|
||||
{
|
||||
p7_handle_t *handle = NULL; int err;
|
||||
if ((err = p7_fdinit(&handle, 0, "server", in, out))) {
|
||||
if ((err = p7_fdinit(&handle, 0, "server", in, out,
|
||||
&p7_default_settings))) {
|
||||
fprintf(stderr, "Server encountered an error while initializing: %s\n",
|
||||
p7_strerror(err));
|
||||
return ;
|
||||
|
|
Reference in New Issue