From d1836b365f6ad41c6d0cf095d2709c86e693e84d Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Thu, 30 Aug 2018 18:33:35 -0700 Subject: [PATCH] Erase scanlist. --- md380.c | 38 +++++++++++++++++++++++++++++--------- util.c | 5 ++++- uv380.c | 40 ++++++++++++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/md380.c b/md380.c index 3da933e..4b65fa4 100644 --- a/md380.c +++ b/md380.c @@ -407,6 +407,24 @@ static void erase_zone(int zone_index) memset(data, 0, 0x80); } +static void erase_scanlist(int index) +{ + scanlist_t *sl = (scanlist_t*) &radio_mem[OFFSET_SCANL + index*104]; + + memset(sl, 0, 104); + + // Bytes 32-37 + sl->priority_ch1 = 0xffff; + sl->priority_ch2 = 0xffff; + sl->tx_designated_ch = 0xffff; + + // Bytes 38-41 + sl->_unused1 = 0xf1; + sl->sign_hold_time = 500 / 25; // 500 msec + sl->prio_sample_time = 2000 / 250; // 2 sec + sl->_unused2 = 0xff; +} + // // Check that the radio does support this frequency. // @@ -517,7 +535,7 @@ static void erase_channel(int i) // Byte 0 ch->channel_mode = MODE_ANALOG; - ch->bandwidth = BW_25_KHZ; + ch->bandwidth = BW_12_5_KHZ; ch->autoscan = 0; ch->squelch = SQ_NORMAL; ch->_unused1 = 1; @@ -579,8 +597,8 @@ static void erase_channel(int i) ch->tx_frequency = 0x40000000; // Bytes 24-27 - ch->ctcss_dcs_receive = 0; - ch->ctcss_dcs_transmit = 0; + ch->ctcss_dcs_receive = 0xffff; + ch->ctcss_dcs_transmit = 0xffff; // Bytes 28-29 ch->rx_signaling_syst = 0; @@ -1193,7 +1211,9 @@ static void erase_channels() for (i=0; i 37) { + if (tot > 555 || tot % 15 != 0) { fprintf(stderr, "Bad timeout timer.\n"); return 0; } - tot *= 15; + tot /= 15; if (*rxonly_str == '-') { rxonly = 0; @@ -1392,7 +1412,7 @@ badtx: fprintf(stderr, "Bad transmit frequency.\n"); setup_channel(num-1, MODE_DIGITAL, name_str, rx_mhz, tx_mhz, power, scanlist, autoscan, squelch, tot, rxonly, admit, - colorcode, timeslot, incall, grouplist, contact, 0, 0, BW_12_5_KHZ); + colorcode, timeslot, incall, grouplist, contact, 0xffff, 0xffff, BW_12_5_KHZ); radio->channel_count++; return 1; @@ -1475,11 +1495,11 @@ badtx: fprintf(stderr, "Bad transmit frequency.\n"); } tot = atoi(tot_str); - if (tot > 37) { + if (tot > 555 || tot % 15 != 0) { fprintf(stderr, "Bad timeout timer.\n"); return 0; } - tot *= 15; + tot /= 15; if (*rxonly_str == '-') { rxonly = 0; diff --git a/util.c b/util.c index 08223ed..e05197c 100644 --- a/util.c +++ b/util.c @@ -286,6 +286,9 @@ int utf8_to_unicode(const char **p) // void utf8_decode(unsigned short *dst, const char *src, unsigned nsym) { + if (src[0] == '-' && src[1] == 0) + src = ""; + for (; nsym > 0; nsym--) { int ch = utf8_to_unicode(&src); @@ -316,7 +319,7 @@ int encode_tone(char *str) if (*str == '-') { // Disabled - return 0; + return 0xffff; } else if (*str == 'D' || *str == 'd') { // diff --git a/uv380.c b/uv380.c index f2611de..73fe76b 100644 --- a/uv380.c +++ b/uv380.c @@ -423,6 +423,24 @@ static void erase_zone(int zone_index) memset(data, 0, 0x80); } +static void erase_scanlist(int index) +{ + scanlist_t *sl = (scanlist_t*) &radio_mem[OFFSET_SCANL + index*104]; + + memset(sl, 0, 104); + + // Bytes 32-37 + sl->priority_ch1 = 0xffff; + sl->priority_ch2 = 0xffff; + sl->tx_designated_ch = 0xffff; + + // Bytes 38-41 + sl->_unused1 = 0xf1; + sl->sign_hold_time = 500 / 25; // 500 msec + sl->prio_sample_time = 2000 / 250; // 2 sec + sl->_unused2 = 0xff; +} + // // Check that the radio does support this frequency. // @@ -537,7 +555,7 @@ static void erase_channel(int i) // Byte 0 ch->channel_mode = MODE_ANALOG; - ch->bandwidth = BW_25_KHZ; + ch->bandwidth = BW_12_5_KHZ; ch->autoscan = 0; ch->_unused1 = 3; ch->lone_worker = 0; @@ -590,15 +608,15 @@ static void erase_channel(int i) // Bytes 14-15 ch->_unused9 = 0; - ch->squelch = 3; + ch->squelch = 1; // Bytes 16-23 ch->rx_frequency = 0x40000000; ch->tx_frequency = 0x40000000; // Bytes 24-27 - ch->ctcss_dcs_receive = 0; - ch->ctcss_dcs_transmit = 0; + ch->ctcss_dcs_receive = 0xffff; + ch->ctcss_dcs_transmit = 0xffff; // Bytes 28-29 ch->rx_signaling_syst = 0; @@ -1242,7 +1260,9 @@ static void erase_channels() for (i=0; i 37) { + if (tot > 555 || tot % 15 != 0) { fprintf(stderr, "Bad timeout timer.\n"); return 0; } - tot *= 15; + tot /= 15; if (*rxonly_str == '-') { rxonly = 0; @@ -1447,7 +1467,7 @@ badtx: fprintf(stderr, "Bad transmit frequency.\n"); setup_channel(num-1, MODE_DIGITAL, name_str, rx_mhz, tx_mhz, power, scanlist, autoscan, squelch, tot, rxonly, admit, - colorcode, timeslot, incall, grouplist, contact, 0, 0, BW_12_5_KHZ); + colorcode, timeslot, incall, grouplist, contact, 0xffff, 0xffff, BW_12_5_KHZ); radio->channel_count++; return 1; @@ -1532,11 +1552,11 @@ badtx: fprintf(stderr, "Bad transmit frequency.\n"); } tot = atoi(tot_str); - if (tot > 37) { + if (tot > 555 || tot % 15 != 0) { fprintf(stderr, "Bad timeout timer.\n"); return 0; } - tot *= 15; + tot /= 15; if (*rxonly_str == '-') { rxonly = 0;