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

Function rot_open

src/rotator.c:368–588  ·  view source on GitHub ↗

* \brief Open the communication channel to the rotator. * * \param rot The #ROT handle of the rotator to be opened. * * Opens the communication channel to a rotator for which the #ROT handle has * been passed. * * \return RIG_OK if the operation has been successful, otherwise a **negative * value** if an error occurred (in which case, cause is set appropriately). * * \retval RIG_OK Commu

Source from the content-addressed store, hash-verified

366 * \sa rot_init(), rot_close()
367 */
368int HAMLIB_API rot_open(ROT *rot)
369{
370 const struct rot_caps *caps;
371 struct rot_state *rs;
372 hamlib_port_t *rotp = ROTPORT(rot);
373 hamlib_port_t *rotp2 = ROTPORT2(rot);
374 int status;
375 int net1, net2, net3, net4, port;
376 deferred_config_item_t *item;
377
378 rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
379
380 if (!rot || !rot->caps)
381 {
382 return -RIG_EINVAL;
383 }
384
385 caps = rot->caps;
386 rs = ROTSTATE(rot);
387
388 if (rs->comm_state)
389 {
390 return -RIG_EINVAL;
391 }
392
393 rotp->fd = -1;
394 rotp2->fd = -1;
395
396 // determine if we have a network address
397 if (sscanf(rotp->pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
398 &port) == 5)
399 {
400 char *type = "TCP";
401
402 if (rot->caps->port_type == RIG_PORT_UDP_NETWORK)
403 {
404 rotp->type.rig = RIG_PORT_UDP_NETWORK;
405 type = "UDP";
406 }
407 else
408 {
409 rotp->type.rig = RIG_PORT_NETWORK;
410 }
411
412 rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s:%s\n", __func__,
413 rotp->pathname, type);
414 }
415
416 if (sscanf(rotp2->pathname, "%d.%d.%d.%d:%d", &net1, &net2, &net3, &net4,
417 &port) == 5)
418 {
419 rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s\n", __func__,
420 rotp2->pathname);
421
422 if (rot->caps->port_type == RIG_PORT_UDP_NETWORK)
423 {
424 rotp->type.rig = RIG_PORT_UDP_NETWORK;
425 }

Callers 4

openMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 9

rig_debugFunction · 0.85
serial_openFunction · 0.85
par_openFunction · 0.85
usb_port_openFunction · 0.85
network_openFunction · 0.85
add_opened_rotFunction · 0.85
ser_set_dtrFunction · 0.85
ser_set_rtsFunction · 0.85
rot_set_confFunction · 0.85

Tested by

no test coverage detected