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

@@ -202,7 +202,7 @@ int main()
write_aes_utils(dev); write_aes_utils(dev);
free_dev_cmd_resp(resp); free_dev_cmd_resp(resp);
for(int i = 0; i < 32; i++) for(int i = 0; i < 65536; i++)
{ {
resp = execute_payload(dev, PAYLOAD_AES_SW, 0, 7, resp = execute_payload(dev, PAYLOAD_AES_SW, 0, 7,
0x180153000, 16, 0x180152000, 0x180153000, 16, 0x180152000,
@@ -221,15 +221,14 @@ int main()
printf("failed to read encrypted data from memory\n"); printf("failed to read encrypted data from memory\n");
} }
memcpy(data, resp->data, 16);
free_dev_cmd_resp(resp);
printf("got "); printf("got ");
for(int j = 0; j < 16; j++) for(int j = 0; j < 16; j++)
{ {
printf("%02x", data[j]); printf("%02x", resp->data[j]);
} }
printf("\n");
printf(" (%llu)\n", resp->retval);
free_dev_cmd_resp(resp);
} }
close_device_session(dev); close_device_session(dev);

View File

@@ -249,10 +249,12 @@ int is_device_session_open(struct pwned_device *dev)
#ifdef WITH_ARDUINO #ifdef WITH_ARDUINO
void ard_read(struct pwned_device *dev, unsigned char *target, int nbytes) void ard_read(struct pwned_device *dev, unsigned char *target, int nbytes)
{ {
int index = 0; int index = 0, amount;
while(index < nbytes) 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 #endif