Exemplo n.º 1
0
/**
 * \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
 */
int par_ptt_get(hamlib_port_t *p, ptt_t *pttx)
{
	switch (p->type.ptt) {
	case RIG_PTT_PARALLEL: {
		unsigned char ctl;
		int status;

		par_lock(p);
		status = par_read_control(p, &ctl);
		par_unlock(p);

		*pttx = (ctl & PARPORT_CONTROL_INIT) &&
			!(ctl & PARPORT_CONTROL_STROBE) ?
			RIG_PTT_ON : RIG_PTT_OFF;
		return status;
	}

	default:
		rig_debug(RIG_DEBUG_ERR, "Unsupported PTT type %d\n",
			  p->type.ptt);
		return -RIG_ENAVAIL;
	}

	return RIG_OK;
}
Exemplo n.º 2
0
/**
 * \brief Set or unset Push to talk bit on Parallel Port
 * \param p
 * \param pttx RIG_PTT_ON --> Set PTT
 * \return RIG_OK or < 0 error
 */
int par_ptt_set(hamlib_port_t *p, ptt_t pttx)
{
	switch(p->type.ptt) {
	case RIG_PTT_PARALLEL:
		{
		unsigned char ctl;
		int status;

		par_lock (p);
		status = par_read_control(p, &ctl);
		if (status != RIG_OK)
			return status;

		/* Enable CW & PTT - /STROBE bit (pin 1) */
		ctl &= ~PARPORT_CONTROL_STROBE;

		/* TODO: kill parm.parallel.pin? */

		/* PTT keying - /INIT bit (pin 16) (inverted) */
		if (pttx == RIG_PTT_ON)
			ctl |= PARPORT_CONTROL_INIT;
		else
			ctl &= ~PARPORT_CONTROL_INIT;

		status = par_write_control(p, ctl);
		par_unlock (p);
		return status;
		}
	default:
		rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
						p->type.ptt);
		return -RIG_EINVAL;
	}
	return RIG_OK;
}