Skip to content

Commit aeec1ab

Browse files
authored
Merge pull request #18 from tectrolabs/updates_for_FreeBSD
Increased timeout for read operations and added support to FreeBSD 14
2 parents 001f2fa + df05199 commit aeec1ab

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

linux-and-macOS/swrng/api-inc/USBSerialDevice.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* USBSerialDevice.h
3-
* Ver 1.2
3+
* Ver 1.3
44
*/
55

66
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -30,6 +30,10 @@
3030
#include <ctype.h>
3131
#include <sstream>
3232

33+
#ifdef __FreeBSD__
34+
#include <sys/param.h>
35+
#endif
36+
3337
class USBSerialDevice {
3438
public:
3539
USBSerialDevice();

linux-and-macOS/swrng/api-src/USBSerialDevice.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* USBSerialDevice.cpp
3-
* Ver 1.5
3+
* Ver 1.6
44
*/
55

66
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -71,8 +71,12 @@ bool USBSerialDevice::connect(const char *devicePath) {
7171
opts.c_iflag &= ~(INLCR | IGNCR | ICRNL | IXON | IXOFF);
7272
opts.c_oflag &= ~(ONLCR | OCRNL);
7373

74-
// Set time out to 100 milliseconds for read serial device operations
74+
// Set time out or read serial device operations
75+
#ifdef __FreeBSD__
76+
opts.c_cc[VTIME] = 2;
77+
#else
7578
opts.c_cc[VTIME] = 1;
79+
#endif
7680
opts.c_cc[VMIN] = 0;
7781

7882
retVal = tcsetattr(m_fd, TCSANOW, &opts);
@@ -220,8 +224,13 @@ void USBSerialDevice::scan_available_devices() {
220224
continue;
221225
}
222226
if (device_candidate) {
227+
#if __FreeBSD_version < 1400000
223228
if (strstr(line, "VCOM") != nullptr && strstr(line, "umodem") != nullptr) {
224-
// Found VCOM description. Extract 'cuaU' number.
229+
#else
230+
if (strstr(line, "umodem") != nullptr) {
231+
232+
#endif
233+
// Found description. Extract 'cuaU' number.
225234
char *p = strstr(line, "umodem");
226235
if (p == nullptr) {
227236
continue;

0 commit comments

Comments
 (0)