Move ID and name to the bottom of config script.

This commit is contained in:
Serge Vakulenko 2018-08-31 11:54:07 -07:00
parent 17560c1a41
commit c548bf8ebe
12 changed files with 147 additions and 123 deletions

View File

@ -17,4 +17,4 @@ clean:
.SUFFIXES: .conf .rdt
.rdt.conf:
dmrconfig -r $< > $@
dmrconfig $< > $@

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

38
main.c
View File

@ -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,16 +134,9 @@ 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));
} else {
// Dump device to image file.
radio_connect();
radio_download();
@ -160,9 +154,13 @@ int main(int argc, char **argv)
}
radio_print_config(conf, 1);
fclose(conf);
}
} else {
if (argc != 1)
usage();
// Print configuration from image file.
radio_read_image(argv[0]);
radio_print_config(stdout, !isatty(1));
}
return 0;
}

25
md380.c
View File

@ -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];
if (verbose)
fprintf(out, "\n# Text displayed when the radio powers up.\n");
fprintf(out, "Welcome Line 1: ");
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;
}

25
uv380.c
View File

@ -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];
if (verbose)
fprintf(out, "\n# Text displayed when the radio powers up.\n");
fprintf(out, "Welcome Line 1: ");
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;
}