Skip to content

Latest commit

 

History

History
104 lines (80 loc) · 7.58 KB

README.md

File metadata and controls

104 lines (80 loc) · 7.58 KB

Go + hardware

This repo is a directory of tools, packages and tutorials to let you introduce Go in your hardware projects.

Why Go?

  • Go can target platforms and architectures that are primarily in the scope of non-real time embedded operating systems.

    • ARMv5, ARMv6, ARMv7 and ARMv8 support for Linux
    • ARMv7, ARMv8, x86 support for Android
    • Experimental OpenWRT
  • Out-of-the-box cross compilation story.

    • E.g. Run GOOS=linux GOARCH=arm go build to build a binary for ARM/linux boards from a Mac or Windows machine. No other configuration is required.
  • Built-in concurrency primitives in Go is making it easier to write concurrent programs.

    • Strong advantage in implementing hardware controllers.
    • Strong advantage in implementing networking devices.
  • Go is garbage collected language but the garbage collector footprint has been improved significantly since Go 1.4. The pause times are being targetted to be 10ms or less even with large heaps and is not a significant disadvantage on non-real time operating systems -- the preemptive nature of the OS scheduler is more of a major problem than pause times.

  • Go's network stack is high quality and maintained well. Networking is a core component in IoT.

  • Go provides out-of-the-box HTTP, HTTPS and HTTP/2 client/server implementations.

    • Standard library might be missing higher level implementations for P2P protocols, but the community works to fill that gap.
    • Community is also investing time to implement newer IoT-targeting networking protocols such as COAP.
  • Writing C bindings in Go is very trivial with cgo unlike other high level programming languages like Python and Java. It is so much easier to depend on an existing C/C++ library from the Go context.

    • E.g. portmidi bindings. See the source code to see how you can mix and match Go and C code in the same Go file.
  • C-like syntax enables the existing IoT/embedded programmers (mostly fluent in C) to read and write Go without much knowledge of the language.

  • Go programs compile to static binaries and doesn’t require a runtime on the host (e.g. a VM). Deployment is copy/pasting a binary.

  • Go had strong community figures who worked on the hardware aspects from the early days.

    • Gobot made its debut at the first GopherCon.
    • There are numerous libraries and frameworks around hardware and robotics already contributed by the community. A list can be found at go-hardware.
  • Go is efficient, fast and has low memory footprint.

  • Code reuse between server and client (connected device or mobile).

    • E.g. gRPC Go is working out of the box on servers, Android, iOS and embedded Linux.

Tutorials

Packages

Controllers

  • devices - A repository of high-level device/sensor packages for Go.
  • gobot - High level Go package with a variety of platform APIs to talk to popular drivers such as GPIO on Arduino and Raspberry Pi, Leap Motion or Pebble.
  • go-gpio - GPIO for Go, doesn't require cgo.
  • embd - Embedded programming framework for Go.
  • fadecandy - Dithering OPC-based LED controller
  • godrone - High level Parrot AR Drone 2.0 framework written in Go.
  • launchpad - High level controller library for Novation Launchpad.
  • littlebits - littleBits controller for Go. It requires USB I/O module.
  • piCamera - Capture the stream of Images for a Raspberry Pi Camera in GoLang
  • hwio - Hardware library for ARM boards such as Raspberry Pi and BeagleBone, loosely based on Arduino.
  • go-lepton - Streams images taken on a FLIR Lepton connected to a Raspberry Pi SPI port to over via WebSockets via embedded HTTP server.
  • go-embedded - Embedded Linux support for I2C, SPI, PWM, GPIO, ADC
  • go-beaglebone - Go package for the BeagleBone open source hardware
  • go-mavlink - MAVLink protocol implementation for Go (MAVLink is used to control drones)
  • joystick - a polled API to read the state of an attached joystick.
  • emgo - Go-like language for programming embedded systems (e.g. STM32 MCU).
  • go-rpi-rgb-led-matrix - Controlling up to three chains of 32x32 or 16x32 RGB LED displays using Raspberry Pi GPIO
  • go-rpi-ws281x - Go bindings for Raspberry Pi PWM library for WS281X LEDs Edit
  • ghw - Golang hardware discovery/inspection library
  • sysinfo - A pure Go library providing Linux OS / kernel / hardware system information.

Signal processing, computer vision, graphics, media

  • go-gl - OpenGL bindings for Go.
  • go-opc - Open Pixel Control bindings for Go.
  • go-opencv - OpenCV bindings for Go.
  • go-sox - SoX bindings for Go.
  • portaudio - PortAudio bindings for Go.
  • portmidi - PortMidi bindings for Go.
  • go-osc - Open Sound Control (OSC) bindings for Go.
  • openvg - 2D Graphics library wrapping the OpenVG API
  • lirc - Go Client for Linux Infra-red Remote Control. Allows sending and receiving IR commands.
  • gocv - OpenCV 3+ bindings for Go. Also supports OpenVINO.

Networking, peripheral communications

  • mdns - mDNS server and client implementation in Go. Multicast DNS can be used to discover services and message on the local network without the use of an authoritative DNS server.
  • gatt - Provides a Bluetooth Low Energy GATT implementation.
  • go.hid - Provides communication with USB Human Interface Devices.
  • goble - Bluetooth Low Energy (HM10) module for Go
  • serial - Serial Port Communication Package for Go
  • firmata - Firmata client for Go
  • periph - Peripherals I/O in Go
  • go-ckb - Corsair ckb-daemon communication in Go
  • ble - Bluetooth Low Energy communication wrapper for Linux/macOS.

Mobile (Go 1.5 or above)

Contributions are welcome, please fork and open a PR if you see a missing package, tutorial, etc.