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

Function win32_serial_open

lib/termios.c:1356–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1354----------------------------------------------------------*/
1355
1356int win32_serial_open(const char *filename, int flags, ...)
1357{
1358 struct termios_list *index;
1359 char message[756];
1360 char fullfilename[256];
1361
1362 ENTER("serial_open");
1363
1364 fullfilename[sizeof(fullfilename) - 1] = '\0';
1365
1366 /* according to http://support.microsoft.com/kb/115831
1367 * this is necessary for COM ports larger than COM9 */
1368 if (memcmp(filename, "\\\\.\\", 4) != 0)
1369 {
1370 SNPRINTF(fullfilename, sizeof(fullfilename) - 1, "\\\\.\\%s", filename);
1371 }
1372 else
1373 {
1374 strncpy(fullfilename, filename, sizeof(fullfilename) - 1);
1375 }
1376
1377 if (port_opened(fullfilename))
1378 {
1379 report("Port is already opened\n");
1380 return (-1);
1381 }
1382
1383 index = add_port(fullfilename);
1384
1385 if (!index)
1386 {
1387 report("serial_open !index\n");
1388 return (-1);
1389 }
1390
1391 index->interrupt = 0;
1392 index->tx_happened = 0;
1393
1394 if (open_port(index))
1395 {
1396 SNPRINTF(message, sizeof(message),
1397 "serial_open(): Invalid Port Reference for %s\n",
1398 fullfilename);
1399 report(message);
1400 win32_serial_close(index->fd);
1401 return -1;
1402 }
1403
1404 if (check_port_capabilities(index))
1405 {
1406 report("check_port_capabilities!");
1407 win32_serial_close(index->fd);
1408 return -1;
1409 }
1410
1411 init_termios(index->ttyset);
1412 init_serial_struct(index->sstruct);
1413

Callers

nothing calls this directly

Calls 8

port_openedFunction · 0.85
add_portFunction · 0.85
open_portFunction · 0.85
win32_serial_closeFunction · 0.85
check_port_capabilitiesFunction · 0.85
init_termiosFunction · 0.85
init_serial_structFunction · 0.85
tcsetattrFunction · 0.85

Tested by

no test coverage detected