* \brief Set control data for Parallel Port * \param port * \param control */
| 333 | * \param control |
| 334 | */ |
| 335 | int HAMLIB_API par_write_control(hamlib_port_t *port, unsigned char control) |
| 336 | { |
| 337 | #ifdef HAVE_LINUX_PPDEV_H |
| 338 | int status; |
| 339 | unsigned char ctrl = control ^ CP_ACTIVE_LOW_BITS; |
| 340 | status = ioctl(port->fd, PPWCONTROL, &ctrl); |
| 341 | |
| 342 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 343 | |
| 344 | if (status < 0) |
| 345 | { |
| 346 | rig_debug(RIG_DEBUG_ERR, |
| 347 | "%s: ioctl(PPWCONTROL) failed: %s\n", |
| 348 | __func__, |
| 349 | strerror(errno)); |
| 350 | } |
| 351 | |
| 352 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 353 | #elif defined(HAVE_DEV_PPBUS_PPI_H) |
| 354 | int status; |
| 355 | unsigned char ctrl = control ^ CP_ACTIVE_LOW_BITS; |
| 356 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 357 | |
| 358 | status = ioctl(port->fd, PPISCTRL, &ctrl); |
| 359 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 360 | #elif defined(__WIN64__) || defined(__WIN32__) |
| 361 | unsigned char ctr = control; |
| 362 | unsigned char dummyc; |
| 363 | unsigned int dummy = 0; |
| 364 | const unsigned char wm = (C1284_NSTROBE |
| 365 | | C1284_NAUTOFD |
| 366 | | C1284_NINIT |
| 367 | | C1284_NSELECTIN); |
| 368 | intptr_t handle; |
| 369 | |
| 370 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 371 | |
| 372 | if (ctr & 0x20) |
| 373 | { |
| 374 | rig_debug(RIG_DEBUG_WARN, |
| 375 | "%s: use ieee1284_data_dir to change data line direction!\n", |
| 376 | __func__); |
| 377 | } |
| 378 | |
| 379 | /* Deal with inversion issues. */ |
| 380 | ctr ^= wm & C1284_INVERTED; |
| 381 | ctr = (ctr & ~wm) ^ (ctr & wm); |
| 382 | |
| 383 | handle = _get_osfhandle(port->fd); |
| 384 | |
| 385 | if (handle != (intptr_t)INVALID_HANDLE_VALUE) |
| 386 | { |
| 387 | if (!(DeviceIoControl((HANDLE)handle, |
| 388 | NT_IOCTL_CONTROL, |
| 389 | &ctr, |
| 390 | sizeof(ctr), |
| 391 | &dummyc, |
| 392 | sizeof(dummyc), |
no test coverage detected