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