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

Function par_read_control

src/parallel.c:415–477  ·  view source on GitHub ↗

* \brief Read control data for Parallel Port * \param port * \param control */

Source from the content-addressed store, hash-verified

413 * \param control
414 */
415int HAMLIB_API par_read_control(hamlib_port_t *port, unsigned char *control)
416{
417
418#ifdef HAVE_LINUX_PPDEV_H
419 int status;
420 unsigned char ctrl;
421
422 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
423 status = ioctl(port->fd, PPRCONTROL, &ctrl);
424
425 if (status < 0)
426 {
427 rig_debug(RIG_DEBUG_ERR,
428 "%s: ioctl(PPRCONTROL) failed: %s\n",
429 __func__,
430 strerror(errno));
431 }
432
433 *control = ctrl ^ CP_ACTIVE_LOW_BITS;
434 return status == 0 ? RIG_OK : -RIG_EIO;
435#elif defined(HAVE_DEV_PPBUS_PPI_H)
436 int status;
437 unsigned char ctrl;
438
439 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
440 status = ioctl(port->fd, PPIGCTRL, &ctrl);
441 *control = ctrl ^ CP_ACTIVE_LOW_BITS;
442 return status == 0 ? RIG_OK : -RIG_EIO;
443#elif defined(__WIN64__) || defined(__WIN32__)
444 unsigned char ret = 0;
445 unsigned int dummy = 0;
446
447 intptr_t handle;
448
449 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
450 handle = _get_osfhandle(port->fd);
451
452 if (handle != (intptr_t)INVALID_HANDLE_VALUE)
453 {
454 if (!(DeviceIoControl((HANDLE)handle,
455 NT_IOCTL_CONTROL,
456 NULL,
457 0,
458 &ret,
459 sizeof(ret),
460 (LPDWORD)&dummy,
461 NULL)))
462 {
463 rig_debug(RIG_DEBUG_ERR,
464 "%s: DeviceIoControl failed!\n",
465 __func__);
466
467 return -RIG_EIO;
468 }
469 }
470
471 *control = ret ^ S1284_INVERTED;
472

Callers 2

par_ptt_setFunction · 0.85
par_ptt_getFunction · 0.85

Calls 1

rig_debugFunction · 0.85

Tested by

no test coverage detected