Skip to content

Instantly share code, notes, and snippets.

@samuelsonbrito
Created January 6, 2018 22:38
Show Gist options
  • Save samuelsonbrito/b16d97ae11ae51193618062b427816bf to your computer and use it in GitHub Desktop.
Save samuelsonbrito/b16d97ae11ae51193618062b427816bf to your computer and use it in GitHub Desktop.
@FXML
private void conectar(ActionEvent event) {
if (btnConectar.getText().equals("Conectar")) {
porta = SerialPort.getCommPort(cbPortas.getSelectionModel().getSelectedItem().toString());
porta.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0);
if (porta.openPort()) {
btnConectar.setText("Desconectar");
cbPortas.setDisable(true);
}
} else {
porta.closePort();
cbPortas.setDisable(false);
btnConectar.setText("Conectar");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment