iotee

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 4 Imported by: 3

README

go-iotee

iotee client for Go

Quickstart

package main

import (
	"gitlab.mi.hdm-stuttgart.de/iotee/go-iotee"
	"log"
)

const (
	dev = "/dev/ttyACM0" // adjust to match actual device (COMX for Windows)
	baud = 115200
)

func main() {
	// initialize the device, open the serial connection
	it := iotee.NewIoTee(dev, baud)
	err := it.Open()
	if err != nil {
		log.Fatal(err)
	}
	defer it.Close()
	
	// construct a message of type MessageTypeDisplay
	bytes := []byte("Hello\nIoTee!")
	msg := iotee.NewMessage(iotee.MessageTypeDisplay, byte(len(bytes)))
	msg.Data = bytes
	
	// transmit the message to the device
	err = it.Transmit(&msg)
	if err != nil {
		log.Fatal(err)
	}
}

More examples in ./examples...

Documentation

Index

Constants

View Source
const (
	MessageStartByte  = '|'
	MessageMaxDataLen = 128

	MessageTypePing = 0x1A
	MessageTypePong = 0x1B

	MessageTypeButton = 0x2A

	MessageTypeDisplay  = 0x3A
	MessageTypeTempReq  = 0x4A
	MessageTypeTempRes  = 0x4B
	MessageTypeHumReq   = 0x5A
	MessageTypeHumRes   = 0x5B
	MessageTypePressReq = 0x6A
	MessageTypePressRes = 0x6B
	MessageTypeLightReq = 0x7A
	MessageTypeLightRes = 0x7B
	MessageTypeProxReq  = 0x8A
	MessageTypeProxRes  = 0x8B
	MessageTypeRGBLED   = 0x9A
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IoTee

type IoTee struct {
	RxChan chan *Message
	// contains filtered or unexported fields
}

func NewIoTee

func NewIoTee(device string, baud int) *IoTee

func (*IoTee) Close

func (it *IoTee) Close()

func (*IoTee) Open

func (it *IoTee) Open() error

func (*IoTee) ReceiveBlocking

func (it *IoTee) ReceiveBlocking() *Message

func (*IoTee) ReceiveWithTimeout

func (it *IoTee) ReceiveWithTimeout(timeout time.Duration) *Message

func (*IoTee) RxPump

func (it *IoTee) RxPump()

func (*IoTee) Transmit

func (it *IoTee) Transmit(msg *Message) error

type Message

type Message struct {
	MsgType byte
	DataLen byte
	Data    []byte
}

func NewMessage

func NewMessage(msgType byte, dataLen byte) Message

Jump to

Keyboard shortcuts

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