* \brief Get state of Push to Talk from Parallel Port * \param p * \param pttx return value (must be non NULL) * \return RIG_OK or < 0 error */
| 678 | * \return RIG_OK or < 0 error |
| 679 | */ |
| 680 | int par_ptt_get(hamlib_port_t *p, ptt_t *pttx) |
| 681 | { |
| 682 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 683 | |
| 684 | switch (p->type.ptt) |
| 685 | { |
| 686 | case RIG_PTT_PARALLEL: |
| 687 | { |
| 688 | unsigned char ctl; |
| 689 | int status; |
| 690 | |
| 691 | par_lock(p); |
| 692 | status = par_read_control(p, &ctl); |
| 693 | par_unlock(p); |
| 694 | |
| 695 | if (status == RIG_OK) |
| 696 | { |
| 697 | *pttx = (ctl & PARPORT_CONTROL_INIT) && |
| 698 | !(ctl & PARPORT_CONTROL_STROBE) ? |
| 699 | RIG_PTT_ON : RIG_PTT_OFF; |
| 700 | } |
| 701 | |
| 702 | return status; |
| 703 | } |
| 704 | |
| 705 | default: |
| 706 | rig_debug(RIG_DEBUG_ERR, |
| 707 | "%s: unsupported PTT type %d\n", |
| 708 | __func__, |
| 709 | p->type.ptt); |
| 710 | return -RIG_ENAVAIL; |
| 711 | } |
| 712 | |
| 713 | return RIG_OK; |
| 714 | } |
| 715 | |
| 716 | |
| 717 | /** |
no test coverage detected