D868UV: Print and parse id, name and intro strings.

Write image works correctly.
This commit is contained in:
Serge 2018-10-17 23:46:25 -07:00
parent 0ca967d411
commit 39b28f6026
6 changed files with 98 additions and 24 deletions

View File

@ -92,8 +92,19 @@ typedef struct {
// TODO: verify the general settings with official CPS // TODO: verify the general settings with official CPS
// //
typedef struct { typedef struct {
// Bytes 0-0x5ff. // Bytes 0-5.
uint8_t _unused0[0x600]; uint8_t _unused0[6];
// Bytes 6-7.
uint8_t power_on; // Power-on Interface
#define PWON_DEFAULT 0 // Default
#define PWON_CUST_CHAR 1 // Custom Char
#define PWON_CUST_PICT 2 // Custom Picture
uint8_t _unused7;
// Bytes 8-0x5ff.
uint8_t _unused8[0x5f8];
// Bytes 0x600-0x61f // Bytes 0x600-0x61f
uint8_t intro_line1[16]; // Up to 14 characters uint8_t intro_line1[16]; // Up to 14 characters
@ -194,10 +205,11 @@ static void d868uv_download(radio_device_t *radio)
static void d868uv_upload(radio_device_t *radio, int cont_flag) static void d868uv_upload(radio_device_t *radio, int cont_flag)
{ {
fragment_t *f; fragment_t *f;
unsigned file_offset = 0; unsigned file_offset;
unsigned last_printed = 0; unsigned last_printed = 0;
// Skip first region. // Skip first region.
file_offset = region_map[0].length;
for (f=region_map+1; f->length; f++) { for (f=region_map+1; f->length; f++) {
unsigned addr = f->address; unsigned addr = f->address;
unsigned nbytes = f->length; unsigned nbytes = f->length;
@ -345,7 +357,39 @@ static channel_t *get_bank(int i)
// //
static void d868uv_parse_parameter(radio_device_t *radio, char *param, char *value) static void d868uv_parse_parameter(radio_device_t *radio, char *param, char *value)
{ {
//TODO if (strcasecmp("Radio", param) == 0) {
if (!radio_is_compatible(value)) {
fprintf(stderr, "Incompatible model: %s\n", value);
exit(-1);
}
return;
}
radioid_t *ri = GET_RADIOID();
if (strcasecmp ("Name", param) == 0) {
ascii_decode(ri->name, value, 16, 0);
return;
}
if (strcasecmp ("ID", param) == 0) {
uint32_t id = strtoul(value, 0, 0);
ri->id[0] = ((id / 10000000) << 4) | ((id / 1000000) % 10);
ri->id[1] = ((id / 100000 % 10) << 4) | ((id / 10000) % 10);
ri->id[2] = ((id / 1000 % 10) << 4) | ((id / 100) % 10);
ri->id[3] = ((id / 10 % 10) << 4) | (id % 10);
return;
}
general_settings_t *gs = GET_SETTINGS();
if (strcasecmp ("Intro Line 1", param) == 0) {
ascii_decode_uppercase(gs->intro_line1, value, 14, 0);
gs->power_on = PWON_CUST_CHAR;
return;
}
if (strcasecmp ("Intro Line 2", param) == 0) {
ascii_decode_uppercase(gs->intro_line2, value, 14, 0);
gs->power_on = PWON_CUST_CHAR;
return;
}
fprintf(stderr, "Unknown parameter: %s = %s\n", param, value); fprintf(stderr, "Unknown parameter: %s = %s\n", param, value);
exit(-1); exit(-1);
} }

16
gd77.c
View File

@ -419,7 +419,7 @@ static void setup_zone(int index, const char *name)
zonetab_t *zt = GET_ZONETAB(); zonetab_t *zt = GET_ZONETAB();
zone_t *z = &zt->zone[index]; zone_t *z = &zt->zone[index];
ascii_decode(z->name, name, sizeof(z->name)); ascii_decode(z->name, name, sizeof(z->name), 0xff);
memset(z->member, 0, sizeof(z->member)); memset(z->member, 0, sizeof(z->member));
// Set valid bit. // Set valid bit.
@ -483,7 +483,7 @@ static void setup_scanlist(int index, const char *name,
scanlist_t *sl = &st->scanlist[index]; scanlist_t *sl = &st->scanlist[index];
memset(sl, 0, 88); memset(sl, 0, 88);
ascii_decode(sl->name, name, sizeof(sl->name)); ascii_decode(sl->name, name, sizeof(sl->name), 0xff);
sl->priority_ch1 = prio1; sl->priority_ch1 = prio1;
sl->priority_ch2 = prio2; sl->priority_ch2 = prio2;
@ -571,7 +571,7 @@ static void setup_contact(int index, const char *name, int type, int id, int rxt
ct->ring_style = 0; // TODO ct->ring_style = 0; // TODO
ct->_unused23 = (type < CALL_ALL) ? 0 : 0xff; ct->_unused23 = (type < CALL_ALL) ? 0 : 0xff;
ascii_decode(ct->name, name, 16); ascii_decode(ct->name, name, 16, 0xff);
} }
// //
@ -593,7 +593,7 @@ static void setup_grouplist(int index, const char *name)
grouptab_t *gt = GET_GROUPTAB(); grouptab_t *gt = GET_GROUPTAB();
grouplist_t *gl = &gt->grouplist[index]; grouplist_t *gl = &gt->grouplist[index];
ascii_decode(gl->name, name, sizeof(gl->name)); ascii_decode(gl->name, name, sizeof(gl->name), 0xff);
// Enable grouplist. // Enable grouplist.
gt->nitems1[index] = 1; gt->nitems1[index] = 1;
@ -712,7 +712,7 @@ static void setup_channel(int i, int mode, char *name, double rx_mhz, double tx_
ch->ctcss_dcs_receive = rxtone; ch->ctcss_dcs_receive = rxtone;
ch->ctcss_dcs_transmit = txtone; ch->ctcss_dcs_transmit = txtone;
ascii_decode(ch->name, name, sizeof(ch->name)); ascii_decode(ch->name, name, sizeof(ch->name), 0xff);
// Set valid bit. // Set valid bit.
b->bitmap[i % 128 / 8] |= 1 << (i & 7); b->bitmap[i % 128 / 8] |= 1 << (i & 7);
@ -1475,7 +1475,7 @@ static void gd77_parse_parameter(radio_device_t *radio, char *param, char *value
general_settings_t *gs = GET_SETTINGS(); general_settings_t *gs = GET_SETTINGS();
if (strcasecmp ("Name", param) == 0) { if (strcasecmp ("Name", param) == 0) {
ascii_decode(gs->radio_name, value, 8); ascii_decode(gs->radio_name, value, 8, 0xff);
return; return;
} }
if (strcasecmp ("ID", param) == 0) { if (strcasecmp ("ID", param) == 0) {
@ -1497,11 +1497,11 @@ static void gd77_parse_parameter(radio_device_t *radio, char *param, char *value
intro_text_t *it = GET_INTRO(); intro_text_t *it = GET_INTRO();
if (strcasecmp ("Intro Line 1", param) == 0) { if (strcasecmp ("Intro Line 1", param) == 0) {
ascii_decode(it->intro_line1, value, 16); ascii_decode(it->intro_line1, value, 16, 0xff);
return; return;
} }
if (strcasecmp ("Intro Line 2", param) == 0) { if (strcasecmp ("Intro Line 2", param) == 0) {
ascii_decode(it->intro_line2, value, 16); ascii_decode(it->intro_line2, value, 16, 0xff);
return; return;
} }
fprintf(stderr, "Unknown parameter: %s = %s\n", param, value); fprintf(stderr, "Unknown parameter: %s = %s\n", param, value);

16
rd5r.c
View File

@ -419,7 +419,7 @@ static void setup_zone(int index, const char *name)
zonetab_t *zt = GET_ZONETAB(); zonetab_t *zt = GET_ZONETAB();
zone_t *z = &zt->zone[index]; zone_t *z = &zt->zone[index];
ascii_decode(z->name, name, sizeof(z->name)); ascii_decode(z->name, name, sizeof(z->name), 0xff);
memset(z->member, 0, sizeof(z->member)); memset(z->member, 0, sizeof(z->member));
// Set valid bit. // Set valid bit.
@ -483,7 +483,7 @@ static void setup_scanlist(int index, const char *name,
scanlist_t *sl = &st->scanlist[index]; scanlist_t *sl = &st->scanlist[index];
memset(sl, 0, 88); memset(sl, 0, 88);
ascii_decode(sl->name, name, sizeof(sl->name)); ascii_decode(sl->name, name, sizeof(sl->name), 0xff);
sl->priority_ch1 = prio1; sl->priority_ch1 = prio1;
sl->priority_ch2 = prio2; sl->priority_ch2 = prio2;
@ -571,7 +571,7 @@ static void setup_contact(int index, const char *name, int type, int id, int rxt
ct->ring_style = 0; // TODO ct->ring_style = 0; // TODO
ct->_unused23 = (type < CALL_ALL) ? 0 : 0xff; ct->_unused23 = (type < CALL_ALL) ? 0 : 0xff;
ascii_decode(ct->name, name, 16); ascii_decode(ct->name, name, 16, 0xff);
} }
// //
@ -593,7 +593,7 @@ static void setup_grouplist(int index, const char *name)
grouptab_t *gt = GET_GROUPTAB(); grouptab_t *gt = GET_GROUPTAB();
grouplist_t *gl = &gt->grouplist[index]; grouplist_t *gl = &gt->grouplist[index];
ascii_decode(gl->name, name, sizeof(gl->name)); ascii_decode(gl->name, name, sizeof(gl->name), 0xff);
// Enable grouplist. // Enable grouplist.
gt->nitems1[index] = 1; gt->nitems1[index] = 1;
@ -716,7 +716,7 @@ static void setup_channel(int i, int mode, char *name, double rx_mhz, double tx_
ch->ctcss_dcs_receive = rxtone; ch->ctcss_dcs_receive = rxtone;
ch->ctcss_dcs_transmit = txtone; ch->ctcss_dcs_transmit = txtone;
ascii_decode(ch->name, name, sizeof(ch->name)); ascii_decode(ch->name, name, sizeof(ch->name), 0xff);
// Set valid bit. // Set valid bit.
b->bitmap[i % 128 / 8] |= 1 << (i & 7); b->bitmap[i % 128 / 8] |= 1 << (i & 7);
@ -1479,7 +1479,7 @@ static void rd5r_parse_parameter(radio_device_t *radio, char *param, char *value
general_settings_t *gs = GET_SETTINGS(); general_settings_t *gs = GET_SETTINGS();
if (strcasecmp ("Name", param) == 0) { if (strcasecmp ("Name", param) == 0) {
ascii_decode(gs->radio_name, value, 8); ascii_decode(gs->radio_name, value, 8, 0xff);
return; return;
} }
if (strcasecmp ("ID", param) == 0) { if (strcasecmp ("ID", param) == 0) {
@ -1501,11 +1501,11 @@ static void rd5r_parse_parameter(radio_device_t *radio, char *param, char *value
intro_text_t *it = GET_INTRO(); intro_text_t *it = GET_INTRO();
if (strcasecmp ("Intro Line 1", param) == 0) { if (strcasecmp ("Intro Line 1", param) == 0) {
ascii_decode(it->intro_line1, value, 16); ascii_decode(it->intro_line1, value, 16, 0xff);
return; return;
} }
if (strcasecmp ("Intro Line 2", param) == 0) { if (strcasecmp ("Intro Line 2", param) == 0) {
ascii_decode(it->intro_line2, value, 16); ascii_decode(it->intro_line2, value, 16, 0xff);
return; return;
} }
fprintf(stderr, "Unknown parameter: %s = %s\n", param, value); fprintf(stderr, "Unknown parameter: %s = %s\n", param, value);

View File

@ -696,7 +696,8 @@ again:
void serial_write_region(int addr, unsigned char *data, int nbytes) void serial_write_region(int addr, unsigned char *data, int nbytes)
{ {
static const int DATASZ = 64; //static const int DATASZ = 64;
static const int DATASZ = 16;
unsigned char ack, cmd[8 + DATASZ]; unsigned char ack, cmd[8 + DATASZ];
int n, i; int n, i;

32
util.c
View File

@ -334,7 +334,7 @@ void utf8_decode(unsigned short *dst, const char *src, unsigned nsym)
// Replace underscore by space. // Replace underscore by space.
// Fill the rest with 0xff. // Fill the rest with 0xff.
// //
void ascii_decode(unsigned char *dst, const char *src, unsigned nsym) void ascii_decode(unsigned char *dst, const char *src, unsigned nsym, unsigned fill)
{ {
if (src[0] == '-' && src[1] == 0) if (src[0] == '-' && src[1] == 0)
src = ""; src = "";
@ -345,7 +345,7 @@ void ascii_decode(unsigned char *dst, const char *src, unsigned nsym)
if (ch == 0) { if (ch == 0) {
// Clear the remaining bytes. // Clear the remaining bytes.
while (nsym-- > 0) while (nsym-- > 0)
*dst++ = 0xff; *dst++ = fill;
break; break;
} }
if (ch == '_') if (ch == '_')
@ -355,6 +355,34 @@ void ascii_decode(unsigned char *dst, const char *src, unsigned nsym)
} }
} }
//
// Copy ASCII string, at most nsym characters.
// Replace underscore by space.
// Fill the rest with 0xff.
//
void ascii_decode_uppercase(unsigned char *dst, const char *src, unsigned nsym, unsigned fill)
{
if (src[0] == '-' && src[1] == 0)
src = "";
for (; nsym > 0; nsym--) {
int ch = *src++;
if (ch == 0) {
// Clear the remaining bytes.
while (nsym-- > 0)
*dst++ = fill;
break;
}
if (ch == '_')
ch = ' ';
else if (ch >= 'a' && ch <= 'z')
ch += 'A' - 'a';
*dst++ = ch;
}
}
// //
// Convert tone string to BCD format. // Convert tone string to BCD format.
// Four possible formats: // Four possible formats:

3
util.h
View File

@ -162,7 +162,8 @@ void utf8_decode(unsigned short *dst, const char *src, unsigned nsym);
// Copy ASCII string, at most nsym characters. // Copy ASCII string, at most nsym characters.
// Replace underscore by space. // Replace underscore by space.
// //
void ascii_decode(unsigned char *dst, const char *src, unsigned nsym); void ascii_decode(unsigned char *dst, const char *src, unsigned nsym, unsigned fill);
void ascii_decode_uppercase(unsigned char *dst, const char *src, unsigned nsym, unsigned fill);
// //
// Get local time in format: YYYYMMDDhhmmss // Get local time in format: YYYYMMDDhhmmss