kopia lustrzana https://github.com/Hamlib/Hamlib
Fix compilation errors in GUOHETEC drivers
- Remove duplicate function declarations in pmr171_send - Remove duplicate code blocks in pmr171_set_mode - Remove duplicate pmr171_send calls in pmr171_set_ptt - Add missing from_be function implementation - Fix syntax errors that were causing CI failurespull/1787/head
rodzic
c9161e2e25
commit
abf6be0b5e
|
@ -96,6 +96,26 @@ uint16_t CRC16Check(const unsigned char *buf, int len)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from big-endian byte order
|
||||||
|
* @param data Data pointer
|
||||||
|
* @param byte_len Byte length
|
||||||
|
* @return Converted value
|
||||||
|
*/
|
||||||
|
unsigned long long from_be(const unsigned char data[], unsigned int byte_len)
|
||||||
|
{
|
||||||
|
unsigned long long result = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
for (i = 0; i < byte_len; i++)
|
||||||
|
{
|
||||||
|
result = (result << 8) | data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Common response validation functions
|
// Common response validation functions
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,6 @@ static int pmr171_open(RIG *rig)
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen)
|
static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen)
|
||||||
static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen)
|
|
||||||
{
|
{
|
||||||
hamlib_port_t *rp = RIGPORT(rig);
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
int retry = 5;
|
int retry = 5;
|
||||||
|
@ -644,16 +643,6 @@ static int pmr171_open(RIG *rig)
|
||||||
unsigned char reply[10];
|
unsigned char reply[10];
|
||||||
unsigned char i = rmode2guohe(mode, pmr171_modes);
|
unsigned char i = rmode2guohe(mode, pmr171_modes);
|
||||||
|
|
||||||
if (vfo == RIG_VFO_B)
|
|
||||||
{
|
|
||||||
cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes);
|
|
||||||
cmd[7] = i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd[6] = i;
|
|
||||||
cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes);
|
|
||||||
}
|
|
||||||
if (vfo == RIG_VFO_B)
|
if (vfo == RIG_VFO_B)
|
||||||
{
|
{
|
||||||
cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes);
|
cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes);
|
||||||
|
@ -695,39 +684,6 @@ static int pmr171_open(RIG *rig)
|
||||||
|
|
||||||
dump_hex(reply, reply[4] + 5);
|
dump_hex(reply, reply[4] + 5);
|
||||||
|
|
||||||
// Update cache
|
|
||||||
CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes);
|
|
||||||
CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes);
|
|
||||||
int crc = CRC16Check(&cmd[4], 4);
|
|
||||||
cmd[8] = crc >> 8;
|
|
||||||
cmd[9] = crc & 0xff;
|
|
||||||
rig_flush(rp);
|
|
||||||
write_block(rp, cmd, 10);
|
|
||||||
|
|
||||||
// Read header
|
|
||||||
int ret = read_block(rp, reply, 5);
|
|
||||||
if (ret < 0) {
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate data length
|
|
||||||
if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) {
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read data section
|
|
||||||
ret = read_block(rp, &reply[5], reply[4]);
|
|
||||||
if (ret < 0) {
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate mode field index won't overflow
|
|
||||||
if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7]
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__);
|
|
||||||
}
|
|
||||||
|
|
||||||
dump_hex(reply, reply[4] + 5);
|
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes);
|
CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes);
|
||||||
CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes);
|
CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes);
|
||||||
|
@ -751,7 +707,6 @@ static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
|
|
||||||
unsigned char reply[9];
|
unsigned char reply[9];
|
||||||
pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply));
|
pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply));
|
||||||
pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply));
|
|
||||||
|
|
||||||
CACHE(rig)->ptt = ptt;
|
CACHE(rig)->ptt = ptt;
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue