summaryrefslogtreecommitdiffstats
path: root/qtserialbluetooth.cpp
diff options
context:
space:
mode:
authorGravatar Claudiu Olteanu <olteanu.claudiu@ymail.com>2015-08-18 21:38:17 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-20 22:45:28 -0700
commit994087c0b9172a6ecfcae89da7ab9e0cdd8a08e8 (patch)
treed618e9381db90be1104aff753c2f15aaf23b1f1d /qtserialbluetooth.cpp
parent23c5dee2f1207a338588473918cf6ff588e4e28b (diff)
downloadsubsurface-994087c0b9172a6ecfcae89da7ab9e0cdd8a08e8.tar.gz
Add implementation for BTH custom serial read method used on Windows
Implement the read 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.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index 20f2ecd5d..9d1c14b74 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -209,9 +209,22 @@ static int qt_serial_read(serial_t *device, void* data, unsigned int size)
if (device == NULL)
return DC_STATUS_INVALIDARGS;
- // TODO read *size* bytes from the device
+ unsigned int nbytes = 0;
+ int rc;
- return 0;
+ while (nbytes < size) {
+ rc = recv (device->socket, (char *) data + nbytes, size - nbytes, 0);
+
+ if (rc < 0) {
+ return -1; // Error during recv call.
+ } else if (rc == 0) {
+ break; // EOF reached.
+ }
+
+ nbytes += rc;
+ }
+
+ return nbytes;
#else
if (device == NULL || device->socket == NULL)
return DC_STATUS_INVALIDARGS;