kopia lustrzana https://github.com/Hamlib/Hamlib
Fix micom get_freq
rodzic
cc9bb6f0b5
commit
74c96da18a
|
@ -41,16 +41,26 @@ static int micom_open(RIG *rig)
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns bytes read
|
||||||
|
// format has length in byte[1] plus 5 bytes 0x24/len/cmd at start and checksum+0x03 at end
|
||||||
|
// So a data "length" of 5 is 10 bytes for example
|
||||||
static int micom_read_frame(RIG *rig, unsigned char *buf, int maxlen)
|
static int micom_read_frame(RIG *rig, unsigned char *buf, int maxlen)
|
||||||
{
|
{
|
||||||
hamlib_port_t *rp = RIGPORT(rig);
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
int retval;
|
int bytes;
|
||||||
//const char stopset[1] = {0x03};
|
//const char stopset[1] = {0x03};
|
||||||
ENTERFUNC;
|
ENTERFUNC;
|
||||||
retval = read_block(rp, buf, 4);
|
bytes = read_block(rp, buf, 3);
|
||||||
retval = read_block(rp, buf, buf[1]+1);
|
if (bytes+buf[1]+2 > maxlen)
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: retval=%d\n", __func__, retval);
|
{
|
||||||
RETURNFUNC(retval);
|
rig_debug(RIG_DEBUG_ERR, "%s: buffer overrun...expected max of %d, got %d\n",
|
||||||
|
__func__, maxlen, bytes+buf[1]+2);
|
||||||
|
dump_hex(buf,bytes);
|
||||||
|
RETURNFUNC(-RIG_EPROTO);
|
||||||
|
}
|
||||||
|
bytes += read_block(rp, &buf[3], buf[1]+2);
|
||||||
|
dump_hex(buf,bytes);
|
||||||
|
RETURNFUNC(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Example of set of commands that works
|
/* Example of set of commands that works
|
||||||
|
@ -129,7 +139,6 @@ static int micom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
unsigned char cmd[6] = { 0x24, 0x01, 0x18, 0x06, 0x06, 0x03 };
|
unsigned char cmd[6] = { 0x24, 0x01, 0x18, 0x06, 0x06, 0x03 };
|
||||||
unsigned char reply[11];
|
unsigned char reply[11];
|
||||||
int retval;
|
int retval;
|
||||||
int ifreq;
|
|
||||||
|
|
||||||
cmd[4] = checksum(cmd,4);
|
cmd[4] = checksum(cmd,4);
|
||||||
set_transaction_active(rig);
|
set_transaction_active(rig);
|
||||||
|
@ -146,8 +155,7 @@ static int micom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
|
|
||||||
micom_read_frame(rig, reply, sizeof(reply));
|
micom_read_frame(rig, reply, sizeof(reply));
|
||||||
set_transaction_inactive(rig);
|
set_transaction_inactive(rig);
|
||||||
ifreq = (reply[5] << 24) | (reply[6] << 16) | (reply[7] << 8) | reply[8];
|
*freq = (reply[5] << 24) | (reply[6] << 16) | (reply[7] << 8) | reply[8];
|
||||||
*freq = ifreq * 1000;
|
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +181,7 @@ struct rig_caps micom_caps =
|
||||||
RIG_MODEL(RIG_MODEL_MICOM2),
|
RIG_MODEL(RIG_MODEL_MICOM2),
|
||||||
.model_name = "Micom 2/3",
|
.model_name = "Micom 2/3",
|
||||||
.mfg_name = "Micom",
|
.mfg_name = "Micom",
|
||||||
.version = "20240502.0",
|
.version = "20240503.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_ALPHA,
|
.status = RIG_STATUS_ALPHA,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct ip_mreq
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../include/hamlib/rig.h"
|
#include "../include/hamlib/rig.h"
|
||||||
|
#include "../src/misc.h"
|
||||||
|
|
||||||
#define BUFSIZE 256
|
#define BUFSIZE 256
|
||||||
|
|
||||||
|
@ -114,6 +115,10 @@ again:
|
||||||
{
|
{
|
||||||
case 0x06:
|
case 0x06:
|
||||||
printf("Report receiver freq\n");
|
printf("Report receiver freq\n");
|
||||||
|
unsigned char cmd[11] = { 0x24,0x06,0x18,0x05,0x01,0x00,0x38,0xea,0x50,0xba,0x03};
|
||||||
|
dump_hex(cmd, 11);
|
||||||
|
int n = write(fd, cmd, sizeof(cmd));
|
||||||
|
printf("%d bytes sent\n", n);
|
||||||
break;
|
break;
|
||||||
case 0x13:
|
case 0x13:
|
||||||
printf("PTT On\n");
|
printf("PTT On\n");
|
||||||
|
@ -121,6 +126,9 @@ again:
|
||||||
case 0x14:
|
case 0x14:
|
||||||
printf("PTT Off\n");
|
printf("PTT Off\n");
|
||||||
break;
|
break;
|
||||||
|
case 0x36:
|
||||||
|
printf("Key request\n");
|
||||||
|
break;
|
||||||
|
|
||||||
default: printf("Unknown cmd=%02x\n", buf[3]);
|
default: printf("Unknown cmd=%02x\n", buf[3]);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue