scanner

package
v0.0.0-...-bf2171b Latest Latest
Warning

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

Go to latest
Published: May 31, 2015 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EVENT_BUFFER   = 64
	EVENT_CAPTURES = 16
	SCANNER_DEVICE = "/dev/input/event0" // default location on the Pi
)

Variables

View Source
var EVENT_SIZE = int(unsafe.Sizeof(InputEvent{}))
View Source
var KEYCODES = map[byte]string{
	0x02: "1",
	0x03: "2",
	0x04: "3",
	0x05: "4",
	0x06: "5",
	0x07: "6",
	0x08: "7",
	0x09: "8",
	0x0a: "9",
	0x0b: "0",
	0x0c: "-",
	0x10: "q",
	0x11: "w",
	0x12: "e",
	0x13: "r",
	0x14: "t",
	0x15: "y",
	0x16: "u",
	0x17: "i",
	0x18: "o",
	0x19: "p",
	0x1e: "a",
	0x1f: "s",
	0x20: "d",
	0x21: "f",
	0x22: "g",
	0x23: "h",
	0x24: "j",
	0x25: "k",
	0x26: "l",
	0x2c: "z",
	0x2d: "x",
	0x2e: "c",
	0x2f: "v",
	0x30: "b",
	0x31: "n",
	0x32: "m",
}

KEYCODES is the map of hex found in the InputEvent.Code field, and its corresponding char (string) representation [source: Vojtech Pavlik (author of the Linux Input Drivers project), via linuxquestions.org user bricedebrignaisplage]

Functions

func ScanForever

func ScanForever(device string, fn func(string), errFn func(error))

ScanForever takes a linux input device string pointing to the scanner to read from, invokes the given function on the resulting barcode string when complete, or the errfn on error, then goes back to read/scan again

Types

type InputEvent

type InputEvent struct {
	Time  syscall.Timeval
	Type  uint16
	Code  uint16
	Value int32
}

InputEvent is a Go implementation of the native linux device input_event struct, as described in the kernel documentation (https://www.kernel.org/doc/Documentation/input/input.txt), with a big assist from https://github.com/gvalkov/golang-evdev

Jump to

Keyboard shortcuts

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