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

Function par_read_status

src/parallel.c:486–541  ·  view source on GitHub ↗

* \brief Get parallel port status * \param port * \param status * \return RIG_OK or < 0 for error */

Source from the content-addressed store, hash-verified

484 * \return RIG_OK or < 0 for error
485 */
486int HAMLIB_API par_read_status(hamlib_port_t *port, unsigned char *status)
487{
488
489#ifdef HAVE_LINUX_PPDEV_H
490 int ret;
491 unsigned char sta;
492
493 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
494 ret = ioctl(port->fd, PPRSTATUS, &sta);
495 *status = sta ^ SP_ACTIVE_LOW_BITS;
496 return ret == 0 ? RIG_OK : -RIG_EIO;
497
498#elif defined(HAVE_DEV_PPBUS_PPI_H)
499 int ret;
500 unsigned char sta;
501
502 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
503 ret = ioctl(port->fd, PPIGSTATUS, &sta);
504 *status = sta ^ SP_ACTIVE_LOW_BITS;
505 return ret == 0 ? RIG_OK : -RIG_EIO;
506
507#elif defined(__WIN64__) || defined(__WIN32__)
508 unsigned char ret = 0;
509 unsigned int dummy = 0;
510
511 intptr_t handle;
512
513 rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
514 handle = _get_osfhandle(port->fd);
515
516 if (handle != (intptr_t)INVALID_HANDLE_VALUE)
517 {
518 if (!(DeviceIoControl((HANDLE)handle,
519 NT_IOCTL_STATUS,
520 NULL,
521 0,
522 &ret,
523 sizeof(ret),
524 (LPDWORD)&dummy,
525 NULL)))
526 {
527 rig_debug(RIG_DEBUG_ERR,
528 "%s: DeviceIoControl failed!\n",
529 __func__);
530
531 return -RIG_EIO;
532 }
533 }
534
535 *status = ret ^ S1284_INVERTED;
536
537 return RIG_OK;
538#else
539 return -RIG_ENIMPL;
540#endif
541}
542
543

Callers 1

ars_get_positionFunction · 0.85

Calls 1

rig_debugFunction · 0.85

Tested by

no test coverage detected