* \brief Send data on Parallel port * \param port * \param data */
| 232 | * \param data |
| 233 | */ |
| 234 | int HAMLIB_API par_write_data(hamlib_port_t *port, unsigned char data) |
| 235 | { |
| 236 | #ifdef HAVE_LINUX_PPDEV_H |
| 237 | int status; |
| 238 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 239 | |
| 240 | status = ioctl(port->fd, PPWDATA, &data); |
| 241 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 242 | #elif defined(HAVE_DEV_PPBUS_PPI_H) |
| 243 | int status; |
| 244 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 245 | |
| 246 | status = ioctl(port->fd, PPISDATA, &data); |
| 247 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 248 | #elif defined(__WIN64__) || defined(__WIN32__) |
| 249 | unsigned int dummy = 0; |
| 250 | |
| 251 | intptr_t handle; |
| 252 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 253 | |
| 254 | |
| 255 | handle = _get_osfhandle(port->fd); |
| 256 | |
| 257 | if (handle != (intptr_t)INVALID_HANDLE_VALUE) |
| 258 | { |
| 259 | if (!(DeviceIoControl((HANDLE)handle, NT_IOCTL_DATA, &data, sizeof(data), |
| 260 | NULL, 0, (LPDWORD)&dummy, NULL))) |
| 261 | { |
| 262 | rig_debug(RIG_DEBUG_ERR, "%s: DeviceIoControl failed!\n", __func__); |
| 263 | return -RIG_EIO; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | return RIG_OK; |
| 268 | #else |
| 269 | return -RIG_ENIMPL; |
| 270 | #endif |
| 271 | } |
| 272 | |
| 273 | |
| 274 | /** |
no test coverage detected