Documentation ¶
Overview ¶
Package mockup provides GPIO mockups using the Linux gpio-mockup kernel module. This is intended for GPIO testing of gpiod, but could also be used for testing by users of their own code that uses gpiod.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckKernelVersion ¶
CheckKernelVersion returns an error if the kernel version is less than the min.
func IsSupported ¶
func IsSupported() error
IsSupported returns an error if this package cannot run on this platform.
func KernelVersion ¶
KernelVersion returns the running kernel version.
Types ¶
type Chip ¶
Chip represents a single mocked GPIO chip.
type ErrorBadVersion ¶
ErrorBadVersion indicates the kernel version is insufficient.
func (ErrorBadVersion) Error ¶
func (e ErrorBadVersion) Error() string
type ErrorIndexRange ¶
ErrorIndexRange indicates the requested index is beyond the limit of the array.
func (ErrorIndexRange) Error ¶
func (e ErrorIndexRange) Error() string
type Mockup ¶
type Mockup struct {
// contains filtered or unexported fields
}
Mockup represents a number of GPIO chips being mocked.
func New ¶
New creates a new Mockup. A number of GPIO chips can be mocked, with the number of lines on each specified in lines. e.g. []int{4,6} would create two chips, the first with 4 lines and the second with 6. Requires the gpio-mockup kernel module and Linux 5.1.0 or later. Note that only one Mockup can be present on a system at any time and that this function unloads the gpio-mockup module if it is already loaded.
type ModprobeMonitor ¶
ModprobeMonitor finds the details of gpio-mockup based gpiochips loaded via modprobe.
type SimpleMonitor ¶
type SimpleMonitor struct{}
SimpleMonitor assumes an empty platform so any added gpiochips will be the first and only gpiochips.
func (*SimpleMonitor) Chips ¶
func (m *SimpleMonitor) Chips(lines []int) ([]Chip, error)
Chips returns the chips corresponding to the requested number of lines per chip.
func (*SimpleMonitor) Close ¶
func (m *SimpleMonitor) Close()
Close is just a stub to fulfil the ModprobeMonitor interface.