X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=OpenPixelControl.pde;h=830ba6c1b07a5812ab46b50c740dbc7491b2c8da;hb=a521a50b10037871a64746a7d5c40ed5f38e59e3;hp=118eb2a56cf10a20b7e1cc3c229d3c77d435068e;hpb=3ffd6241fa4f38d82cdb4dca434ca04b1edc9ccd;p=SugarCubes.git diff --git a/OpenPixelControl.pde b/OpenPixelControl.pde index 118eb2a..830ba6c 100644 --- a/OpenPixelControl.pde +++ b/OpenPixelControl.pde @@ -46,9 +46,10 @@ class OpenPixelControl extends SCPattern { bufferedByteCount = client.readBytes(buffer); } else { // Append to an earlier partial frame - byte[] additional = client.readBytes(); - arrayCopy(additional, 0, buffer, bufferedByteCount, additional.length); - bufferedByteCount += additional.length; + byte[] additional = new byte[buffer.length - bufferedByteCount]; + int additionalLength = client.readBytes(additional); + arrayCopy(additional, 0, buffer, bufferedByteCount, additionalLength); + bufferedByteCount += additionalLength; } // Extract OPC packets from buffer