This commit is contained in:
Serge Vakulenko 2018-09-05 11:16:23 -07:00
commit 9cd07d3cd2
5 changed files with 35 additions and 15 deletions

31
dfu.c
View File

@ -126,7 +126,7 @@ static int get_status()
}
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
REQUEST_GETSTATUS, 0, 0, (unsigned char*)&status, 6, 0);
if (trace_flag && error == USB_OK) {
if (trace_flag && error >= 0) {
printf("--- Recv ");
print_hex((unsigned char*)&status, 6);
printf("\n");
@ -154,7 +154,7 @@ static int get_state(int *pstate)
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
REQUEST_GETSTATE, 0, 0, &state, 1, 0);
*pstate = state;
if (trace_flag && error == USB_OK) {
if (trace_flag && error >= 0) {
printf("--- Recv ");
print_hex(&state, 1);
printf("\n");
@ -305,7 +305,7 @@ static const char *identify()
__func__, error, libusb_strerror(error));
exit(-1);
}
if (trace_flag && error == USB_OK) {
if (trace_flag) {
printf("--- Recv ");
print_hex(data, 64);
printf("\n");
@ -417,7 +417,7 @@ void dfu_read_block(int bno, uint8_t *data, int nbytes)
__func__, bno, nbytes, error, libusb_strerror(error));
exit(-1);
}
if (trace_flag && error == USB_OK) {
if (trace_flag > 1) {
printf("--- Recv ");
print_hex(data, nbytes);
printf("\n");
@ -432,7 +432,8 @@ void dfu_write_block(int bno, uint8_t *data, int nbytes)
if (trace_flag) {
printf("--- Send DNLOAD [%d] ", nbytes);
print_hex(data, nbytes);
if (trace_flag > 1)
print_hex(data, nbytes);
printf("\n");
}
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE,
@ -446,3 +447,23 @@ void dfu_write_block(int bno, uint8_t *data, int nbytes)
get_status();
wait_dfu_idle();
}
void dfu_reboot()
{
unsigned char cmd[2] = { 0x91, 0x05 };
if (trace_flag) {
printf("--- Send DNLOAD [2] ");
print_hex(cmd, 2);
printf("\n");
}
wait_dfu_idle();
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE,
REQUEST_DNLOAD, 0, 0, cmd, 2, 0);
if (error < 0) {
fprintf(stderr, "%s: cannot send command: %d: %s\n",
__func__, error, libusb_strerror(error));
exit(-1);
}
get_status();
}

View File

@ -322,10 +322,10 @@ typedef struct {
static const char *POWER_NAME[] = { "Low", "High" };
static const char *SQUELCH_NAME[] = { "Tight", "Normal" };
static const char *BANDWIDTH[] = { "12.5", "20", "25" };
static const char *BANDWIDTH[] = { "12.5", "20", "25", "25" };
static const char *CONTACT_TYPE[] = { "-", "Group", "Private", "All" };
static const char *ADMIT_NAME[] = { "-", "Free", "Tone", "Color" };
static const char *INCALL_NAME[] = { "-", "Admit", "???", "???" };
static const char *INCALL_NAME[] = { "-", "Admit", "-", "Admit" };
#ifdef PRINT_RARE_PARAMS
static const char *REF_FREQUENCY[] = { "Low", "Med", "High" };

View File

@ -47,11 +47,9 @@ void radio_disconnect()
{
fprintf(stderr, "Close device.\n");
// Restore the port mode.
// Restore the normal radio mode.
dfu_reboot();
dfu_close();
// Radio needs a timeout to reset to a normal state.
mdelay(2000);
}
//

1
util.h
View File

@ -63,6 +63,7 @@ void dfu_close(void);
void dfu_erase(int nbytes);
void dfu_read_block(int bno, unsigned char *data, int nbytes);
void dfu_write_block(int bno, unsigned char *data, int nbytes);
void dfu_reboot(void);
//
// Delay in milliseconds.

View File

@ -338,17 +338,17 @@ typedef struct {
uint16_t radio_name[16];
} general_settings_t;
static const char *POWER_NAME[] = { "Low", "???", "Mid", "High" };
static const char *BANDWIDTH[] = { "12.5", "20", "25" };
static const char *POWER_NAME[] = { "Low", "Low", "Mid", "High" };
static const char *BANDWIDTH[] = { "12.5", "20", "25", "25" };
static const char *CONTACT_TYPE[] = { "-", "Group", "Private", "All" };
static const char *ADMIT_NAME[] = { "-", "Free", "Tone", "Color" };
static const char *INCALL_NAME[] = { "-", "Admit", "TXInt" };
static const char *INCALL_NAME[] = { "-", "Admit", "TXInt", "Admit" };
#ifdef PRINT_RARE_PARAMS
static const char *REF_FREQUENCY[] = { "Low", "Med", "High" };
static const char *PRIVACY_NAME[] = { "-", "Basic", "Enhanced" };
static const char *SIGNALING_SYSTEM[] = { "-", "DTMF-1", "DTMF-2", "DTMF-3", "DTMF-4" };
static const char *TURNOFF_FREQ[] = { "259.2", "55.2", "???", "-" };
static const char *TURNOFF_FREQ[] = { "259.2", "55.2", "-", "-" };
#endif
//