From 7f988e28412a389fa8af7a6374921bbb8aa41634 Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Sat, 27 Mar 2021 15:19:32 +0100 Subject: [PATCH] works with hidraw --- go.mod | 2 -- go.sum | 2 -- main.go | 15 +++------------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 11c1100..39b5ad7 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module gitlab.com/wobcom/iot/schnutibox go 1.16 - -require github.com/karalabe/hid v1.0.0 diff --git a/go.sum b/go.sum index e09e634..e69de29 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +0,0 @@ -github.com/karalabe/hid v1.0.0 h1:+/CIMNXhSU/zIJgnIvBD2nKHxS/bnRHhhs9xBryLpPo= -github.com/karalabe/hid v1.0.0/go.mod h1:Vr51f8rUOLYrfrWDFlV12GGQgM5AT8sVh+2fY4MPeu8= diff --git a/main.go b/main.go index 5052984..9c6bfa0 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,11 @@ // https://medium.com/coinmonks/iot-tutorial-read-tags-from-a-usb-rfid-reader-with-raspberry-pi-and-node-red-from-scratch-4554836be127 -// nolint: gochecknoglobals, lll, forbidigo, godox +// nolint: gochecknoglobals, lll, forbidigo package main import ( "fmt" "log" - - "github.com/karalabe/hid" -) - -const ( - product = 0x27db - vendor = 0x16c0 + "os" ) const newLine = 40 @@ -30,9 +24,7 @@ var charMap = map[byte]string{ } func main() { - readerInfo := hid.Enumerate(vendor, product)[0] - - d, err := readerInfo.Open() + d, err := os.Open("/dev/hidraw7") if err != nil { log.Fatal(err) } @@ -46,7 +38,6 @@ func main() { for { // Reading the RFID reader. - // TODO: Check if "/dev/hidraw" can be used. _, err := d.Read(buf) if err != nil { log.Print(err)