Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied, errno = 13 #16

Open
schigabiga opened this issue Jan 5, 2023 · 1 comment
Open

Permission denied, errno = 13 #16

schigabiga opened this issue Jan 5, 2023 · 1 comment

Comments

@schigabiga
Copy link

Hello!
I started to use https://pub.dev/packages/linux_serial this package, but after I run on Android 11 mobile and called the below function I got an error.
final ports = SerialPorts.ports; print(ports);

Error:
Directory listing failed, path = '/sys/dev/char/' (OS Error: Permission denied, errno = 13)

Stack:

#0      _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24)
#1      _Directory.listSync (dart:io/directory_impl.dart:243:5)
#2      SerialPorts.ports (package:linux_serial/src/linux_serial.dart:581:7)
#3      _MyHomePageState._incrementCounter (package:usb_serial_test/main.dart:37:31)
#4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:1005:21)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:198:24)
#6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:613:11)
#7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:298:5)

I got the same error, when I used these packages: https://pub.dev/packages/libserialport , https://pub.dev/packages/flutter_libserialport

What kind of permission should I grant?
Thank you in advance!

Flutter version:

Flutter 3.0.0
Framework • revision ee4e09cce0 (8 months ago) • 2022-05-09 16:45:18 -0700
Engine • revision d1b9a6938a
Tools • Dart 2.17.0 • DevTools 2.12.2
@ardera
Copy link
Owner

ardera commented Jan 13, 2023

For listing the serial ports, read access to /sys/dev/char is required. You can try running chmod ugo+r /sys/dev/char as the root user to grant everyone access to that folder. Though that may be a security problem. There's probably a reason why android doesn't grant the permission by default.

If you know the path of the serial port device, you can also try creating the serial port directly:

final port = SerialPort('/dev/ttyUSB0', 0, 0, '');

To read & write the serial port, you also need read&write access to the device node, so (in the example above) read & write permissions to /dev/ttyUSB0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants