react-native-serial-port-api
react-native-serial-port-api copied to clipboard
no permission to read or write this serial port
hi dear i have the same issue too i do some stuff like bellow but still give me the no permission to read or write this serial port
i put this lines to androidManifest.xml " uses-permission android:name="android.things.permission.USE_PERIPHERAL_IO" uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" " get /system/xbin/su from command ( which su ) and put this to following code
async function example() {
SerialPortAPI.setSuPath("/system/xbin/su");
console.log("tp1")
const serialPort = await SerialPortAPI.open("/dev/ttyS2", { baudRate: 38400 });
// subscribe received data
serialPort.onReceived(buff => {
console.log(buff.toString('hex').toUpperCase());
})
// unsubscribe
// sub.remove();
// send data with hex format
await serialPort.send('00FF');
// close
serlialPort.close();
}
example()