in src/main/java/com/fazecast/jSerialComm/SerialPort.java [2352:2377]
public final void write(byte[] b, int off, int len) throws NullPointerException, IndexOutOfBoundsException, SerialPortIOException, SerialPortTimeoutException
{
// Perform error checking
if (b == null)
throw new NullPointerException("A null pointer was passed in for the write buffer.");
if ((len < 0) || (off < 0) || ((off + len) > b.length))
throw new IndexOutOfBoundsException("The specified write offset plus length extends past the end of the specified buffer.");
// Write to the serial port until all bytes have been consumed
int totalNumWritten = 0;
while (totalNumWritten != len)
{
// Always ensure that the port has not been closed
if (portHandle == 0)
throw new SerialPortIOException("This port appears to have been shutdown or disconnected.");
// Write the actual bytes to the serial port
int numWritten = writeBytes(b, len - totalNumWritten, off + totalNumWritten);
if (numWritten < 0)
throw new SerialPortIOException("No bytes written. This port appears to have been shutdown or disconnected.");
else if (numWritten == 0)
throw new SerialPortTimeoutException("The write operation timed out before all data was written.");
else
totalNumWritten += numWritten;
}
}