To simplify the connection to the serial port on the Nautiz X2 and the Nautiz X6, we have created a library that takes care of providing the correct path and handles power control depending on the hardware.
Below you’ll find a short code example in Java. If you need access to the AAR file directly, you can find it here.
Implement dependency
implementation 'com.handheldgroup.tools:serialport:1.5.0'
If the library can’t be found, you have to add a custom repository to you build file:
allprojects { repositories { ... maven { url "https://repo.repsy.io/mvn/handheldgroup/handheldgroup" } } }
Connection setup
File port = new File(SerialPort.getSerialPath()); SerialPort.setDevicePower(this, true); mSerialPort = new SerialPort(port, 9600, 0); mOutputStream = mSerialPort.getOutputStream(); mInputStream = mSerialPort.getInputStream(); // Start reading and writing to device