libmsr

package
v0.0.0-...-582891e Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VendorID  uint16 = 0x0801
	ProductID uint16 = 0x0003
)

Variables

This section is empty.

Functions

func DecodeRaw

func DecodeRaw(raw []byte, offset byte, bpcRaw, bpcChars int, parityEven bool) (chars []byte, parityOK []bool, lrcOK bool)

func EncodeRaw

func EncodeRaw(chars []byte, offset byte, bpcRaw, bpcChars int, parityEven bool) []byte

Types

type Device

type Device struct {
	PreSendDelay time.Duration
	CheckTimeout,
	SwipeTimeout time.Duration
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(d usb.Device) *Device

func (*Device) Close

func (d *Device) Close() error

Close resets and closes the USB device.

func (*Device) Erase

func (d *Device) Erase(t1, t2, t3 bool) error

Erase clears the selected tracks on a card. Does not return until a card is swiped or d.SwipeTimeout is reached.

func (*Device) FirmwareVersion

func (d *Device) FirmwareVersion() (string, error)

FirmwareVersion returns the device's reported firmware version.

func (*Device) IsHiCo

func (d *Device) IsHiCo() (bool, error)

IsHiCo checks the device's current write coercivity.

func (*Device) Model

func (d *Device) Model() (string, error)

Model returns the device's reported model.

func (*Device) ReadISOTracks

func (d *Device) ReadISOTracks() ([]byte, error)

ReadISOTracks reads ISO data from a card. Does not return until a card is swiped or d.SwipeTimeout is reached.

func (*Device) ReadRawTracks

func (d *Device) ReadRawTracks() ([3][]byte, error)

WriteRawTracks reads raw data from a card. Data can be decoded with DecodeRaw. Does not return until a card is swiped or d.SwipeTimeout is reached.

func (*Device) Reset

func (d *Device) Reset() error

Reset resets the device. Useful for cancelling timed-out operations.

func (*Device) SetBitsPerChar

func (d *Device) SetBitsPerChar(t1, t2, t3 int) error

SetBitsPerChar sets the number of bits (including parity) for each track.

func (*Device) SetBitsPerInch

func (d *Device) SetBitsPerInch(t1, t2, t3 int) error

SetBitsPerInch sets the density of each track in BPI.

func (*Device) SetHiCo

func (d *Device) SetHiCo() error

SetHiCo sets the device to write Hi-Co cards.

func (*Device) SetLED

func (d *Device) SetLED(mode LEDMode) error

SetLED sets the device's LEDs to mode.

func (*Device) SetLoCo

func (d *Device) SetLoCo() error

SetLoCo sets the device to write Lo-Co cards.

func (*Device) TestCommunication

func (d *Device) TestCommunication() error

TestCommunication verifies the connection with the device.

func (*Device) TestRAM

func (d *Device) TestRAM() error

TestRAM verifies that the device's onboard RAM is working.

func (*Device) TestSensor

func (d *Device) TestSensor() error

TestSensor verifies that the device's card sensing circuit is working. Does not return until a card is sensed or d.SwipeTimeout is reached.

func (*Device) WriteISOTracks

func (d *Device) WriteISOTracks(t1, t2, t3 []byte) error

WriteISOTracks writes ISO data to a card. Does not return until a card is swiped or d.SwipeTimeout is reached.

func (*Device) WriteRawTracks

func (d *Device) WriteRawTracks(t1, t2, t3 []byte) error

WriteRawTracks writes raw data to a card. Data can be encoded with EncodeRaw. Does not return until a card is swiped or d.SwipeTimeout is reached.

type LEDMode

type LEDMode byte
const (
	LEDAllOff LEDMode = iota
	LEDAllOn
	LEDGreenOn
	LEDYellowOn
	LEDRedOn
)

type Status

type Status byte

Status represents a status byte returned by the device. It implements the error interface.

const (
	StatusOK                Status = '0'
	StatusReadWriteErr      Status = '1'
	StatusInvalidCommandFmt Status = '2'
	StatusInvalidCommand    Status = '4'
	StatusWriteSwipeErr     Status = '9'
	StatusFail              Status = 'A'
)

func (Status) Error

func (s Status) Error() string

Jump to

Keyboard shortcuts

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