1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Add SP_MODE_READ_WRITE enum value.

This commit is contained in:
Aurelien Jacobs 2014-09-20 21:24:31 +02:00
parent eb82be98a7
commit 276ef1b92f
2 changed files with 5 additions and 3 deletions

View File

@ -108,7 +108,9 @@ enum sp_mode {
/** Open port for read access. */
SP_MODE_READ = 1,
/** Open port for write access. */
SP_MODE_WRITE = 2
SP_MODE_WRITE = 2,
/** Open port for read and write access. */
SP_MODE_READ_WRITE = 3
};
/** Port events. */

View File

@ -402,7 +402,7 @@ SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
CHECK_PORT();
if (flags > (SP_MODE_READ | SP_MODE_WRITE))
if (flags > SP_MODE_READ_WRITE)
RETURN_ERROR(SP_ERR_ARG, "Invalid flags");
DEBUG_FMT("Opening port %s", port->name);
@ -479,7 +479,7 @@ SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
int flags_local = O_NONBLOCK | O_NOCTTY;
/* Map 'flags' to the OS-specific settings. */
if (flags & (SP_MODE_READ | SP_MODE_WRITE))
if ((flags & SP_MODE_READ_WRITE) == SP_MODE_READ_WRITE)
flags_local |= O_RDWR;
else if (flags & SP_MODE_READ)
flags_local |= O_RDONLY;