From 10205e06cb1de3b65e81dfcdc5a20fe890155162 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:06:27 +1000 Subject: [PATCH] Add host uart support for MacOS (#7095) --- esphome/components/uart/uart_component_host.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/esphome/components/uart/uart_component_host.cpp b/esphome/components/uart/uart_component_host.cpp index d8d2fd75b8..40d3e91ab2 100644 --- a/esphome/components/uart/uart_component_host.cpp +++ b/esphome/components/uart/uart_component_host.cpp @@ -5,8 +5,8 @@ #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#ifndef __linux__ -#error This HostUartComponent implementation is only for Linux +#if !(defined(__linux__) || defined(__APPLE__)) +#error This HostUartComponent implementation is not supported on this host OS #endif #include @@ -24,6 +24,9 @@ namespace { speed_t get_baud(int baud) { +#ifdef __APPLE__ + return baud; +#else switch (baud) { case 50: return B50; @@ -88,6 +91,7 @@ speed_t get_baud(int baud) { default: return B0; } +#endif } } // namespace