Rename -t flag.

This commit is contained in:
Serge Vakulenko 2018-08-31 11:56:21 -07:00
parent c548bf8ebe
commit 6a69737d65
4 changed files with 22 additions and 22 deletions

30
dfu.c
View File

@ -111,7 +111,7 @@ static status_t status;
static int detach(int timeout) static int detach(int timeout)
{ {
if (serial_verbose) { if (trace_flag) {
printf("--- Send DETACH\n"); printf("--- Send DETACH\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE,
@ -121,12 +121,12 @@ static int detach(int timeout)
static int get_status() static int get_status()
{ {
if (serial_verbose) { if (trace_flag) {
printf("--- Send GETSTATUS [6]\n"); printf("--- Send GETSTATUS [6]\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
REQUEST_GETSTATUS, 0, 0, (unsigned char*)&status, 6, 0); REQUEST_GETSTATUS, 0, 0, (unsigned char*)&status, 6, 0);
if (serial_verbose && error == USB_OK) { if (trace_flag && error == USB_OK) {
printf("--- Recv "); printf("--- Recv ");
print_hex((unsigned char*)&status, 6); print_hex((unsigned char*)&status, 6);
printf("\n"); printf("\n");
@ -136,7 +136,7 @@ static int get_status()
static int clear_status() static int clear_status()
{ {
if (serial_verbose) { if (trace_flag) {
printf("--- Send CLRSTATUS\n"); printf("--- Send CLRSTATUS\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE,
@ -148,13 +148,13 @@ static int get_state(int *pstate)
{ {
unsigned char state; unsigned char state;
if (serial_verbose) { if (trace_flag) {
printf("--- Send GETSTATE [1]\n"); printf("--- Send GETSTATE [1]\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
REQUEST_GETSTATE, 0, 0, &state, 1, 0); REQUEST_GETSTATE, 0, 0, &state, 1, 0);
*pstate = state; *pstate = state;
if (serial_verbose && error == USB_OK) { if (trace_flag && error == USB_OK) {
printf("--- Recv "); printf("--- Recv ");
print_hex(&state, 1); print_hex(&state, 1);
printf("\n"); printf("\n");
@ -164,7 +164,7 @@ static int get_state(int *pstate)
static int dfu_abort() static int dfu_abort()
{ {
if (serial_verbose) { if (trace_flag) {
printf("--- Send ABORT\n"); printf("--- Send ABORT\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_DEVICE,
@ -219,7 +219,7 @@ static void md380_command(uint8_t a, uint8_t b)
{ {
unsigned char cmd[2] = { a, b }; unsigned char cmd[2] = { a, b };
if (serial_verbose) { if (trace_flag) {
printf("--- Send DNLOAD [2] "); printf("--- Send DNLOAD [2] ");
print_hex(cmd, 2); print_hex(cmd, 2);
printf("\n"); printf("\n");
@ -245,7 +245,7 @@ static void set_address(uint32_t address)
(uint8_t)(address >> 24), (uint8_t)(address >> 24),
}; };
if (serial_verbose) { if (trace_flag) {
printf("--- Send DNLOAD [5] "); printf("--- Send DNLOAD [5] ");
print_hex(cmd, 5); print_hex(cmd, 5);
printf("\n"); printf("\n");
@ -270,7 +270,7 @@ static void erase_block(uint32_t address)
(uint8_t)(address >> 24), (uint8_t)(address >> 24),
}; };
if (serial_verbose) { if (trace_flag) {
printf("--- Send DNLOAD [5] "); printf("--- Send DNLOAD [5] ");
print_hex(cmd, 5); print_hex(cmd, 5);
printf("\n"); printf("\n");
@ -292,7 +292,7 @@ static const char *identify()
md380_command(0xa2, 0x01); md380_command(0xa2, 0x01);
if (serial_verbose) { if (trace_flag) {
printf("--- Send UPLOAD [64]\n"); printf("--- Send UPLOAD [64]\n");
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
@ -302,7 +302,7 @@ static const char *identify()
__func__, error, libusb_strerror(error)); __func__, error, libusb_strerror(error));
exit(-1); exit(-1);
} }
if (serial_verbose && error == USB_OK) { if (trace_flag && error == USB_OK) {
printf("--- Recv "); printf("--- Recv ");
print_hex(data, 64); print_hex(data, 64);
printf("\n"); printf("\n");
@ -402,7 +402,7 @@ void dfu_read_block(int bno, uint8_t *data, int nbytes)
if (bno >= 256) if (bno >= 256)
bno += 832; bno += 832;
if (serial_verbose) { if (trace_flag) {
printf("--- Send UPLOAD [%d]\n", nbytes); printf("--- Send UPLOAD [%d]\n", nbytes);
} }
int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST, int error = libusb_control_transfer(dev, REQUEST_TYPE_TO_HOST,
@ -412,7 +412,7 @@ void dfu_read_block(int bno, uint8_t *data, int nbytes)
__func__, bno, nbytes, error, libusb_strerror(error)); __func__, bno, nbytes, error, libusb_strerror(error));
exit(-1); exit(-1);
} }
if (serial_verbose && error == USB_OK) { if (trace_flag && error == USB_OK) {
printf("--- Recv "); printf("--- Recv ");
print_hex(data, nbytes); print_hex(data, nbytes);
printf("\n"); printf("\n");
@ -425,7 +425,7 @@ void dfu_write_block(int bno, uint8_t *data, int nbytes)
if (bno >= 256) if (bno >= 256)
bno += 832; bno += 832;
if (serial_verbose) { if (trace_flag) {
printf("--- Send DNLOAD [%d] ", nbytes); printf("--- Send DNLOAD [%d] ", nbytes);
print_hex(data, nbytes); print_hex(data, nbytes);
printf("\n"); printf("\n");

4
main.c
View File

@ -77,10 +77,10 @@ int main(int argc, char **argv)
textdomain("dmrconfig"); textdomain("dmrconfig");
copyright = _("Copyright (C) 2018 Serge Vakulenko KK6ABQ"); copyright = _("Copyright (C) 2018 Serge Vakulenko KK6ABQ");
serial_verbose = 0; trace_flag = 0;
for (;;) { for (;;) {
switch (getopt(argc, argv, "tcwr")) { switch (getopt(argc, argv, "tcwr")) {
case 't': ++serial_verbose; continue; case 't': ++trace_flag; continue;
case 'r': ++read_flag; continue; case 'r': ++read_flag; continue;
case 'w': ++write_flag; continue; case 'w': ++write_flag; continue;
case 'c': ++config_flag; continue; case 'c': ++config_flag; continue;

View File

@ -92,12 +92,12 @@ void radio_connect()
void radio_download() void radio_download()
{ {
radio_progress = 0; radio_progress = 0;
if (! serial_verbose) if (! trace_flag)
fprintf(stderr, "Read device: "); fprintf(stderr, "Read device: ");
device->download(device); device->download(device);
if (! serial_verbose) if (! trace_flag)
fprintf(stderr, " done.\n"); fprintf(stderr, " done.\n");
} }
@ -112,13 +112,13 @@ void radio_upload(int cont_flag)
exit(-1); exit(-1);
} }
radio_progress = 0; radio_progress = 0;
if (! serial_verbose) { if (! trace_flag) {
fprintf(stderr, "Write device: "); fprintf(stderr, "Write device: ");
fflush(stderr); fflush(stderr);
} }
device->upload(device, cont_flag); device->upload(device, cont_flag);
if (! serial_verbose) if (! trace_flag)
fprintf(stderr, " done.\n"); fprintf(stderr, " done.\n");
} }

2
util.h
View File

@ -48,7 +48,7 @@ extern const char *copyright;
// //
// Trace data i/o via the serial port. // Trace data i/o via the serial port.
// //
int serial_verbose; int trace_flag;
// //
// Print data in hex format. // Print data in hex format.