NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/52219: Example included in gpio(3lua) incorrect



>Number:         52219
>Category:       bin
>Synopsis:       Example included in gpio(3lua) incorrect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 08 01:50:00 +0000 2017
>Originator:     Sevan Janiyan
>Release:        NetBSD-HEAD
>Organization:
>Environment:
NetBSD armv7 7.99.71 NetBSD 7.99.71 (BEAGLEBONE) #0: Fri May  5 12:21:28 UTC 2017  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/evbarm/compile/BEAGLEBONE evbarm
>Description:
The example included in gpio(3lua) in incorrect & does not run.
lua reports
lua: GPIOREAD
stack traceback:
        [C]: in function 'gpio.read'
        ppp.lua:8: in main chunk
        [C]: in ?


The reason is that gpio.read is expecting the configured gpio pin to read from whereas the example passes the value of number of configured pins on the system, minus one.

>How-To-Repeat:
Adding the following to a text file, eg gpio.lua
local gpio = require 'gpio'

gpiodev = gpio.open('/dev/gpio0')

local npins = gpiodev:info()

for n = 1, npins do
    print('pin ' .. n .. ': ' .. gpiodev:read(n - 1))
end

execute it with lua
lua gpio.lua
>Fix:



Home | Main Index | Thread Index | Old Index