usbio2

package module
v0.0.0-...-22821d9 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 6 Imported by: 0

README

go-usbio2

Dependencies

Install

export GOPATH=/path/to/go-develop-directory
go get github.com/yukkeorg/go-usbio2

Example

package main

import "fmt"
import "github.com/yukkeorg/go-usbio2"

func main() {
	usbio, err := usbio2.NewUsbIO2()
	if err != nil {
		return
	}
	defer usbio.Cleanup()

	fmt.Printf("Device Name: %s\n", usbio.GetDeviceName())

cmd, _ := usbio.CreateCommand(usbio2.CMD_WRITEREAD)
	r, err := usbio.WriteRead(cmd)
	if err != nil {
		return
	}

	fmt.Printf("ReadData : %v\n", r)
}

License

MIT

Documentation

Index

Constants

View Source
const (
	USB_VENDOR       uint16 = 0x1352
	USB_PRODUCT_ORIG uint16 = 0x0120 // ORIGINAL
	USB_PRODUCT_AKI  uint16 = 0x0121 // AKIZUKI Compatible

	COMMANDSIZE int = 64

	// Command
	CMD_WRITEREAD   byte = 0x20
	CMD_READWRITE   byte = 0x21 // for original
	CMD_REPEATWRITE byte = 0x22 // for original

	CMD_READFROMFLASH byte = 0xF0
	CMD_WRITETOFLASH  byte = 0xF1

	CMD_READCONFIG  byte = 0xF8
	CMD_WEIRWCONFIG byte = 0xF9

	// Config
	CNF_P2_PULLUP_ENABLE  byte = 0x00
	CNF_P2_PULLUP_DISABLE byte = 0x01
	CNF_P2_PULLUP_DEFALUT byte = CNF_P2_PULLUP_ENABLE

	CNF_P1_PIN_DEFAULT byte = 0x00
	CNF_P2_PIN_DEFAULT byte = 0x0F
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UsbIO2

type UsbIO2 struct {
	// contains filtered or unexported fields
}

func NewUsbIO2

func NewUsbIO2() (*UsbIO2, error)

func (*UsbIO2) Cleanup

func (self *UsbIO2) Cleanup()

func (*UsbIO2) CreateCommand

func (self *UsbIO2) CreateCommand(requestId byte) ([]byte, error)

func (*UsbIO2) CreateCommandWithData

func (self *UsbIO2) CreateCommandWithData(requestId byte, data []byte) ([]byte, error)

func (*UsbIO2) GetConfig

func (self *UsbIO2) GetConfig() (*UsbIO2Config, error)

func (*UsbIO2) GetDeviceName

func (self *UsbIO2) GetDeviceName() string

func (*UsbIO2) GetPortStatus

func (self *UsbIO2) GetPortStatus() (uint16, error)

func (*UsbIO2) Read

func (self *UsbIO2) Read() ([]byte, error)

func (*UsbIO2) Write

func (self *UsbIO2) Write(data []byte) error

func (*UsbIO2) WriteRead

func (self *UsbIO2) WriteRead(command []byte) ([]byte, error)

type UsbIO2Config

type UsbIO2Config struct {
	// "Disable" Port2 pullup settings
	// bit0 on: Disable, bit0 off: Enable
	EnablePullUp bool

	// Pin Settings
	// true: input, false: output
	Port1 []bool
	Port2 []bool
}

func NewUsbIO2Config

func NewUsbIO2Config() *UsbIO2Config

func (*UsbIO2Config) FromBytes

func (self *UsbIO2Config) FromBytes(buf []byte)

func (*UsbIO2Config) ToBytes

func (self *UsbIO2Config) ToBytes() []byte

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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