diff options
author | Claudiu Olteanu <olteanu.claudiu@ymail.com> | 2015-08-18 21:38:47 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-20 22:45:31 -0700 |
commit | 3b811552aa19f9f929565f8cec9bb3e233162362 (patch) | |
tree | 718332c6b11e6e90d4f3439c0bfd5a56200d97ea /qtserialbluetooth.cpp | |
parent | 994087c0b9172a6ecfcae89da7ab9e0cdd8a08e8 (diff) | |
download | subsurface-3b811552aa19f9f929565f8cec9bb3e233162362.tar.gz |
Add implementation for BTH custom serial write method used on Windows
Implement the write method used for our custom serial implementation
on Windows platforms.
Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qtserialbluetooth.cpp')
-rw-r--r-- | qtserialbluetooth.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp index 9d1c14b74..45fc8d1ec 100644 --- a/qtserialbluetooth.cpp +++ b/qtserialbluetooth.cpp @@ -263,9 +263,20 @@ static int qt_serial_write(serial_t *device, const void* data, unsigned int size if (device == NULL) return DC_STATUS_INVALIDARGS; - // TODO write *size* bytes from data to the device + unsigned int nbytes = 0; + int rc; - return 0; + while (nbytes < size) { + rc = send(device->socket, (char *) data + nbytes, size - nbytes, 0); + + if (rc < 0) { + return -1; // Error during send call. + } + + nbytes += rc; + } + + return nbytes; #else if (device == NULL || device->socket == NULL) return DC_STATUS_INVALIDARGS; |