From f08dd8329744f978f383aee8a40b9e817d16dfd4 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 12 Aug 2019 00:14:56 -0700 Subject: [PATCH] Make DM-1801 images compatible with native CPS. --- dm1801.c | 4 ++-- radio.c | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/dm1801.c b/dm1801.c index 3ee53f0..d5cee22 100644 --- a/dm1801.c +++ b/dm1801.c @@ -380,7 +380,7 @@ static void dm1801_download(radio_device_t *radio) download(radio); // Add header. - memcpy(&radio_mem[0], "MD-760P", 7); + memcpy(&radio_mem[0], "1801", 4); } // @@ -412,7 +412,7 @@ static void dm1801_upload(radio_device_t *radio, int cont_flag) // static int dm1801_is_compatible(radio_device_t *radio) { - return strncmp("MD-760P", (char*)&radio_mem[0], 7) == 0; + return strncmp("1801", (char*)&radio_mem[0], 4) == 0; } // diff --git a/radio.c b/radio.c index 76be167..55664ec 100644 --- a/radio.c +++ b/radio.c @@ -231,17 +231,9 @@ void radio_read_image(const char *filename) if (memcmp(ident, "BF-5R", 5) == 0) { device = &radio_rd5r; } else if (memcmp(ident, "MD-760P", 7) == 0) { - // Both GD-77 and DM-1801 have the same header. - fseek(img, 0x90, SEEK_SET); - if (fread(ident, 1, 8, img) != 8) { - fprintf(stderr, "%s: Cannot read radio ID.\n", filename); - exit(-1); - } - if (memcmp(ident, "BF-1801", 7) == 0) { - device = &radio_dm1801; - } else { - device = &radio_gd77; - } + device = &radio_gd77; + } else if (memcmp(ident, "1801", 4) == 0) { + device = &radio_dm1801; } else if (memcmp(ident, "MD-760", 6) == 0) { fprintf(stderr, "Old Radioddity GD-77 v2.6 image not supported!\n"); exit(-1);