void compass_update() { char *data = malloc(20); if (!serialRead(*compass->hSerial, data, 19)) return; log_write(0, "Heading: %d (%s)\r\n", heading, data); free(data); } int serialRead(HANDLE hSerial, char *buff, DWORD bytes) { DWORD dwBytesRead = 0; if (!ReadFile(hSerial, buff, bytes, &dwBytesRead, NULL)) return 0; return dwBytesRead; }