Fixed active idling when waiting for arduino communication

This commit is contained in:
2020-01-10 14:54:24 -05:00
parent 5326c19acc
commit 3f0e274bd5
2 changed files with 9 additions and 8 deletions

View File

@@ -249,10 +249,12 @@ int is_device_session_open(struct pwned_device *dev)
#ifdef WITH_ARDUINO
void ard_read(struct pwned_device *dev, unsigned char *target, int nbytes)
{
int index = 0;
int index = 0, amount;
while(index < nbytes)
{
index += read(dev->ard_fd, &target[index], nbytes - index);
amount = read(dev->ard_fd, &target[index], nbytes - index);
if(amount == 0) usleep(5000);
else index += amount;
}
}
#endif