@ Override public void close ( ) throws IllegalStateException , IOException { // validate state if ( isClosed ( ) ) throw new IllegalStateException ( "Serial connection is not open; cannot 'close()'." ) ; // remove serial port listener SerialInterrupt . removeListener ( fileDescriptor ) ; // close serial port now com . pi4j . jni . Serial . close ( fileDescriptor ) ; // reset file descriptor fileDescriptor = - 1 ; }
This method is called to close a currently open open serial port .