works with hidraw
This commit is contained in:
parent
0689803582
commit
7f988e2841
2
go.mod
2
go.mod
@ -1,5 +1,3 @@
|
|||||||
module gitlab.com/wobcom/iot/schnutibox
|
module gitlab.com/wobcom/iot/schnutibox
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require github.com/karalabe/hid v1.0.0
|
|
||||||
|
2
go.sum
2
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=
|
|
15
main.go
15
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
|
// 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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"github.com/karalabe/hid"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
product = 0x27db
|
|
||||||
vendor = 0x16c0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const newLine = 40
|
const newLine = 40
|
||||||
@ -30,9 +24,7 @@ var charMap = map[byte]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
readerInfo := hid.Enumerate(vendor, product)[0]
|
d, err := os.Open("/dev/hidraw7")
|
||||||
|
|
||||||
d, err := readerInfo.Open()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -46,7 +38,6 @@ func main() {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
// Reading the RFID reader.
|
// Reading the RFID reader.
|
||||||
// TODO: Check if "/dev/hidraw" can be used.
|
|
||||||
_, err := d.Read(buf)
|
_, err := d.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user