* rig_check_backend * check the backend declaring this model has been loaded * and if not loaded already, load it! * This permits seamless operation in rig_init. */ @cond Doxygen_Suppress
| 294 | */ |
| 295 | //! @cond Doxygen_Suppress |
| 296 | int HAMLIB_API rig_check_backend(rig_model_t rig_model) |
| 297 | { |
| 298 | const struct rig_caps *caps; |
| 299 | int be_idx; |
| 300 | int retval; |
| 301 | // int i; |
| 302 | |
| 303 | /* already loaded ? */ |
| 304 | caps = rig_get_caps(rig_model); |
| 305 | |
| 306 | if (caps) |
| 307 | { |
| 308 | return RIG_OK; |
| 309 | } |
| 310 | |
| 311 | #if 0 // this stopped a 2nd rig_init call with a valid model to fail -- reversing |
| 312 | |
| 313 | // hmmm...no caps so did we already load the rigs? |
| 314 | for (n = 0, i = 0; i < RIGLSTHASHSZ; i++) |
| 315 | { |
| 316 | if (rig_hash_table[i]) { ++n; } |
| 317 | } |
| 318 | |
| 319 | |
| 320 | if (n > 1) |
| 321 | { |
| 322 | rig_debug(RIG_DEBUG_ERR, "%s: rig model %u not found and rig count=%d\n", |
| 323 | __func__, rig_model, n); |
| 324 | return -RIG_ENAVAIL; |
| 325 | } |
| 326 | |
| 327 | #endif |
| 328 | |
| 329 | be_idx = rig_lookup_backend(rig_model); |
| 330 | |
| 331 | /* |
| 332 | * Never heard about this backend family! |
| 333 | */ |
| 334 | if (be_idx == -1) |
| 335 | { |
| 336 | rig_debug(RIG_DEBUG_VERBOSE, |
| 337 | "rig_check_backend: unsupported backend %u for model %u\n", |
| 338 | RIG_BACKEND_NUM(rig_model), |
| 339 | rig_model); |
| 340 | return -RIG_ENAVAIL; |
| 341 | } |
| 342 | |
| 343 | // do we need to load the backend? |
| 344 | // if (rig_backend_list[be_idx].be_init_all == 0) |
| 345 | { |
| 346 | retval = rig_load_backend(rig_backend_list[be_idx].be_name); |
| 347 | } |
| 348 | #if 0 |
| 349 | else |
| 350 | { |
| 351 | retval = RIG_OK; |
| 352 | } |
| 353 |
no test coverage detected