serialport.js
function openSerialPortDevice(readFd) {
		//Save TTY streams
		self._readStream = new tty.ReadStream(readFd);
		self._readStream.setRawMode(true);
		self._writeStream = self._readStream;
		//Setup error handlers
		self._readStream.on("error", function(err) {
			self.emit("error", err);
		});
		//Setup read event handlers
		self._readStream.on("data", function(chunk) {
			self.push(chunk);
		});
		self._readStream.on("end", function() {
			self.push(null);
		});
		self._readStream.on("close", function() {
			self.emit("close");
		});
		//Emit open event
		self.emit("open",self._readStream);
	}
function openSerialPortDevice(readFd) {
		//Save TTY streams
		self._readStream = new tty.ReadStream(readFd);
		self._readStream.setRawMode(true);
		self._writeStream = self._readStream;
		//Setup error handlers
		self._readStream.on("error", function(err) {
			self.emit("error", err);
		});
		//Setup read event handlers
		self._readStream.on("data", function(chunk) {
			self.push(chunk);
		});
		self._readStream.on("end", function() {
			self.push(null);
		});
		self._readStream.on("close", function() {
			self.emit("close");
		});
		//Emit open event
		self.emit("open",self._readStream);
	}
function openSerialPortDevice ( readFd ) { //Save TTY streams self . _readStream = new tty . ReadStream ( readFd ) ; self . _readStream . setRawMode ( true ) ; self . _writeStream = self . _readStream ; //Setup error handlers self . _readStream . on ( "error" , function ( err ) { self . emit ( "error" , err ) ; } ) ; //Setup read event handlers self . _readStream . on ( "data" , function ( chunk ) { self . push ( chunk ) ; } ) ; self . _readStream . on ( "end" , function ( ) { self . push ( null ) ; } ) ; self . _readStream . on ( "close" , function ( ) { self . emit ( "close" ) ; } ) ; //Emit open event self . emit ( "open" , self . _readStream ) ; }
Once the process exits successfully, we call this function
Once the process exits successfully we call this function