* \brief Receive data on Parallel port * \param port * \param data */
| 277 | * \param data |
| 278 | */ |
| 279 | int HAMLIB_API par_read_data(hamlib_port_t *port, unsigned char *data) |
| 280 | { |
| 281 | #ifdef HAVE_LINUX_PPDEV_H |
| 282 | int status; |
| 283 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 284 | |
| 285 | status = ioctl(port->fd, PPRDATA, data); |
| 286 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 287 | #elif defined(HAVE_DEV_PPBUS_PPI_H) |
| 288 | int status; |
| 289 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 290 | |
| 291 | status = ioctl(port->fd, PPIGDATA, &data); |
| 292 | return status == 0 ? RIG_OK : -RIG_EIO; |
| 293 | #elif defined(__WIN64__) || defined(__WIN32__) |
| 294 | unsigned char ret = 0; |
| 295 | unsigned int dummy = 0; |
| 296 | |
| 297 | intptr_t handle; |
| 298 | |
| 299 | rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); |
| 300 | |
| 301 | handle = _get_osfhandle(port->fd); |
| 302 | |
| 303 | if (handle != (intptr_t)INVALID_HANDLE_VALUE) |
| 304 | { |
| 305 | if (!(DeviceIoControl((HANDLE)handle, |
| 306 | NT_IOCTL_STATUS, |
| 307 | NULL, |
| 308 | 0, |
| 309 | &ret, |
| 310 | sizeof(ret), |
| 311 | (LPDWORD)&dummy, |
| 312 | NULL))) |
| 313 | { |
| 314 | rig_debug(RIG_DEBUG_ERR, |
| 315 | "%s: DeviceIoControl failed!\n", |
| 316 | __func__); |
| 317 | |
| 318 | return -RIG_EIO; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | *data = ret ^ S1284_INVERTED; |
| 323 | return RIG_OK; |
| 324 | #else |
| 325 | return -RIG_ENIMPL; |
| 326 | #endif |
| 327 | } |
| 328 | |
| 329 | |
| 330 | /** |
no test coverage detected