* \brief Stop rig poll routine * * Stop rig poll routine * * \return RIG_OK or < 0 if error */
| 317 | * \return RIG_OK or < 0 if error |
| 318 | */ |
| 319 | int rig_poll_routine_stop(RIG *rig) |
| 320 | { |
| 321 | struct rig_state *rs = STATE(rig); |
| 322 | rig_poll_routine_priv_data *poll_routine_priv; |
| 323 | |
| 324 | ENTERFUNC; |
| 325 | |
| 326 | if (rs->poll_interval < 1) |
| 327 | { |
| 328 | RETURNFUNC(RIG_OK); |
| 329 | } |
| 330 | |
| 331 | if (rs->poll_routine_priv_data == NULL) |
| 332 | { |
| 333 | RETURNFUNC(-RIG_EINVAL); |
| 334 | } |
| 335 | |
| 336 | rs->poll_routine_thread_run = 0; |
| 337 | |
| 338 | poll_routine_priv = (rig_poll_routine_priv_data *) rs->poll_routine_priv_data; |
| 339 | |
| 340 | if (poll_routine_priv->thread_id != 0) |
| 341 | { |
| 342 | int err = pthread_join(poll_routine_priv->thread_id, NULL); |
| 343 | |
| 344 | if (err) |
| 345 | { |
| 346 | rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__, |
| 347 | strerror(errno)); |
| 348 | // just ignore it |
| 349 | } |
| 350 | |
| 351 | poll_routine_priv->thread_id = 0; |
| 352 | } |
| 353 | |
| 354 | network_publish_rig_poll_data(rig); |
| 355 | |
| 356 | free(rs->poll_routine_priv_data); |
| 357 | rs->poll_routine_priv_data = NULL; |
| 358 | |
| 359 | RETURNFUNC(RIG_OK); |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * \brief set the callback for freq events |
no test coverage detected