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

Function par_write_control

src/parallel.c:335–407  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

333 * \param control
334 */
335int 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),

Callers 5

write_latchFunction · 0.85
par_ptt_setFunction · 0.85
setDirectionFunction · 0.85
ars_clear_ctrl_pinFunction · 0.85
ars_set_ctrl_pinFunction · 0.85

Calls 1

rig_debugFunction · 0.85

Tested by

no test coverage detected