mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
23c5dee2f1
commit
994087c0b9
1 changed files with 15 additions and 2 deletions
|
@ -209,9 +209,22 @@ static int qt_serial_read(serial_t *device, void* data, unsigned int size)
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
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
|
#else
|
||||||
if (device == NULL || device->socket == NULL)
|
if (device == NULL || device->socket == NULL)
|
||||||
return DC_STATUS_INVALIDARGS;
|
return DC_STATUS_INVALIDARGS;
|
||||||
|
|
Loading…
Add table
Reference in a new issue