@@ -146,17 +146,25 @@ seac_screen_receive (seac_screen_device_t *device, unsigned short cmd, unsigned
146
146
dc_device_t * abstract = (dc_device_t * ) device ;
147
147
unsigned char packet [SZ_MAXRSP + 8 ] = {0 };
148
148
149
- // Read the packet header.
150
- status = dc_iostream_read (device -> iostream , packet , 3 , NULL );
151
- if (status != DC_STATUS_SUCCESS ) {
152
- ERROR (abstract -> context , "Failed to receive the packet header." );
153
- return status ;
149
+ // Read the packet start byte.
150
+ while (1 ) {
151
+ status = dc_iostream_read (device -> iostream , packet + 0 , 1 , NULL );
152
+ if (status != DC_STATUS_SUCCESS ) {
153
+ ERROR (abstract -> context , "Failed to receive the packet start byte." );
154
+ return status ;
155
+ }
156
+
157
+ if (packet [0 ] == START )
158
+ break ;
159
+
160
+ WARNING (abstract -> context , "Unexpected packet header byte (%02x)." , packet [0 ]);
154
161
}
155
162
156
- // Verify the start byte.
157
- if (packet [0 ] != START ) {
158
- ERROR (abstract -> context , "Unexpected start byte (%02x)." , packet [0 ]);
159
- return DC_STATUS_PROTOCOL ;
163
+ // Read the packet length.
164
+ status = dc_iostream_read (device -> iostream , packet + 1 , 2 , NULL );
165
+ if (status != DC_STATUS_SUCCESS ) {
166
+ ERROR (abstract -> context , "Failed to receive the packet length." );
167
+ return status ;
160
168
}
161
169
162
170
// Verify the length.
0 commit comments