Skip to content

Commit 3be7107

Browse files
authored
Fix a synchronization bug
Fixes a synchronization bug. Return if there's no timeout OR if there's no sync byte received. The previous version needed both to be true at the same time to return without sending a frame, which meant that a frame was sent if there was a timeout even if no sync byte had been received. That, in turn, caused random problems for the Processing sketch on the other end.
1 parent f10a895 commit 3be7107

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/Camera/examples/CameraCaptureRawBytes/CameraCaptureRawBytes.ino

+5-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ void loop() {
6767
// Time out after 2 seconds and send new data
6868
bool timeoutDetected = millis() - lastUpdate > 2000;
6969

70-
// Wait for sync byte.
71-
if(!timeoutDetected && Serial.read() != 1) return;
70+
// Wait for sync byte and timeout
71+
if ((!timeoutDetected) || (Serial.read() != 1))
72+
{
73+
return;
74+
}
7275

7376
lastUpdate = millis();
7477

0 commit comments

Comments
 (0)