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
NetBSD armv7 7.99.71 NetBSD 7.99.71 (BEAGLEBONE) #0: Fri May  5 12:21:28 UTC 2017 evbarm
The example included in gpio(3lua) in incorrect & does not run.
lua reports
stack traceback:
        [C]: in function ''
        ppp.lua:8: in main chunk
        [C]: in ?

The reason is that 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.

Adding the following to a text file, eg gpio.lua
local gpio = require 'gpio'

gpiodev ='/dev/gpio0')

local npins = gpiodev:info()

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

execute it with lua
lua gpio.lua

Home | Main Index | Thread Index | Old Index