MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SerialCustomBaud.cpp
Go to the documentation of this file.
2
3#if defined(MAYAFLUX_PLATFORM_LINUX)
4
5#include <asm/termbits.h>
6#include <sys/ioctl.h>
7
9
10int set_custom_baud(int fd, uint32_t baud)
11{
12 termios2 settings {};
13 if (::ioctl(fd, TCGETS2, &settings) != 0) {
14 return errno;
15 }
16
17 settings.c_cflag &= ~static_cast<tcflag_t>(CBAUD);
18 settings.c_cflag |= BOTHER;
19 settings.c_ispeed = baud;
20 settings.c_ospeed = baud;
21
22 return ::ioctl(fd, TCSETS2, &settings) == 0 ? 0 : errno;
23}
24
25}
26
27#elif defined(MAYAFLUX_PLATFORM_MACOS)
28
29#include <IOKit/serial/ioss.h>
30#include <sys/ioctl.h>
31
32namespace MayaFlux::Core::detail {
33
34int set_custom_baud(int fd, uint32_t baud)
35{
36 speed_t speed = baud;
37 return ::ioctl(fd, IOSSIOSPEED, &speed) == 0 ? 0 : errno;
38}
39
40}
41
42#else
43
45
46int set_custom_baud(int, uint32_t)
47{
48 return ENOTSUP;
49}
50
51}
52
53#endif
int set_custom_baud(int, uint32_t)
Set a baud rate the portable serial option table does not accept.
double speed(const Memory::HistoryBuffer< double > &history, double dt) noexcept
Absolute value of a scalar first difference.