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

Function serial_open

src/serial.c:215–365  ·  view source on GitHub ↗

* \brief Open serial port using port data only * \param rp port data structure (must spec port id eg /dev/ttyS1) * \return RIG_OK or < 0 if error */

Source from the content-addressed store, hash-verified

213 * \return RIG_OK or < 0 if error
214 */
215int HAMLIB_API serial_open(hamlib_port_t *rp)
216{
217
218 int fd; /* File descriptor for the port */
219 int err;
220
221 if (!rp)
222 {
223 return (-RIG_EINVAL);
224 }
225
226#if defined(WIN32)
227 int retcode = check_com_port_in_use(rp->pathname);
228
229 switch (retcode)
230 {
231 case SER_IN_USE:
232 rig_debug(RIG_DEBUG_ERR, "%s: serial port %s is already open\n", __func__,
233 rp->pathname);
234 return -RIG_EACCESS;
235
236 case SER_NO_EXIST:
237 rig_debug(RIG_DEBUG_ERR, "%s: serial port %s does not exist\n", __func__,
238 rp->pathname);
239 return -RIG_EIO;
240
241 case SER_AVAILABLE:
242 rig_debug(RIG_DEBUG_VERBOSE, "%s: serial port %s is OK\n", __func__, rp->pathname);
243 break;
244 }
245
246#endif
247
248
249 rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rp->pathname);
250
251 if (!strncmp(rp->pathname, "uh-rig", 6))
252 {
253 /*
254 * If the pathname is EXACTLY "uh-rig", try to use a microHam device
255 * rather than a conventional serial port.
256 * The microHam devices ALWAYS use "no parity", and can either use no handshake
257 * or hardware handshake. Return with error if something else is requested.
258 */
259 if (rp->parm.serial.parity != RIG_PARITY_NONE)
260 {
261 return (-RIG_EIO);
262 }
263
264 if ((rp->parm.serial.handshake != RIG_HANDSHAKE_HARDWARE) &&
265 (rp->parm.serial.handshake != RIG_HANDSHAKE_NONE))
266 {
267 return (-RIG_EIO);
268 }
269
270 /*
271 * Note that serial setup is also don in uh_open_radio.
272 * So we need to dig into serial_setup().

Callers 14

lowe.cFile · 0.85
rshfiq_openFunction · 0.85
icom.cFile · 0.85
yaesu.cFile · 0.85
elad.cFile · 0.85
uniden.cFile · 0.85
kenwood.cFile · 0.85
adat.cFile · 0.85
anytone.cFile · 0.85
drake.cFile · 0.85
rot_openFunction · 0.85
port_openFunction · 0.85

Calls 6

check_com_port_in_useFunction · 0.85
rig_debugFunction · 0.85
uh_open_radioFunction · 0.85
hl_usleepFunction · 0.85
serial_setupFunction · 0.85
serial_flushFunction · 0.85

Tested by

no test coverage detected