node.js – Permission denied error while accessing /dev/bus/usb/001/002 in termux for android

Firstly i want to tell you that i want to run react native app with local server in my tablet so i am running my nodejs backend in termux in my real device and data recieved by arduino via usb will be shown in my react-native.

I want to recieve data from usb device(arduino) to my nodejs in termux like this

   const porter=new SerialPort('/dev/bus/usb/001/001',{
       baudRate:115200
   });

   const parser=porter.pipe(new Readline({delimiter:'n'}))
   porter.on("open",()=>{
      console.log("serialport open")
   })

   parser.on('data',data=>{
      console.log('got words from arduino:',data)
   })

but i got the error like this

   (node:12968) UnhandledPromiseRejectionWarning: Error: Error: Permission denied, cannot open 
   /dev/bus/usb/001/001 (Use `node --trace-warnings ...` to show where the warning was 
   created)(node:12968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This 
   error originated either by throwing inside of an async function without a catch block, or 
   by rejecting a promise which was not handled with .catch(). To terminate the node process 
   on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see 
   https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
   (node:12968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In 
   the future, promise rejections that are not handled will terminate the Node.js process with 
   a non-zero exit code.

please help me to overcome this problem. Thanks in advanced.

Source link