This makes libdivecomputer build via Android NDK. Its currently unusable due to the fact that Android usually doesn't provide any kernel serial drivers.
Signed-off-by: Anton Lundin glance@acc.umu.se --- src/serial_posix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/serial_posix.c b/src/serial_posix.c index 2748957..fc0e79e 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -53,6 +53,11 @@ #define NOPTY 1 #endif
+/* Android is missing tcdrain, so use ioctl version instead */ +#ifdef __ANDROID__ +#define tcdrain(x) ioctl(x, TCSBRK, 1) +#endif + #include "serial.h" #include "context-private.h"
@@ -433,7 +438,7 @@ serial_configure (serial_t *device, int baudrate, int databits, int parity, int
// Configure a custom baudrate if necessary. if (custom) { -#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) +#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) && !defined(__ANDROID__) // Get the current settings. struct serial_struct ss; if (ioctl (device->fd, TIOCGSERIAL, &ss) != 0 && NOPTY) {
On 2014-03-27 20:44, Anton Lundin wrote:
This makes libdivecomputer build via Android NDK. Its currently unusable due to the fact that Android usually doesn't provide any kernel serial drivers.
I'll apply your patch, although with a slight modification. I prefer the tcdrain #ifdef right where the function is being called, rather than redirecting one function to another. I find that confusing when debugging.
But the reason why I'm replying to you is actually the TIOCGSERIAL part. Can you tell me what's going wrong there? Is TIOCGSERIAL defined on Android, but not supported somehow? Maybe the serial_struct struct is missing in bionic?
I have just pushed some changes related to the low latency stuff. Those will probably need similar changes. So that's why I'm asking.
Jef
On 28 March, 2014 - Jef Driesen wrote:
On 2014-03-27 20:44, Anton Lundin wrote:
This makes libdivecomputer build via Android NDK. Its currently unusable due to the fact that Android usually doesn't provide any kernel serial drivers.
I'll apply your patch, although with a slight modification. I prefer the tcdrain #ifdef right where the function is being called, rather than redirecting one function to another. I find that confusing when debugging.
But the reason why I'm replying to you is actually the TIOCGSERIAL part. Can you tell me what's going wrong there? Is TIOCGSERIAL defined on Android, but not supported somehow? Maybe the serial_struct struct is missing in bionic?
Yepp, its the serial_struct struct thats missing from bionic.
I have just pushed some changes related to the low latency stuff. Those will probably need similar changes. So that's why I'm asking.
So, after the low latency patch this fixes it:
--- i/src/serial_posix.c +++ w/src/serial_posix.c @@ -523,7 +523,7 @@ serial_set_latency (serial_t *device, unsigned int milliseconds) if (device == NULL) return -1; // EINVAL (Invalid argument)
-#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) +#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) && !defined(__ANDROID__) // Get the current settings. struct serial_struct ss; if (ioctl (device->fd, TIOCGSERIAL, &ss) != 0 && NOPTY) {
Just tell me if you would like me to redo the patch.
//Anton
On 2014-03-28 11:41, Anton Lundin wrote:
On 28 March, 2014 - Jef Driesen wrote:
On 2014-03-27 20:44, Anton Lundin wrote:
This makes libdivecomputer build via Android NDK. Its currently unusable due to the fact that Android usually doesn't provide any kernel serial drivers.
I'll apply your patch, although with a slight modification. I prefer the tcdrain #ifdef right where the function is being called, rather than redirecting one function to another. I find that confusing when debugging.
But the reason why I'm replying to you is actually the TIOCGSERIAL part. Can you tell me what's going wrong there? Is TIOCGSERIAL defined on Android, but not supported somehow? Maybe the serial_struct struct is missing in bionic?
Yepp, its the serial_struct struct thats missing from bionic.
Looks like my guess was right :-)
I have just pushed some changes related to the low latency stuff. Those will probably need similar changes. So that's why I'm asking.
So, after the low latency patch this fixes it:
--- i/src/serial_posix.c +++ w/src/serial_posix.c @@ -523,7 +523,7 @@ serial_set_latency (serial_t *device, unsigned int milliseconds) if (device == NULL) return -1; // EINVAL (Invalid argument)
-#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) +#if defined(TIOCGSERIAL) && defined(TIOCSSERIAL) && !defined(__ANDROID__) // Get the current settings. struct serial_struct ss; if (ioctl (device->fd, TIOCGSERIAL, &ss) != 0 && NOPTY) {
Just tell me if you would like me to redo the patch.
No need to redo. I already did it myself. Patch has been pushed.
Jef