1From fc0f031563146b91d255c752a61624f6dd3c14d4 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Tue, 15 Jan 2019 08:33:27 +0100
4Subject: [PATCH] SerialPort.cpp: don't use high baudrates when not available
5
6On certain architectures (namely Sparc), the maximum baud rate exposed
7by the kernel headers is B2000000. Therefore, the current libserial
8code doesn't build for the Sparc and Sparc64 architectures due to
9this.
10
11In order to address this problem, this patch tests the value of
12__MAX_BAUD. If it's higher than B2000000 then we assume we're on an
13architecture that supports all baud rates up to B4000000. Otherwise,
14we simply don't support the baud rates above B2000000.
15
16Fixes build failures such as:
17
18SerialPort.cpp: In member function 'int LibSerial::SerialPort::Implementation::GetBitRate(const LibSerial::BaudRate&) const':
19SerialPort.cpp:1226:14: error: 'BAUD_2000000' is not a member of 'LibSerial::BaudRate'
20         case BaudRate::BAUD_2000000:
21
22Fixes:
23 - http://autobuild.buildroot.org/results/63ba95b6786464fa8e75af64593010df84530079
24
25Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
26[Upstream status: https://github.com/crayzeewulf/libserial/pull/127]
27---
28 src/SerialPort.cpp | 2 ++
29 1 file changed, 2 insertions(+)
30
31diff --git a/src/SerialPort.cpp b/src/SerialPort.cpp
32index e3240eb..18daac0 100644
33--- a/src/SerialPort.cpp
34+++ b/src/SerialPort.cpp
35@@ -1223,6 +1223,7 @@ namespace LibSerial
36             baud_rate_as_int = 1500000 ;
37             break ;
38
39+#if __MAX_BAUD > B2000000
40         case BaudRate::BAUD_2000000:
41             baud_rate_as_int = 2000000 ;
42             break ;
43@@ -1242,6 +1243,7 @@ namespace LibSerial
44         case BaudRate::BAUD_4000000:
45             baud_rate_as_int = 4000000 ;
46             break ;
47+#endif /* __MAX_BAUD */
48         default:
49             // If an incorrect baud rate was specified, throw an exception.
50             throw std::runtime_error(ERR_MSG_INVALID_BAUD_RATE) ;
51--
522.14.1
53
54