From 40835b8d80945556d07a58c07f8585dc941e1026 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 27 Nov 2007 15:09:38 +0000 Subject: [PATCH] Added a function to configure the size of the input and output buffers. --- serial.h | 2 ++ serial_posix.c | 13 +++++++++++++ serial_win32.c | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/serial.h b/serial.h index ecf1b67..6527aaf 100644 --- a/serial.h +++ b/serial.h @@ -58,6 +58,8 @@ int serial_configure (serial *device, int baudrate, int databits, int parity, in int serial_set_timeout (serial *device, long timeout /* milliseconds */); +int serial_set_queue_size (serial *device, unsigned int input, unsigned int output); + int serial_read (serial *device, void* data, unsigned int size); int serial_write (serial *device, const void* data, unsigned int size); diff --git a/serial_posix.c b/serial_posix.c index abe0d76..6c8e8d0 100644 --- a/serial_posix.c +++ b/serial_posix.c @@ -323,6 +323,19 @@ serial_set_timeout (serial *device, long timeout) } +// +// Configure the serial port (recommended size of the input/output buffers). +// + +int +serial_set_queue_size (serial *device, unsigned int input, unsigned int output) +{ + if (device == NULL) + return -1; // ERROR_INVALID_PARAMETER (The parameter is incorrect) + + return 0; +} + struct timeouts_t { int interval; int total; diff --git a/serial_win32.c b/serial_win32.c index b951708..7357d91 100644 --- a/serial_win32.c +++ b/serial_win32.c @@ -311,6 +311,23 @@ serial_set_timeout (serial* device, long timeout) return 0; } +// +// Configure the serial port (recommended size of the input/output buffers). +// + +int +serial_set_queue_size (serial *device, unsigned int input, unsigned int output) +{ + if (device == NULL) + return -1; // ERROR_INVALID_PARAMETER (The parameter is incorrect) + + if (!SetupComm (device->hFile, input, output)) { + TRACE ("SetupComm"); + return -1; + } + + return 0; +} int serial_read (serial* device, void* data, unsigned int size)