From 13b7579bd45e89304b8697a6fb471bf0524f49d4 Mon Sep 17 00:00:00 2001 From: germeier Date: Sun, 27 Oct 2002 02:45:28 +0000 Subject: added code to read/write and display config files (CONFIG.DAT and FMCONFIG.DAT) another 8.3 fix :-( --- mpiosh/callback.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- mpiosh/callback.h | 3 +- mpiosh/global.c | 16 ++++++--- 3 files changed, 112 insertions(+), 8 deletions(-) (limited to 'mpiosh') diff --git a/mpiosh/callback.c b/mpiosh/callback.c index 8f4be03..e9d7a0a 100644 --- a/mpiosh/callback.c +++ b/mpiosh/callback.c @@ -2,7 +2,7 @@ * * Author: Andreas Büsching * - * $Id: callback.c,v 1.27 2002/10/18 08:39:23 crunchy Exp $ + * $Id: callback.c,v 1.28 2002/10/27 02:45:28 germeier Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -628,11 +628,108 @@ mpiosh_cmd_dump_mem(char *args[]) void mpiosh_cmd_config(char *args[]) { + BYTE *config_data, *p; + int size; + MPIOSH_CHECK_CONNECTION_CLOSED; - UNUSED(args); + if (args[0] != NULL) { + if (!strcmp(args[0], "read")) { + if ((size = mpio_file_get(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CONFIG_FILE, NULL))<=0) { + fprintf(stderr, "Could not read config file\n"); + } else { + printf("done.\n"); + } + } else if (!strcmp(args[0], "write")) { + printf("deleting old config file ...\n"); + mpio_file_del(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CONFIG_FILE, NULL); + printf("writing new config file ...\n"); + if (mpio_file_put(mpiosh.dev, MPIO_INTERNAL_MEM, MPIO_CONFIG_FILE, + FTYPE_CONF, NULL)==-1) + mpio_perror("error"); + mpio_sync(mpiosh.dev, MPIO_INTERNAL_MEM); + } else if (!strcmp(args[0], "show")) { + if ((size = mpio_file_get_to_memory(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CONFIG_FILE, NULL, &config_data))<=0) { + fprintf(stderr, "Could not read config file\n"); + } else { + hexdumpn(0, config_data, size); + fprintf(stderr, "please implement me!\n"); + free(config_data); + } + } else { + fprintf(stderr, "unknown config command\n"); + printf("config [read|write|show] channel\n"); + } + } else { + fprintf(stderr, "error: no arguments given\n"); + printf("config [read|write|show] <\n"); + } + } +void +mpiosh_cmd_channel(char *args[]) +{ + BYTE *channel_data, *p, name[17]; + int size; + int i; + int chan; + + MPIOSH_CHECK_CONNECTION_CLOSED; + + if (args[0] != NULL) { + if (!strcmp(args[0], "read")) { + if ((size = mpio_file_get(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CHANNEL_FILE, NULL))<=0) { + fprintf(stderr, "Could not read channel file\n"); + } else { + printf("done.\n"); + } + } else if (!strcmp(args[0], "write")) { + printf("deleting old config file ...\n"); + mpio_file_del(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CHANNEL_FILE, NULL); + printf("writing new config file ...\n"); + if (mpio_file_put(mpiosh.dev, MPIO_INTERNAL_MEM, MPIO_CHANNEL_FILE, + FTYPE_CHAN, NULL)==-1) + mpio_perror("error"); + mpio_sync(mpiosh.dev, MPIO_INTERNAL_MEM); + } else if (!strcmp(args[0], "show")) { + if ((size = mpio_file_get_to_memory(mpiosh.dev, MPIO_INTERNAL_MEM, + MPIO_CHANNEL_FILE, NULL, &channel_data))<=0) { + fprintf(stderr, "Could not read channel file\n"); + } else { + hexdump(channel_data, size); + + i=0; + p=channel_data; + while ((i<20) && (*p)) + { + memset(name, 0, 17); + strncpy(name, p, 16); + chan = (((p[16] * 0x100) + p[17]) - 0x600) + 1750; + printf("%2d. %-16s at %7.2f MHz\n", (i+1), + name, ((float)chan/20)); + p+=18; + i++; + } + if (!i) + printf("no channel defined!\n"); + + free(channel_data); + } + } else { + fprintf(stderr, "unknown channel command\n"); + printf("channel [read|write|show] channel\n"); + } + } else { + fprintf(stderr, "error: no arguments given\n"); + printf("channel [read|write|show] <\n"); + } +} void mpiosh_cmd_ldir(char *args[]) diff --git a/mpiosh/callback.h b/mpiosh/callback.h index a377a49..eefbd31 100644 --- a/mpiosh/callback.h +++ b/mpiosh/callback.h @@ -2,7 +2,7 @@ * * Author: Andreas Büsching * - * $Id: callback.h,v 1.6 2002/10/18 08:39:23 crunchy Exp $ + * $Id: callback.h,v 1.7 2002/10/27 02:45:28 germeier Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -48,6 +48,7 @@ void mpiosh_cmd_format(char *args[]); void mpiosh_cmd_switch(char *args[]); void mpiosh_cmd_dump_mem(char *args[]); void mpiosh_cmd_config(char *args[]); +void mpiosh_cmd_channel(char *args[]); /* local command callbacks */ void mpiosh_cmd_ldir(char *args[]); diff --git a/mpiosh/global.c b/mpiosh/global.c index 7fe21b6..d300f62 100644 --- a/mpiosh/global.c +++ b/mpiosh/global.c @@ -2,7 +2,7 @@ * * Author: Andreas Buesching * - * $Id: global.c,v 1.3 2002/10/18 08:39:23 crunchy Exp $ + * $Id: global.c,v 1.4 2002/10/27 02:45:28 germeier Exp $ * * Copyright (C) 2001 Andreas Büsching * @@ -105,12 +105,18 @@ mpiosh_cmd_t commands[] = { " dump FAT, directory, spare area and the first 0x100 of the\n" " selected memory card", mpiosh_cmd_dump_mem, NULL }, - { "config", (char *[]) { "conf", NULL }, "-w -r -s", + { "config", (char *[]) { "conf", NULL }, "[read|write|show]", " give access to the configuration file of the MPIO player\n" - " -w write the configuration back to the MPIO player\n" - " -r read the configuration file and dumps it on the local disc\n" - " -s show the current configuration", + " read read the configuration file and dump it on the local disc\n" + " write write the configuration back to the MPIO player\n" + " show show the current configuration", mpiosh_cmd_config, mpiosh_readline_comp_config }, + { "channel", (char *[]) { "channels", "chan", NULL }, "[read|write|show]", + " give access to the radio channel file of the MPIO player\n" + " read read the channel file and dump it on the local disc\n" + " write write the channel file back to the MPIO player\n" + " show show the current channel configuration", + mpiosh_cmd_channel, mpiosh_readline_comp_config }, { NULL, NULL, NULL, NULL, NULL, NULL } }; -- cgit v1.2.3