[Hamlib-developer] AOR AR5000
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: Chuck H. <n2...@am...> - 2003-02-24 11:43:15
|
I had a chance to play a little bit with an AOR AR5000 the other day.
I ran into a problem with hamlib in that the radio expects sent to it to be
terminated by a CR. In aor.c, the commands being sent are terminated with a
EOM, which translates to "0xa" which translates to LF.
I'm not sure if anyone has tested this yet or if any of the AOR radios expect
commands to be terminated with a LF. If there are, it's going to make the
patch a little more difficult.
I also ran across a bug where in aor_get_freq if the response from the radio
didn't have a "RF" in it (eg. because of a timeout) then it would try to do a
scanf with a null pointer and segfault.
I didn't have a lot of time while I was playing with the radio, so I didn't
have a chance to test most of the functions. And I didn't have time to make
the changes look nice. I attached an example of the quick changes I did, and
with them, get_freq and set_freq seemed to work fine. If you want, I'll try to
come up with a cleaner patch.
By the way, I need to be able to set the radio's attenuator using hamlib and I
didn't see any support for the in aor.c. Does that just require creating a
aor_set_level that does the work, and adding it to the cap structure in
AR5000.c?
---
Warning: this patch is pretty ugly, but it worked for me. :)
#define CR '\r'
#define EOM "\x0a"
+#define CR_STRING "\r"
.
.
.
int aor_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
char *rfp;
int freq_len, retval;
unsigned char freqbuf[BUFSZ];
- retval = aor_transaction (rig, "RX" EOM, 3, freqbuf, &freq_len);
+ retval = aor_transaction (rig, "RX" CR_STRING, 3, freqbuf,
&freq_len);
if (retval != RIG_OK)
return retval;
rfp = strstr(freqbuf, "RF");
+ if(!rfp)
+ {
+ printf("NO RF in returned string in aor_get_freq\n");
+ printf("freqbuf = '%s'\n",freqbuf);
+ return -RIG_EINVAL;
+ }
sscanf(rfp+2,"%lld", freq);
return RIG_OK;
}
|