usbserial

package module
v0.0.0-...-40b6298 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

README

i.MX Serial over USB driver

This Go package implements communication through Serial over USB (CDC-ACM) on NXP i.MX SoCs, to be used with GOOS=tamago GOARCH=arm as supported by the TamaGo framework for bare metal Go on ARM SoCs.

This CDC-ACM Serial over USB driver has been tested on Linux as follows:

picocom -b 115200 -eb /dev/ttyACM0 --imap lfcrlf

Authors

Andrea Barisani
andrea.barisani@withsecure.com | andrea@inversepath.com

Documentation

The package API documentation can be found on pkg.go.dev.

For more information about TamaGo see its repository and project wiki.

License

tamago | https://github.com/usbarmory/imx-usbserial
Copyright (c) WithSecure Corporation

These source files are distributed under the BSD-style license found in the LICENSE file.

Documentation

Overview

Package usbserial implements Serial over USB (CDC-ACM) on i.MX6 SoCs.

This package is only meant to be used with `GOOS=tamago GOARCH=arm` as supported by the TamaGo framework for bare metal Go on ARM SoCs, see https://github.com/usbarmory/tamago.

Index

Constants

This section is empty.

Variables

View Source
var MaxPacketSize uint16 = 512

MaxPacketSize represents the USB data interface endpoint maximum packet size

Functions

This section is empty.

Types

type UART

type UART struct {
	sync.Mutex

	// Device is the USB device associated to Serial over USB interface.
	Device *usb.Device

	// Rx is endpoint 1 OUT function, set by Init() to ACMRx if not
	// already defined.
	Rx func([]byte, error) ([]byte, error)

	// Tx is endpoint 1 IN function, set by Init() to ACMTx if not already
	// defined.
	Tx func([]byte, error) ([]byte, error)

	// Control is endpoint 2 IN function
	Control func([]byte, error) ([]byte, error)
	// contains filtered or unexported fields
}

UART represents a Serial over USB interface instance.

func (*UART) ACMControl

func (serial *UART) ACMControl(_ []byte, lastErr error) (in []byte, err error)

ACMControl implements the endpoint 1 IN function.

func (*UART) ACMRx

func (serial *UART) ACMRx(out []byte, lastErr error) (_ []byte, err error)

ACMRx implements the endpoint 2 OUT function, used to receive serial communication from host to device.

func (*UART) ACMTx

func (serial *UART) ACMTx(_ []byte, lastErr error) (in []byte, err error)

ACMTx implements the endpoint 2 IN function, used to transmit serial communication from device to host.

func (*UART) Init

func (serial *UART) Init() (err error)

Init initializes a Serial over USB interface.

func (*UART) Write

func (serial *UART) Write(p []byte) (n int, err error)

Write appends the contents of p to the serial transmission buffer.

func (*UART) WriteByte

func (serial *UART) WriteByte(c byte) (err error)

WriteByte appends the byte c to the serial transmission buffer.

Jump to

Keyboard shortcuts

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