MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / flrig_get_level

Function flrig_get_level

rigs/dummy/flrig.c:2344–2451  ·  view source on GitHub ↗

* flrig_get_level * Assumes rig!=NULL, STATE(rig)->priv!=NULL, val!=NULL */

Source from the content-addressed store, hash-verified

2342* Assumes rig!=NULL, STATE(rig)->priv!=NULL, val!=NULL
2343*/
2344static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
2345{
2346 char value[MAXARGLEN];
2347 char *cmd;
2348 int retval;
2349 struct flrig_priv_data *priv = (struct flrig_priv_data *) STATE(rig)->priv;
2350
2351 ENTERFUNC;
2352 rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
2353 rig_strvfo(vfo));
2354
2355
2356 switch (level)
2357 {
2358 case RIG_LEVEL_AF: cmd = "rig.get_volume"; break;
2359
2360 case RIG_LEVEL_RF: cmd = "rig.get_rfgain"; break;
2361
2362 case RIG_LEVEL_MICGAIN: cmd = "rig.get_micgain"; break;
2363
2364 case RIG_LEVEL_STRENGTH: cmd = "rig.get_DBM"; break;
2365
2366 case RIG_LEVEL_SWR:
2367 cmd = "rig.get_swrmeter";
2368
2369 // we'll try get_SWR at least once to see if it works
2370 if (priv->get_SWR) { cmd = "rig.get_SWR"; }
2371
2372 break;
2373
2374 case RIG_LEVEL_RFPOWER: cmd = "rig.get_power"; break;
2375
2376 case RIG_LEVEL_RFPOWER_METER_WATTS:
2377 case RIG_LEVEL_RFPOWER_METER: cmd = "rig.get_pwrmeter"; break;
2378
2379 case RIG_LEVEL_AGC: cmd = "rig.get_agc"; break; // flrig 2.0.6+
2380
2381 default:
2382 rig_debug(RIG_DEBUG_ERR, "%s: unknown level=%d\n", __func__, (int)level);
2383 RETURNFUNC(-RIG_EINVAL);
2384 }
2385
2386 retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
2387
2388 if (retval == -RIG_ENAVAIL && strcmp(cmd, "rig.get_SWR") == 0)
2389 {
2390 priv->get_SWR = 0;
2391 cmd = "rig.get_swrmeter"; // revert to old flrig method
2392 retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
2393 }
2394
2395 if (retval != RIG_OK)
2396 {
2397 rig_debug(RIG_DEBUG_ERR, "%s: flrig_transaction failed retval=%s\n", __func__,
2398 rigerror(retval));
2399 RETURNFUNC(retval);
2400 }
2401

Callers

nothing calls this directly

Calls 5

rig_debugFunction · 0.85
rig_strvfoFunction · 0.85
flrig_transactionFunction · 0.85
rigerrorFunction · 0.85
interpolateSWRFunction · 0.85

Tested by

no test coverage detected