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

Function port_close

src/iofunc.c:384–423  ·  view source on GitHub ↗

* \brief Close a hamlib_port * \param p rig port descriptor * \param port_type equivalent rig port type * \return status */

Source from the content-addressed store, hash-verified

382 * \return status
383 */
384int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type)
385{
386 int ret = RIG_OK;
387
388 if (p->fd != -1)
389 {
390 switch (port_type)
391 {
392 case RIG_PORT_SERIAL:
393 ret = ser_close(p);
394 break;
395
396#if defined(HAVE_LIBUSB)
397
398 case RIG_PORT_USB:
399 ret = usb_port_close(p);
400 break;
401#endif
402
403 case RIG_PORT_NETWORK:
404 case RIG_PORT_UDP_NETWORK:
405 ret = network_close(p);
406 break;
407
408 default:
409 rig_debug(RIG_DEBUG_ERR, "%s(): Unknown port type %d\n",
410 __func__, port_type);
411 HL_FALLTHROUGH
412
413 case RIG_PORT_DEVICE:
414 ret = close(p->fd);
415 }
416
417 p->fd = -1;
418 }
419
420 close_sync_data_pipe(p);
421
422 return (ret);
423}
424
425
426#if defined(WIN32) && !defined(HAVE_TERMIOS_H)

Callers 4

dttsp_closeFunction · 0.85
rig_openFunction · 0.85
rig_closeFunction · 0.85
grbl_net_closeFunction · 0.85

Calls 5

ser_closeFunction · 0.85
usb_port_closeFunction · 0.85
network_closeFunction · 0.85
rig_debugFunction · 0.85
close_sync_data_pipeFunction · 0.85

Tested by

no test coverage detected