From: Stéphane F. <fi...@us...> - 2012-06-23 15:25:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 531d45192fd40b93460d0ece438f03d686c1791e (commit) from eb8fc666753f0f718d7bae519f8bfbbd414432ac (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 531d45192fd40b93460d0ece438f03d686c1791e Author: Larry Gadallah <lga...@gm...> Date: Sat Jun 23 17:24:20 2012 +0200 AR7030+: Error reading signal strength for low signal levels. SF Bug ID 3527331 Action: Using rigctl, request signal strength (STRENGTH) for a low signal level (~ < -100 dBm) Expected result: Read a signal level of -100 or less Actual result: Impossibly large negative value is returned. Error found in initialization of a variable. Some (useful) instrumentation was also added to help with future debugging. diff --git a/aor/ar7030p.c b/aor/ar7030p.c index 23090d8..062eaf3 100644 --- a/aor/ar7030p.c +++ b/aor/ar7030p.c @@ -382,6 +382,10 @@ static int ar7030p_open( RIG * rig ) rig->state.str_cal.table[ i ].val = rig->caps->str_cal.table[ i ].val; rig->state.str_cal.table[ i ].raw = (int) v; + + rig_debug( RIG_DEBUG_VERBOSE, "%s: index %d, val %d, raw %d\n", + __func__, i, rig->state.str_cal.table[ i ].val, + rig->state.str_cal.table[ i ].raw); } if ( RIG_OK == rc ) diff --git a/aor/ar7030p_utils.c b/aor/ar7030p_utils.c index 86bd001..f57657b 100644 --- a/aor/ar7030p_utils.c +++ b/aor/ar7030p_utils.c @@ -971,8 +971,15 @@ int getCalLevel( RIG * rig, unsigned char rawAgc, int *dbm ) assert( NULL != rig ); assert( NULL != dbm ); + rig_debug( RIG_DEBUG_VERBOSE, "%s: raw AGC %03d\n", __func__, rawAgc ); + for ( i = 0; i < rig->state.str_cal.size; i++ ) { + *dbm = rig->state.str_cal.table[ i ].val; + + rig_debug( RIG_DEBUG_VERBOSE, "%s: got cal table[ %d ] dBm value %d\n", __func__, i, *dbm); + + /* if the remaining difference in the raw value is negative */ if ( 0 > ( raw - rig->state.str_cal.table[ i ].raw ) ) { /* calculate step size */ @@ -981,29 +988,62 @@ int getCalLevel( RIG * rig, unsigned char rawAgc, int *dbm ) step = rig->state.str_cal.table[ i ].val - rig->state.str_cal.table[ i - 1 ].val; } + else + { + step = 20; /* HACK - try and fix mimimum AGC readings */ + } + + rig_debug( RIG_DEBUG_VERBOSE, "%s: got step size %d\n", __func__, step); - /* interpolate final value */ + /* interpolate the final value */ + *dbm -= step; /* HACK - table seems to be off by one index */ *dbm += (int) ( ( (double) raw / (double) rig->state.str_cal.table[ i ].raw ) * (double) step ); + rig_debug( RIG_DEBUG_VERBOSE, "%s: interpolated dBm value %d\n", __func__, *dbm); + + /* we're done, stop going through the table */ break; } else { + /* calculate the remaining raw value */ raw = raw - rig->state.str_cal.table[ i ].raw; - *dbm = rig->state.str_cal.table[ i ].val; + + rig_debug( RIG_DEBUG_VERBOSE, "%s: residual raw value %d\n", __func__, raw); } } - /* Factor in RFAGC setting */ - rc = readByte( rig, WORKING, RFGAIN, &v ); + /* Factor in Attenuator/preamp settings */ + /* 40 0x028 rxcon 3 bytes Receiver control register mapping */ + rc = readByte( rig, WORKING, RXCON, &v ); if ( RIG_OK == rc ) { - *dbm += ( (int) v * -10 ) + 10; + if ( 0x80 & v ) /* byte 1 bit 7 rx_atn Attenuator enable */ + { + if ( 0xa0 & v ) + { + /* HACK - Settings menu on radio says Atten step is 10 dB, not 20 dB */ + *dbm += 20; /* byte 1 bit 5 rx_atr Atten : 0 = 20dB / 1 = 40dB */ + } + else + { + *dbm += 10; /* byte 1 bit 5 rx_atr Atten : 0 = 20dB / 1 = 40dB */ + } + } + + if ( 0x10 & v ) /* byte 1 bit 4 rx_pre Preamplifier enable */ + { + *dbm -= 10; + } + + rig_debug( RIG_DEBUG_VERBOSE, "%s: RXCON 0x%02x, adjusted dBm value %d\n", __func__, (int) v, *dbm); } /* Adjust to S9 == 0 scale */ *dbm += 73; /* S9 == -73 dBm */ + rig_debug( RIG_DEBUG_VERBOSE, "%s: S9 adjusted dBm value %d\n", __func__, *dbm); + return ( rc ); } ----------------------------------------------------------------------- Summary of changes: aor/ar7030p.c | 4 ++++ aor/ar7030p_utils.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 5 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |