0002-SerialPort.cpp-don-t-use-high-baudrates-when-not-ava.patch 1.9 KB

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