public void Write(byte [] buffer, int offset, int count) { CheckOpen(); if (buffer == null) { throw new ArgumentNullException("buffer"); } if (offset < 0 || count < 0) { throw new ArgumentOutOfRangeException(); } if (buffer.Length - offset < count) { throw new ArgumentException("offset+count", "The size of the buffer is less than offset + count."); } stream.Write(buffer, offset, count); }
private bool GetSync() { try { var bytes = CommandConstants.SyncBytes; serialStream.Write(bytes, 0, bytes.Length); var responseBytes = ReadCurrentReceiveBuffer(4); return(responseBytes.Length == 4 && responseBytes[0] == bytes[3] && responseBytes[1] == bytes[2] && responseBytes[2] == bytes[1] && responseBytes[3] == bytes[0]); } catch (TimeoutException e) { //logger.Trace("Timeout while trying to get sync..."); return(false); } catch (Exception e) { //logger.Trace("Exception while trying to get sync ('{0}')", e.Message); return(false); } }