Skip to content

Commit f8a617e

Browse files
committed
simpler read_from_rfb_server
1 parent a5846be commit f8a617e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/VNC.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,18 @@ bool arduinoVNC::read_from_rfb_server(int sock, char *out, size_t n) {
233233
*/
234234
while(n > 0) {
235235
if(!TCPclient.connected()) {
236-
DEBUG_VNC("[read_from_rfb_server] Receive not connected - 1!\n");
236+
DEBUG_VNC("[read_from_rfb_server] not connected!\n");
237237
return false;
238238
}
239-
while(!TCPclient.available()) {
240-
if(!TCPclient.connected()) {
241-
DEBUG_VNC("[read_from_rfb_server] Receive not connected - 2!\n");
242-
return false;
243-
}
244-
if((millis() - t) > VNC_TCP_TIMEOUT) {
245-
DEBUG_VNC("[read_from_rfb_server] Receive TIMEOUT!\n");
246-
return false;
247-
}
239+
240+
if((millis() - t) > VNC_TCP_TIMEOUT) {
241+
DEBUG_VNC("[read_from_rfb_server] receive TIMEOUT!\n");
242+
return false;
243+
}
244+
245+
if(!TCPclient.available()) {
248246
delay(0);
247+
continue;
249248
}
250249

251250
len = TCPclient.read((uint8_t*) out, n);
@@ -1215,7 +1214,7 @@ bool arduinoVNC::_handle_hextile_encoded_message(rfbFramebufferUpdateRectHeader
12151214
}
12161215
}
12171216

1218-
//DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] subrect: x: %d y: %d w: %d h: %d\n", rect_xW, rect_yW, tile_w, tile_h);
1217+
//DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] subrect: x: %d y: %d w: %d h: %d\n", rect_xW, rect_yW, tile_w, tile_h);
12191218

12201219
#ifdef VNC_FRAMEBUFFER
12211220
if(!fb.begin(tile_w, tile_h)) {
@@ -1247,7 +1246,7 @@ bool arduinoVNC::_handle_hextile_encoded_message(rfbFramebufferUpdateRectHeader
12471246

12481247
HextileSubrectsColoured_t * bufPC = (HextileSubrectsColoured_t *) buf;
12491248
for(uint8_t n = 0; n < nr_subr; n++) {
1250-
// DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] Coloured nr_subr: %d bufPC: 0x%08X\n", n, bufPC);
1249+
// DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] Coloured nr_subr: %d bufPC: 0x%08X\n", n, bufPC);
12511250
#ifdef VNC_FRAMEBUFFER
12521251
fb.draw_rect(bufPC->x, bufPC->y, bufPC->w + 1, bufPC->h + 1, bufPC->color);
12531252
#else
@@ -1265,7 +1264,7 @@ bool arduinoVNC::_handle_hextile_encoded_message(rfbFramebufferUpdateRectHeader
12651264
HextileSubrects_t * bufP = (HextileSubrects_t *) buf;
12661265
for(uint8_t n = 0; n < nr_subr; n++) {
12671266

1268-
// DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] nr_subr: %d bufP: 0x%08X\n", n, bufP);
1267+
// DEBUG_VNC_HEXTILE("[_handle_hextile_encoded_message] nr_subr: %d bufP: 0x%08X\n", n, bufP);
12691268
#ifdef VNC_FRAMEBUFFER
12701269
fb.draw_rect(bufP->x, bufP->y, bufP->w + 1, bufP->h + 1, fgColor);
12711270
#else

0 commit comments

Comments
 (0)