Socket
Socket
Sign inDemoInstall

periph.io/x/conn/v3

Package Overview
Dependencies
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    periph.io/x/conn/v3

Package conn defines core interfaces for protocols and connections. This package and its subpackages describe the base interfaces to connect the software with the real world. It doesn't contain any implementation but includes registries to enable the application to discover the available hardware. periph uses 3 layered concepts for interfacing: Not every subpackage expose all 3 concepts. In fact, most packages don't. For example, SPI doesn't expose Bus as the OSes generally only expose the Port, that is, a Chip Select (CS) line must be selected right upfront to get an handle. For I²C, there's no Port to configure, so selecting a "slave" address is sufficient to jump directly from a Bus to a Conn. periph doesn't have yet a concept of star-like communication network, like an IP network. A Bus is a multi-point communication channel where one "master" and multiple "slaves" communicate together. In the case of periph, the Bus handle is assumed to be the "master". The "master" generally initiates communications and selects the "slave" to talk to. As the "master" selects a "slave" over a bus, a virtual Port is automatically created. Examples include SPI, I²C and 1-wire. In each case, selecting a communication line (Chip Select (CS) line for SPI, address for I²C or 1-wire) converts the Bus into a Port. A port is a point-to-point communication channel that is yet to be initialized. It cannot be used for communication until it is connected and transformed into a Conn. Configuring a Port converts it into a Conn. Not all Port need configuration. A Conn is a fully configured half or full duplex communication channel that is point-to-point, only between two devices. It is ready to use like any readable and/or writable pipe. Most connection-type specific subpackages include subpackages: → XXXreg: registry as that is populated by the host drivers and that can be leveraged by applications. → XXXtest: fake implementation that can be leveraged when writing device driver unit test.


Version published

Readme

Source

periph - Peripherals I/O in Go

Documentation is at https://periph.io

Join us for a chat on gophers.slack.com/messages/periph, get an invite here.

mascot

PkgGoDev codecov

Example

Blink a LED:

package main

import (
    "time"
    "periph.io/x/conn/v3/gpio"
    "periph.io/x/host/v3"
    "periph.io/x/host/v3/rpi"
)

func main() {
    host.Init()
    t := time.NewTicker(500 * time.Millisecond)
    for l := gpio.Low; ; l = !l {
        rpi.P1_33.Out(l)
        <-t.C
    }
}

Curious? Look at supported devices for more examples!

Authors

periph was initiated with ❤️️ and passion by Marc-Antoine Ruel. The full list of contributors is in AUTHORS and CONTRIBUTORS.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

This project is not affiliated with the Go project.

FAQs

Last updated on 27 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc