gocomm

package module
v0.0.0-...-89aa4fc Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Example

package main

import (
	"fmt"

	gocomm "github.com/mv-kan/go-comm"
)

func main() {
	fmt.Println("I am writer")
	p, err := gocomm.NewPort("/dev/", 115200, 0)
	if err != nil {
		panic(err)
	}
	input := make(chan string)
	conn, msgChan, err := gocomm.NewConnection(p, input, 0, "\n", "\n")
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	msg := <-msgChan
	fmt.Println("msg.Data=", msg.Data)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDevice       = errors.New("device error")
	ErrNotConnected = errors.New("not connected")
)

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Close() error
}

func NewConnection

func NewConnection(
	p Port,
	input <-chan string,
	writeInterval time.Duration,
	delimRead string,
	delimWrite string,
) (Connection, <-chan Message, error)

type Message

type Message struct {
	Data string
	Err  error
}

type Port

type Port interface {
	Close() error
	Flush() error
	Read(b []byte) (n int, err error)
	Write(b []byte) (n int, err error)
	Reopen() error
}

func NewPort

func NewPort(devPath string, baud int, readTimeout time.Duration) (Port, error)

Jump to

Keyboard shortcuts

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