libosmocore patch to support custom baud rates on OS X
This patch should allow custom baud-rate setting to work on OS X; tested on Mac OS X 10.7 with a FT232BL-based adapter. diff --git a/src/shared/libosmocore/src/serial.c b/src/shared/libosmocore/src/serial.c index 26cf59d..d702153 100644 --- a/src/shared/libosmocore/src/serial.c +++ b/src/shared/libosmocore/src/serial.c @@ -38,8 +38,9 @@ #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> +#ifdef __linux__ #include <linux/serial.h> - +#endif #include <osmocom/core/serial.h> @@ -155,6 +156,7 @@ osmo_serial_set_baudrate(int fd, speed_t baudrate) int osmo_serial_set_custom_baudrate(int fd, int baudrate) { +#ifdef __linux__ int rc; struct serial_struct ser_info; @@ -174,6 +176,23 @@ osmo_serial_set_custom_baudrate(int fd, int baudrate) } return _osmo_serial_set_baudrate(fd, B38400); /* 38400 is a kind of magic ... */ +#elsif defined(__APPLE__) +#ifndef IOSSIOSPEED +#define IOSSIOSPEED _IOW('T', 2, speed_t) +#endif + int rc; + + unsigned int speed = baudrate; + rc = ioctl(fd, IOSSIOSPEED, &speed); + if (rc < 0) { + dbg.perror("ioctl(IOSSIOSPEED)"); + return -errno; + } + return 0; +#else +#warning osmo_serial_set_custom_baudrate: unsupported platform + return 0; +#endif } /*! \brief Clear any custom baudrate @@ -186,6 +205,7 @@ int osmo_serial_clear_custom_baudrate(int fd) { int rc; +#ifdef __linux__ struct serial_struct ser_info; rc = ioctl(fd, TIOCGSERIAL, &ser_info); @@ -202,7 +222,7 @@ osmo_serial_clear_custom_baudrate(int fd) dbg_perror("ioctl(TIOCSSERIAL)"); return -errno; } - +#endif return 0; }
I can confirm this has fixed the error during the compilation, I've run into a different issue however, while building layer23 module(s) I get: ./configure: line 3461: syntax error near unexpected token `LIBOSMOCORE,' ./configure: line 3461: `PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore)' make: *** [host/layer23/Makefile] Error 2 during the configure, anyone run into that issue? Btw, are you using gcc-4.2 from XCode or you've got a separate build environment from some macports/fink/homebrew? Thanks! Lukas On Wed, Sep 28, 2011 at 8:31 AM, Martin Auer <catchall@blombo.de> wrote:
Am 28.09.2011 um 06:16 schrieb Richard James:
This patch should allow custom baud-rate setting to work on OS X; tested on Mac OS X 10.7 with a FT232BL-based adapter.
Thanks very much, that solved my problem reported some days ago.
<set_custom_baudrate_osx.patch>
Am 02.10.2011 um 06:01 schrieb Lukas Kuzmiak <lukash@backstep.net>:
I can confirm this has fixed the error during the compilation, I've run into a different issue however, while building layer23 module(s) I get:
./configure: line 3461: syntax error near unexpected token `LIBOSMOCORE,' ./configure: line 3461: `PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore)' make: *** [host/layer23/Makefile] Error 2
during the configure, anyone run into that issue?
This is an error I had when my PATH Variable was not set correctly. For building on OSX I recently wrote a wiki entry: http://bb.osmocom.org/trac/wiki/GettingStarted_osx
Btw, are you using gcc-4.2 from XCode or you've got a separate build environment from some macports/fink/homebrew?
Ports and fink will do.
Thanks! Lukas
On Wed, Sep 28, 2011 at 8:31 AM, Martin Auer <catchall@blombo.de> wrote:
Am 28.09.2011 um 06:16 schrieb Richard James:
This patch should allow custom baud-rate setting to work on OS X; tested on Mac OS X 10.7 with a FT232BL-based adapter.
Thanks very much, that solved my problem reported some days ago.
<set_custom_baudrate_osx.patch>
Hey Martin, thanks a lot, after a while I noticed my configure(s) were all messed up with /usr/bin/gcc-4.2 instead of arm-elf-gcc-{version} - I had CC=/usr/bin/gcc-4.2 in my /etc/profile and I haven't noticed that for hours, so now everything seems to be working fine with OS X serial baudrate patch. Thanks for help again. Lukas On Sun, Oct 2, 2011 at 6:51 AM, Martin Auer <catchall@blombo.de> wrote:
Am 02.10.2011 um 06:01 schrieb Lukas Kuzmiak <lukash@backstep.net>:
I can confirm this has fixed the error during the compilation, I've run into a different issue however, while building layer23 module(s) I get:
./configure: line 3461: syntax error near unexpected token `LIBOSMOCORE,' ./configure: line 3461: `PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore)' make: *** [host/layer23/Makefile] Error 2
during the configure, anyone run into that issue?
This is an error I had when my PATH Variable was not set correctly. For building on OSX I recently wrote a wiki entry:
http://bb.osmocom.org/trac/wiki/GettingStarted_osx
Btw, are you using gcc-4.2 from XCode or you've got a separate build environment from some macports/fink/homebrew?
Ports and fink will do.
Thanks! Lukas
On Wed, Sep 28, 2011 at 8:31 AM, Martin Auer < <catchall@blombo.de> catchall@blombo.de> wrote:
Am 28.09.2011 um 06:16 schrieb Richard James:
This patch should allow custom baud-rate setting to work on OS X; tested on Mac OS X 10.7 with a FT232BL-based adapter.
Thanks very much, that solved my problem reported some days ago.
<set_custom_baudrate_osx.patch>
participants (3)
-
Lukas Kuzmiak -
Martin Auer -
Richard James