From f765b68586faf309015206f5ea032c014127a309 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Fri, 7 Sep 2018 23:38:52 -0700 Subject: [PATCH] Fix windows issues. --- Makefile | 2 +- dfu-windows.c | 2 +- md380.c | 9 ++++++--- radio.c | 4 ++-- uv380.c | 9 ++++++--- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e53a1f9..4581198 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -VERSION = 0.3 +VERSION = 0.4 GITCOUNT = $(shell git rev-list HEAD --count) CFLAGS = -g -O -Wall -Werror -DVERSION='"$(VERSION).$(GITCOUNT)"' LDFLAGS = -g diff --git a/dfu-windows.c b/dfu-windows.c index a33446c..959d6c3 100644 --- a/dfu-windows.c +++ b/dfu-windows.c @@ -141,7 +141,7 @@ static int dev_read(int request, int value, int length, PBYTE buffer) rq->Index = 0; rq->Length = length; - if (!DeviceIoControl(dev, PU_VENDOR_REQUEST, rq, rqlen + length, + if (!DeviceIoControl(dev, PU_VENDOR_REQUEST, rq, rqlen, buffer, length, &nbytes, NULL)) { return -1; } diff --git a/md380.c b/md380.c index 1678e21..7251e25 100644 --- a/md380.c +++ b/md380.c @@ -185,7 +185,8 @@ typedef struct { // typedef struct { // Bytes 0-2 - uint32_t id : 24; // Call ID: 1...16777215 + uint8_t id[3]; // Call ID: 1...16777215 +#define CONTACT_ID(ct) ((ct)->id[0] | ((ct)->id[1] << 8) | ((ct)->id[2] << 16)) // Byte 3 uint8_t type : 2, // Call Type: Group Call, Private Call or All Call @@ -509,7 +510,9 @@ static void setup_contact(int index, const char *name, int type, int id, int rxt { contact_t *ct = GET_CONTACT(index); - ct->id = id; + ct->id[0] = id; + ct->id[1] = id >> 8; + ct->id[2] = id >> 16; ct->type = type; ct->receive_tone = rxtone; @@ -1208,7 +1211,7 @@ static void md380_print_config(radio_device_t *radio, FILE *out, int verbose) fprintf(out, "%5d ", i+1); print_unicode(out, ct->name, 16, 1); fprintf(out, " %-7s %-8d %s\n", - CONTACT_TYPE[ct->type], ct->id, ct->receive_tone ? "+" : "-"); + CONTACT_TYPE[ct->type], CONTACT_ID(ct), ct->receive_tone ? "+" : "-"); } } diff --git a/radio.c b/radio.c index 03c9b78..6d33186 100644 --- a/radio.c +++ b/radio.c @@ -176,7 +176,7 @@ void radio_save_image(const char *filename) FILE *img; fprintf(stderr, "Write codeplug to file '%s'.\n", filename); - img = fopen(filename, "w"); + img = fopen(filename, "wb"); if (! img) { perror(filename); exit(-1); @@ -313,7 +313,7 @@ void radio_write_csv(const char *filename) exit(-1); } - csv = fopen(filename, "rb"); + csv = fopen(filename, "r"); if (! csv) { perror(filename); exit(-1); diff --git a/uv380.c b/uv380.c index 3ebded8..18177e2 100644 --- a/uv380.c +++ b/uv380.c @@ -200,7 +200,8 @@ typedef struct { // typedef struct { // Bytes 0-2 - uint32_t id : 24; // Call ID: 1...16777215 + uint8_t id[3]; // Call ID: 1...16777215 +#define CONTACT_ID(ct) ((ct)->id[0] | ((ct)->id[1] << 8) | ((ct)->id[2] << 16)) // Byte 3 uint8_t type : 2, // Call Type: Group Call, Private Call or All Call @@ -564,7 +565,9 @@ static void setup_contact(int index, const char *name, int type, int id, int rxt { contact_t *ct = GET_CONTACT(index); - ct->id = id; + ct->id[0] = id; + ct->id[1] = id >> 8; + ct->id[2] = id >> 16; ct->type = type; ct->receive_tone = rxtone; @@ -1287,7 +1290,7 @@ static void uv380_print_config(radio_device_t *radio, FILE *out, int verbose) fprintf(out, "%5d ", i+1); print_unicode(out, ct->name, 16, 1); fprintf(out, " %-7s %-8d %s\n", - CONTACT_TYPE[ct->type], ct->id, ct->receive_tone ? "+" : "-"); + CONTACT_TYPE[ct->type], CONTACT_ID(ct), ct->receive_tone ? "+" : "-"); } }