Martin Ling
573feabc63
Move all gettimeofday() calls into a wrapper function.
2019-12-28 22:02:19 +01:00
Martin Ling
b457865b8f
windows: Use architecture-specific size limit for WriteFile calls.
2019-12-28 20:43:22 +01:00
Martin Ling
39df7833f7
windows: Use an adaptively sized buffer for nonblocking writes.
2019-12-28 20:43:22 +01:00
Martin Ling
6bd6a8b520
windows: Await completion of previous write before changing config.
2019-12-28 20:43:22 +01:00
Martin Ling
55ab7e0b6b
unix: Fix handling of EAGAIN in sp_nonblocking_write().
2019-12-28 20:43:22 +01:00
Uwe Hermann
81243567bc
Random minor whitespace fixes.
2019-12-28 19:23:30 +01:00
Martin Ling
62ed9f801a
windows: Break out helper function for awaiting previous write completion.
2017-09-13 19:27:50 +02:00
Stefan Tauner
95bad38c5b
Canonicalize symlinks in portnames
...
This allows users to supply symlinks created e.g. by udev rules instead
of the actual device names.
2017-09-13 19:27:50 +02:00
Uwe Hermann
aee7d69195
Fix ERROR_SEM_TIMEOUT issue on Windows.
...
The sp_blocking_write() call was incorrectly returning an error upon
ERROR_SEM_TIMEOUT. It now returns 0 instead.
2016-01-27 12:35:45 +01:00
Uwe Hermann
888fb45d66
Fix sp_blocking_read_next() implementation on Windows.
...
A ReadFile() call needed to check the actual number of bytes read,
instead of assuming all requested bytes were read.
2016-01-22 15:32:00 +01:00
Martin Ling
8062087ab3
Change debug message to "Port not open" when a closed port is used.
...
Fixes bug #710 .
2015-12-29 13:30:30 +01:00
Martin Ling
ae2c5825e7
windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().
...
This fixes bug #707 .
2015-12-09 12:43:11 +01:00
Martin Ling
127d8d0ce7
sp_wait: Avoid overflow of timeout parameter to poll().
2015-10-13 15:04:03 +01:00
Daniel Elstner
1a584c45b0
Build: Include config.h first in all source files
2015-09-13 20:04:31 +02:00
Martin Ling
f77bb46df5
Update copyright notices.
2015-05-31 18:26:53 +02:00
Martin Ling
6b8eee0682
Fix possible use of uninitialised variable in poll() setup.
2015-05-30 21:38:03 +02:00
Martin Ling
e5c2630eee
Add new sp_blocking_read_next() function.
2015-05-27 11:09:26 +02:00
Martin Ling
0188a545c7
windows: Always check and set ReadTotalTimeoutMultiplier.
...
This is not currently touched, but will be by the upcoming
sp_blocking_read_next() function.
2015-05-27 11:09:25 +02:00
Martin Ling
76222ee578
posix: Make sure blocking operations can't time out without trying.
2015-05-27 11:09:25 +02:00
Martin Ling
c3cee38c3b
posix: Consistent debug output when blocking operations time out.
2015-05-27 11:09:25 +02:00
Martin Ling
772c586133
posix: Move FD_ZERO() and FD_SET() calls outside loops.
2015-05-27 11:09:25 +02:00
Martin Ling
27911925c1
windows: Always check return value of GetOverlappedResult().
2015-05-27 11:09:25 +02:00
Martin Ling
bbe566fe1c
windows: Restructure if/else blocks with unnecessary indentation.
2015-05-27 11:09:25 +02:00
Martin Ling
8ebfaf8966
windows: restart_wait_if_needed(): Inline receive buffer check.
...
This removes all the debug spam arising from calling sp_input_waiting().
2015-05-27 11:09:25 +02:00
Martin Ling
21ae5ce197
windows: restart_wait_if_needed(): Skip buffer check if no bytes read.
2015-05-27 11:09:25 +02:00
Martin Ling
94a314a806
windows: Refactor duplicated code into a static function.
2015-05-27 11:09:25 +02:00
Martin Ling
27a58c0521
windows: Avoid unnecessary calls to SetCommTimeouts().
...
This fixes bug #586 .
2015-05-27 11:09:13 +02:00
Martin Ling
9a0c4bbdbe
windows: Strip CR/LF from end of system error messages.
...
This fixes bug #585 .
2015-05-27 11:08:30 +02:00
Uwe Hermann
6392641545
sp_list_ports(): Actually set list_ptr NULL as documented.
2015-05-06 17:06:06 +02:00
Uwe Hermann
6aad5bdd47
Fix a potential segfault in sp_get_config_*().
2015-05-06 17:06:06 +02:00
Uwe Hermann
5f64c28551
Fix a potential segfault in sp_get_port_handle().
2015-05-06 17:06:05 +02:00
Uwe Hermann
1b91c6eadb
Rename timeout to timeout_ms for clarity in a few places.
2015-04-19 19:01:08 +02:00
Uwe Hermann
f14809393a
Constify the sp_get_port_description() parameter.
2015-04-19 19:01:08 +02:00
Uwe Hermann
ad036cc8ef
Constify the sp_get_port_transport() parameter.
2015-04-19 18:28:10 +02:00
Uwe Hermann
23e7fa372a
Fix two compiler warnings on platforms without enumeration support.
...
serialport.c: In function 'sp_list_ports':
serialport.c:326:6: warning: unused variable 'ret' [-Wunused-variable]
int ret;
^
serialport.c:325:19: warning: unused variable 'list' [-Wunused-variable]
struct sp_port **list;
^
2015-04-03 22:11:07 +02:00
Uwe Hermann
ac323d80e0
add_handle(): Fix a realloc() related issue.
2015-04-03 22:02:42 +02:00
Uwe Hermann
948f63f0fd
add_handle(): Fix a memory leak.
...
This fixes the following scan-build warning:
serialport.c:1170:3: warning: Potential leak of memory pointed to by 'new_handles'
RETURN_ERROR(SP_ERR_MEM, "Mask array realloc() failed");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-04-03 17:51:41 +02:00
Martin Ling
8d12e620f2
Clarify sp_list_ports() code.
...
This also fixes the following scan-build warning:
serialport.c:335:15: warning: Result of 'malloc' is converted to a
pointer of type 'struct sp_port *', which is incompatible with sizeof
operand type 'struct sp_port **'
if (!(list = malloc(sizeof(struct sp_port **))))
^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
2015-04-03 17:46:26 +02:00
Martin Ling
34442106ef
windows: Set fAbortOnError=FALSE.
...
Since we're not handling and clearing receive errors (framing, parity and
overrun), we should turn them off to avoid crashing out with
ERROR_OPERATION_ABORTED in various calls if they occur. Invalid data
will then simply not end up in the buffer. This is consistent with our
current behaviour on posix/termios systems.
It might be nice to be able to inform calling code about receive errors, but I
can't see a good way to do this in a cross-platform way at the moment.
This fixes (parts of) bug #341 .
2015-03-29 22:18:46 +02:00
Martin Ling
47fcf8ec85
windows: Revise management of WaitCommEvent() operations.
...
This fixes (at least parts of) bug #341 .
2015-03-29 22:18:46 +02:00
Uwe Hermann
6c6aebe78c
Make std_baudrates[] static (only used in one file).
2015-03-26 23:57:56 +01:00
Uwe Hermann
dc422c04af
Various cosmetic and consistency fixes.
2015-03-26 23:57:56 +01:00
Martin Ling
f446cfbf65
windows: Fix restart of RX/error wait operation after reads.
...
This fixes bug #421 .
2015-02-15 20:52:45 +01:00
Boris Gjenero
e31f2c6b8b
Fix free() of uninitialized pointer.
...
Explicitly set port->usb_path to NULL, otherwise a free(port->usb_path)
can happen where port->usb_path is uninitialized.
This closes bug #512 .
2014-12-05 18:42:43 +01:00
Janne Huttunen
ad7498553c
Flush only the requested buffers
...
Fix the sp_flush() so that it flushes only the requested buffers
also in unix.
2014-10-12 21:38:03 +02:00
Aurelien Jacobs
276ef1b92f
Add SP_MODE_READ_WRITE enum value.
2014-09-20 21:24:31 +02:00
Martin Ling
7890cef6cf
Revise debug macros to work in strict C99.
2014-08-24 14:06:21 +01:00
Martin Ling
9caa2e86aa
Specialise RETURN_VALUE macro into RETURN_{INT,STRING,POINTER}.
...
This avoids the need to pass the required format string on every
call and also eliminates the need for the non-standard typeof() call.
2014-08-24 13:31:20 +01:00
Uwe Hermann
5a8810e2b2
serialport.c: Fix an 'unused variable' compiler warning.
2014-07-31 23:09:24 +02:00
Aurelien Jacobs
970f279ae4
Introduce SP_API/SP_PRIV to mark visibility of functions.
2014-07-02 14:43:32 +02:00