private void sendData(FileInputStream data) throws SerialConnectionException {
    int tosend = 0;
    byte[] databuff = new byte[_chunkSize];

    _sent = 0;
    try {
      tosend = data.read(databuff);
      while (tosend != -1) {
        if (!_keepRunning) return;
        _os.write(databuff, 0, tosend);
        _savedStream.write(databuff, 0, tosend);
        _sent += tosend;
        // update GUI
        _results.updateBytesSent(_sent);
        tosend = data.read(databuff);
      }
    } catch (IOException e) {
      throw new SerialConnectionException("Error writing to i/o streams");
    }
  }
 /**
  * returns a byte array of the data sent.
  *
  * @return byte array of data sent.
  */
 public byte[] getData() {
   if (_data != null) return _data;
   return _savedStream.toByteArray();
 }