diff --git a/examples/Makefile b/examples/Makefile index b4485a5..32ac882 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -17,4 +17,4 @@ clean: .SUFFIXES: .conf .rdt .rdt.conf: - dmrconfig -r $< > $@ + dmrconfig $< > $@ diff --git a/examples/md-uv380-empty.conf b/examples/md-uv380-empty.conf index f650701..9b0967e 100644 --- a/examples/md-uv380-empty.conf +++ b/examples/md-uv380-empty.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-UV380 -Name: - -ID: 1234 Last Programmed Date: 2018-08-20 12:41:08 CPS Software Version: V01.07 -# Text displayed when the radio powers up. -Welcome Line 1: - -Welcome Line 2: - - # Table of analog channels. # 1) Channel number: 1-3000 # 2) Name: up to 16 characters, use '_' instead of space @@ -75,3 +69,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 1234 +Name: - + +# Text displayed when the radio powers up. +Intro Line 1: - +Intro Line 2: - diff --git a/examples/md-uv380-factory.conf b/examples/md-uv380-factory.conf index 3e86588..7198874 100644 --- a/examples/md-uv380-factory.conf +++ b/examples/md-uv380-factory.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-UV380 -Name: - -ID: 1234 Last Programmed Date: 2018-07-13 16:02:59 CPS Software Version: V01.07 -# Text displayed when the radio powers up. -Welcome Line 1: - -Welcome Line 2: - - # Table of digital channels. # 1) Channel number: 1-3000 # 2) Name: up to 16 characters, use '_' instead of space @@ -104,3 +98,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 1234 +Name: - + +# Text displayed when the radio powers up. +Intro Line 1: - +Intro Line 2: - diff --git a/examples/md-uv380_bm_2018-08-07.conf b/examples/md-uv380_bm_2018-08-07.conf index 0820534..f211488 100644 --- a/examples/md-uv380_bm_2018-08-07.conf +++ b/examples/md-uv380_bm_2018-08-07.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-UV380 -Name: Dit_Call -ID: 238 Last Programmed Date: 2018-08-05 17:54:47 CPS Software Version: V01.32 -# Text displayed when the radio powers up. -Welcome Line 1: Husk_ID -Welcome Line 2: og_Call - # Table of digital channels. # 1) Channel number: 1-3000 # 2) Name: up to 16 characters, use '_' instead of space @@ -1162,3 +1156,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 238 +Name: Dit_Call + +# Text displayed when the radio powers up. +Intro Line 1: Husk_ID +Intro Line 2: og_Call diff --git a/examples/md2017-7-23-2017.conf b/examples/md2017-7-23-2017.conf index a2712c0..0fc7459 100644 --- a/examples/md2017-7-23-2017.conf +++ b/examples/md2017-7-23-2017.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-UV380 -Name: - -ID: 1234 Last Programmed Date: 2017-07-23 19:19:23 CPS Software Version: V01.17 -# Text displayed when the radio powers up. -Welcome Line 1: - -Welcome Line 2: - - # Table of digital channels. # 1) Channel number: 1-3000 # 2) Name: up to 16 characters, use '_' instead of space @@ -685,3 +679,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 1234 +Name: - + +# Text displayed when the radio powers up. +Intro Line 1: - +Intro Line 2: - diff --git a/examples/md2017-DualHotspot-PNW-2017-07-19.conf b/examples/md2017-DualHotspot-PNW-2017-07-19.conf index 69aeafd..900bb2a 100644 --- a/examples/md2017-DualHotspot-PNW-2017-07-19.conf +++ b/examples/md2017-DualHotspot-PNW-2017-07-19.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-UV380 -Name: YourCall-Here -ID: 12345678 Last Programmed Date: 2017-07-19 07:09:13 CPS Software Version: V01.16 -# Text displayed when the radio powers up. -Welcome Line 1: YourName -Welcome Line 2: YourCall - # Table of digital channels. # 1) Channel number: 1-3000 # 2) Name: up to 16 characters, use '_' instead of space @@ -1549,3 +1543,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 12345678 +Name: YourCall-Here + +# Text displayed when the radio powers up. +Intro Line 1: YourName +Intro Line 2: YourCall diff --git a/examples/md380-baynet-full-codeplug-rev1.conf b/examples/md380-baynet-full-codeplug-rev1.conf index d3edfbc..8894fc1 100644 --- a/examples/md380-baynet-full-codeplug-rev1.conf +++ b/examples/md380-baynet-full-codeplug-rev1.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-380 -Name: YOURCALL -ID: 1234567 Last Programmed Date: 2018-03-29 10:33:50 CPS Software Version: V01.34 -# Text displayed when the radio powers up. -Welcome Line 1: WELCOME -Welcome Line 2: YOURCALL - # Table of digital channels. # 1) Channel number: 1-1000 # 2) Name: up to 16 characters, use '_' instead of space @@ -156,3 +150,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 1234567 +Name: YOURCALL + +# Text displayed when the radio powers up. +Intro Line 1: WELCOME +Intro Line 2: YOURCALL diff --git a/examples/md380-generic-norcal-uhf-20161103b.conf b/examples/md380-generic-norcal-uhf-20161103b.conf index 8930a1d..8b15d3c 100644 --- a/examples/md380-generic-norcal-uhf-20161103b.conf +++ b/examples/md380-generic-norcal-uhf-20161103b.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-380 -Name: noname -ID: 1234 Last Programmed Date: 2016-09-11 21:46:59 CPS Software Version: V01.32 -# Text displayed when the radio powers up. -Welcome Line 1: noname -Welcome Line 2: noDMRid - # Table of digital channels. # 1) Channel number: 1-1000 # 2) Name: up to 16 characters, use '_' instead of space @@ -1614,3 +1608,11 @@ Message Text 5 Be Right Back 6 My email is mycall@arrl.net 7 73 . . + +# Unique DMR ID and name of this radio. +ID: 1234 +Name: noname + +# Text displayed when the radio powers up. +Intro Line 1: noname +Intro Line 2: noDMRid diff --git a/examples/md380-norcal-brandmeister.conf b/examples/md380-norcal-brandmeister.conf index 371a4c9..1eb5e80 100644 --- a/examples/md380-norcal-brandmeister.conf +++ b/examples/md380-norcal-brandmeister.conf @@ -1,17 +1,11 @@ # -# This configuration was generated 2018/08/30 by dmrconfig, -# Version 0.1.40, Copyright (C) 2018 Serge Vakulenko KK6ABQ +# This configuration was generated 2018/08/31 by dmrconfig, +# Version 0.1.46, Copyright (C) 2018 Serge Vakulenko KK6ABQ # Radio: TYT MD-380 -Name: MYCALL -ID: 1234 Last Programmed Date: 2016-10-20 17:49:09 CPS Software Version: V01.32 -# Text displayed when the radio powers up. -Welcome Line 1: MYCALL -Welcome Line 2: MYNAME - # Table of digital channels. # 1) Channel number: 1-1000 # 2) Name: up to 16 characters, use '_' instead of space @@ -425,3 +419,11 @@ Grouplist Name Contacts # Message Text 1 Hello + +# Unique DMR ID and name of this radio. +ID: 1234 +Name: MYCALL + +# Text displayed when the radio powers up. +Intro Line 1: MYCALL +Intro Line 2: MYNAME diff --git a/main.c b/main.c index 20f5b2e..6e4dfe8 100644 --- a/main.c +++ b/main.c @@ -41,22 +41,23 @@ void usage() { fprintf(stderr, _("DMR Config, Version %s, %s\n"), version, copyright); fprintf(stderr, _("Usage:\n")); - fprintf(stderr, _(" dmrconfig [-v] -r\n")); - fprintf(stderr, _(" Read image from the radio and save it to a binary file 'device.img'.\n")); + fprintf(stderr, _(" dmrconfig -r [-t]\n")); + fprintf(stderr, _(" Read codeplug from the radio and save it to a binary file 'device.img'.\n")); fprintf(stderr, _(" Save configuration to a text file 'device.conf'.\n")); - fprintf(stderr, _(" dmrconfig -w [-v] file.img\n")); - fprintf(stderr, _(" Write image to the radio.\n")); - fprintf(stderr, _(" dmrconfig -c [-v] file.conf\n")); + fprintf(stderr, _(" dmrconfig -w [-t] file.img\n")); + fprintf(stderr, _(" Write codeplug to the radio.\n")); + fprintf(stderr, _(" dmrconfig -c [-t] file.conf\n")); fprintf(stderr, _(" Apply configuration script to the radio.\n")); - fprintf(stderr, _(" dmrconfig -c [-v] file.img file.conf\n")); - fprintf(stderr, _(" Apply text configuration to the image file.\n")); + fprintf(stderr, _(" dmrconfig -c file.img file.conf\n")); + fprintf(stderr, _(" Apply configuration script to the codeplug image.\n")); fprintf(stderr, _(" Store modified copy to a file 'device.img'.\n")); fprintf(stderr, _(" dmrconfig file.img\n")); - fprintf(stderr, _(" Display configuration from the image file.\n")); + fprintf(stderr, _(" Display configuration from the codeplug image.\n")); fprintf(stderr, _("Options:\n")); + fprintf(stderr, _(" -r Read image to the radio.\n")); fprintf(stderr, _(" -w Write image to the radio.\n")); fprintf(stderr, _(" -c Configure the radio from a text file.\n")); - fprintf(stderr, _(" -v Trace USB protocol.\n")); + fprintf(stderr, _(" -t Trace USB protocol.\n")); exit(-1); } @@ -78,8 +79,8 @@ int main(int argc, char **argv) copyright = _("Copyright (C) 2018 Serge Vakulenko KK6ABQ"); serial_verbose = 0; for (;;) { - switch (getopt(argc, argv, "vcwr")) { - case 'v': ++serial_verbose; continue; + switch (getopt(argc, argv, "tcwr")) { + case 't': ++serial_verbose; continue; case 'r': ++read_flag; continue; case 'w': ++write_flag; continue; case 'c': ++config_flag; continue; @@ -133,36 +134,33 @@ int main(int argc, char **argv) } } else if (read_flag) { - if (argc != 0 && argc != 1) + if (argc != 0) usage(); - if (argc == 1) { - // Print configuration from image file. - // Load image from file. - radio_read_image(argv[0]); - radio_print_config(stdout, ! isatty(1)); + // Dump device to image file. + radio_connect(); + radio_download(); + radio_print_version(stdout); + radio_disconnect(); + radio_save_image("device.img"); - } else { - // Dump device to image file. - radio_connect(); - radio_download(); - radio_print_version(stdout); - radio_disconnect(); - radio_save_image("device.img"); - - // Print configuration to file. - const char *filename = "device.conf"; - printf("Print configuration to file '%s'.\n", filename); - FILE *conf = fopen(filename, "w"); - if (! conf) { - perror(filename); - exit(-1); - } - radio_print_config(conf, 1); - fclose(conf); + // Print configuration to file. + const char *filename = "device.conf"; + printf("Print configuration to file '%s'.\n", filename); + FILE *conf = fopen(filename, "w"); + if (!conf) { + perror(filename); + exit(-1); } + radio_print_config(conf, 1); + fclose(conf); } else { - usage(); + if (argc != 1) + usage(); + + // Print configuration from image file. + radio_read_image(argv[0]); + radio_print_config(stdout, !isatty(1)); } return 0; } diff --git a/md380.c b/md380.c index d582bf5..03ca4b1 100644 --- a/md380.c +++ b/md380.c @@ -691,32 +691,35 @@ static void print_chanlist(FILE *out, uint16_t *unsorted, int nchan) fprintf(out, "-%d", last); } -static void print_id(FILE *out) +static void print_id(FILE *out, int verbose) { general_settings_t *gs = (general_settings_t*) &radio_mem[OFFSET_SETTINGS]; unsigned id = gs->radio_id[0] | (gs->radio_id[1] << 8) | (gs->radio_id[2] << 16); - fprintf(out, "Name: "); + if (verbose) + fprintf(out, "\n# Unique DMR ID and name of this radio.\n"); + fprintf(out, "ID: %u\nName: ", id); if (gs->radio_name[0] != 0 && gs->radio_name[0] != 0xffff) { print_unicode(out, gs->radio_name, 16, 0); } else { fprintf(out, "-"); } - fprintf(out, "\nID: %u\n", id); + fprintf(out, "\n"); } -static void print_intro(FILE *out) +static void print_intro(FILE *out, int verbose) { general_settings_t *gs = (general_settings_t*) &radio_mem[OFFSET_SETTINGS]; - fprintf(out, "\n# Text displayed when the radio powers up.\n"); - fprintf(out, "Welcome Line 1: "); + if (verbose) + fprintf(out, "\n# Text displayed when the radio powers up.\n"); + fprintf(out, "Intro Line 1: "); if (gs->intro_line1[0] != 0 && gs->intro_line1[0] != 0xffff) { print_unicode(out, gs->intro_line1, 10, 0); } else { fprintf(out, "-"); } - fprintf(out, "\nWelcome Line 2: "); + fprintf(out, "\nIntro Line 2: "); if (gs->intro_line2[0] != 0 && gs->intro_line2[0] != 0xffff) { print_unicode(out, gs->intro_line2, 10, 0); } else { @@ -1000,10 +1003,8 @@ static void md380_print_config(radio_device_t *radio, FILE *out, int verbose) int i; fprintf(out, "Radio: %s\n", radio->name); - print_id(out); if (verbose) md380_print_version(radio, out); - print_intro(out); // // Channels. @@ -1202,6 +1203,10 @@ static void md380_print_config(radio_device_t *radio, FILE *out, int verbose) fprintf(out, "\n"); } } + + // General settings. + print_id(out, verbose); + print_intro(out, verbose); } // @@ -1328,11 +1333,11 @@ static void md380_parse_parameter(radio_device_t *radio, char *param, char *valu // Ignore. return; } - if (strcasecmp ("Welcome Line 1", param) == 0) { + if (strcasecmp ("Intro Line 1", param) == 0) { utf8_decode(gs->intro_line1, value, 10); return; } - if (strcasecmp ("Welcome Line 2", param) == 0) { + if (strcasecmp ("Intro Line 2", param) == 0) { utf8_decode(gs->intro_line2, value, 10); return; } diff --git a/uv380.c b/uv380.c index beb9e64..f58ed6d 100644 --- a/uv380.c +++ b/uv380.c @@ -733,32 +733,35 @@ static void print_chanlist(FILE *out, uint16_t *unsorted, int nchan) fprintf(out, "-%d", last); } -static void print_id(FILE *out) +static void print_id(FILE *out, int verbose) { general_settings_t *gs = (general_settings_t*) &radio_mem[OFFSET_SETTINGS]; unsigned id = gs->radio_id[0] | (gs->radio_id[1] << 8) | (gs->radio_id[2] << 16); - fprintf(out, "Name: "); + if (verbose) + fprintf(out, "\n# Unique DMR ID and name of this radio.\n"); + fprintf(out, "ID: %u\nName: ", id); if (gs->radio_name[0] != 0 && gs->radio_name[0] != 0xffff) { print_unicode(out, gs->radio_name, 16, 0); } else { fprintf(out, "-"); } - fprintf(out, "\nID: %u\n", id); + fprintf(out, "\n"); } -static void print_intro(FILE *out) +static void print_intro(FILE *out, int verbose) { general_settings_t *gs = (general_settings_t*) &radio_mem[OFFSET_SETTINGS]; - fprintf(out, "\n# Text displayed when the radio powers up.\n"); - fprintf(out, "Welcome Line 1: "); + if (verbose) + fprintf(out, "\n# Text displayed when the radio powers up.\n"); + fprintf(out, "Intro Line 1: "); if (gs->intro_line1[0] != 0 && gs->intro_line1[0] != 0xffff) { print_unicode(out, gs->intro_line1, 10, 0); } else { fprintf(out, "-"); } - fprintf(out, "\nWelcome Line 2: "); + fprintf(out, "\nIntro Line 2: "); if (gs->intro_line2[0] != 0 && gs->intro_line2[0] != 0xffff) { print_unicode(out, gs->intro_line2, 10, 0); } else { @@ -1049,10 +1052,8 @@ static void uv380_print_config(radio_device_t *radio, FILE *out, int verbose) int i; fprintf(out, "Radio: %s\n", radio->name); - print_id(out); if (verbose) uv380_print_version(radio, out); - print_intro(out); // // Channels. @@ -1264,6 +1265,10 @@ static void uv380_print_config(radio_device_t *radio, FILE *out, int verbose) fprintf(out, "\n"); } } + + // General settings. + print_id(out, verbose); + print_intro(out, verbose); } // @@ -1397,11 +1402,11 @@ static void uv380_parse_parameter(radio_device_t *radio, char *param, char *valu // Ignore. return; } - if (strcasecmp ("Welcome Line 1", param) == 0) { + if (strcasecmp ("Intro Line 1", param) == 0) { utf8_decode(gs->intro_line1, value, 10); return; } - if (strcasecmp ("Welcome Line 2", param) == 0) { + if (strcasecmp ("Intro Line 2", param) == 0) { utf8_decode(gs->intro_line2, value, 10); return; }