rpihardware

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 6 Imported by: 3

README

rpihardware GoDoc

Package for determining the used Raspberry Pi hardware with corresponding information during runtime.

About

This package determines the running Raspberry Pi hardware by checking either /proc/cpuinfo or /proc/device-tree/system/linux,revision.

It returns information about:

  • hardware version
  • Pi model type
  • oscillator frequency
  • base address for 'physical memory'
  • description of the model

The list is inspired by github.com/jgarff/rpi_ws281x.

Installation

go get github.com/DerLukas15/rpihardware

Usage

Import the package

import ("github.com/DerLukas15/rpihardware")

Get the struct containing the information about the hardware:

curHardware, err := rpihardware.Check()

License

MIT, see LICENSE

Documentation

Overview

Package rpihardware determines Raspberry Pi hardware and corresponding information during runtime.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHwNotDetected   = errors.New("Hardware undefined")
	ErrUndefinedEndian = errors.New("Endian undefined")
)

Errors

View Source
var HardwareList = []Hardware{}

HardwareList contains all defined hardwares which are used for the check.

Functions

This section is empty.

Types

type Hardware

type Hardware struct {
	Version       Version //Hardware version
	RPiType       RPiType //Raspberry Pi type
	PhysAddrBase  uint32  //Base for physical memory address
	Desc          string  //Description of the hardware
	OscFreq       uint32  //Frequency of the build in oscillator
	VideocoreBase uint32  //Base for videocore
}

Hardware contians all information about a Raspberry Pi hardware.

func Check

func Check() (*Hardware, error)

Check determines the currently used hardware and will return a pointer to the definition. Check will return 'ErrHwNotDetected' if no hardware could be determined.

type RPiType

type RPiType uint32

RPiType type for Raspberry Pi Type.

const (
	RPiTypeUnknown RPiType = 0
	RPiType1       RPiType = 1
	RPiType2       RPiType = 2
	RPiType4       RPiType = 3
)

Possible values for RPiType

type Version

type Version uint32

Version type for hardware version

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL