Fixes permission error

Closes #70
This commit is contained in:
Drahoslav Bednář 2021-08-19 02:37:13 +02:00 committed by GitHub
parent 6d1cac1060
commit 6ea7dcc05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -705,9 +705,9 @@ func Open() (err error) {
var file *os.File
// Open fd for rw mem access; try dev/mem first (need root)
file, err = os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, 0)
file, err = os.OpenFile("/dev/mem", os.O_RDWR|os.O_SYNC, os.ModePerm)
if os.IsPermission(err) { // try gpiomem otherwise (some extra functions like clock and pwm setting wont work)
file, err = os.OpenFile("/dev/gpiomem", os.O_RDWR|os.O_SYNC, 0)
file, err = os.OpenFile("/dev/gpiomem", os.O_RDWR|os.O_SYNC, os.ModePerm)
}
if err != nil {
return