var RS485 = function(opts) {
  if (!opts) {
    pts = {};
  }
  this._serial = opts.serial || Serial3;
  this._speed = opts.speed || 9600;
  this._dirPin = opts.dirPin || P5;
  this._lineEnding = opts.lineEnding || '\r\n';
  this._kPin = opts.kPin;
  this._endPrintID = null;
  this._serial.setup(this._speed);
  var self = this;

  this._serial.on('data', function(data) {
    self.emit('data', data);
  });
  this._serial.on('parity', function() {
    self.emit('error', 'parity');
  });
  this._serial.on('framing', function() {
    self.emit('error', 'speed');
  });
};

RS485.prototype.print = function(data) {
  var time = (data.length * 12 / this._speed) * 1000;
  console.log(time);
  this._dirPin.write(true);
  this._serial.print(data);
  var self = this;
  this._endPrintID = setTimeout(function() {
    self._dirPin.write(false);
  }, time);
};

RS485.prototype.println = function(data) {
  var time = (data.length * 12 / this._speed) * 1000;
  console.log(time);
  this._dirPin.write(true);  
  if (this._lineEnding) {
    this._serial.print(data + this._lineEnding);
  } else {
    this._serial.println(data);
  }
  var self = this;
  this._endPrintID = setTimeout(function() {
    self._dirPin.write(false);
  }, time);
};

exports.connect = function(opts) {
  return new RS485(opts);
};

@@ -28,39 +28,27 @@
 %7B%0A  
-if (!opts) %7B%0A    
+opts = o
 pts 
-=
+%7C%7C
  %7B%7D;%0A
-  %7D%0A
   th
@@ -196,44 +196,8 @@
 ding
- %7C%7C '%5Cr%5Cn';%0A  this._kPin = opts.kPin
 ;%0A  
@@ -262,263 +262,404 @@
 ;%0A  
-var self = this;%0A%0A  this._serial.on('data', function(data) %7B%0A    self.emit('data', data);%0A  %7D);%0A  this._serial.on('parity', function() %7B%0A    self.emit('error', 'parity');%0A  %7D);%0A  this._serial.on('framing', function() %7B%0A    self.emit('error', 'speed');%0A  %7D
+this._timeTransmission = (12 / this._speed) * 1000 + 2;%0A%7D;%0A%0ARS485.prototype.on = function(event, callback) %7B%0A  switch (event) %7B%0A    case 'data': this._serial.on('data', callback); break;%0A    case 'parity': this._serial.on('parity', callback); break;%0A    case 'framing': this._serial.on('framing', callback); break;%0A  %7D%0A%7D;%0A%0ARS485.prototype.available = function() %7B%0A  return this._serial.available(
 );%0A%7D
@@ -677,21 +677,20 @@
 ototype.
-print
+read
  = funct
@@ -697,253 +697,353 @@
 ion(
-data
+chars
 ) %7B%0A  
-var time = (data.length * 12 / this._speed) * 1000;%0A  console.log(time);%0A  this._dirPin.write(true);%0A  this._serial.print(data);%0A  var self = this;%0A  this._endPrintID = setTimeout(function() %7B%0A    self._dirPin.write(false);%0A  %7D, time);
+return this._serial.read(chars);%0A%7D;%0A%0ARS485.prototype.print = function(data) %7B%0A  this._transmissionOn(data);%0A  this._serial.print(data);%0A%7D;%0A%0ARS485.prototype.println = function(data) %7B%0A  this._transmissionOn(data);%0A  if (this._lineEnding) %7B%0A    this._serial.print(data + this._lineEnding);%0A  %7D else %7B%0A    this._serial.println(data);%0A  %7D
 %0A%7D;%0A
@@ -1051,39 +1051,37 @@
 RS485.prototype.
-println
+write
  = function(data
@@ -1090,78 +1090,33 @@
 %7B%0A  
-var time = (data.length * 12 / this._speed) * 1000;%0A  console.log(time
+this._transmissionOn(data
 );%0A 
@@ -1126,151 +1126,161 @@
 is._
-dirPin
+serial
 .write(
-true);  %0A  if (this._lineEnding) %7B%0A    this._serial.print(data + this._lineEnding);%0A  %7D else %7B%0A    this._serial.println(data);%0A  %7D
+data);%0A%7D;%0A%0ARS485.prototype._transmissionOn = function(data) %7B%0A  var time = data.length * this._timeTransmission;%0A  this._dirPin.write(true);
 %0A  v

fix lib