From a777eb3394b72795a75aa2a7f7db82f1c37fd93d Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Fri, 27 Feb 2026 04:14:41 -0800 Subject: exec -> systemd-run; more parsing --- cmd/ipp/main.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'cmd/ipp/main.go') diff --git a/cmd/ipp/main.go b/cmd/ipp/main.go index 16317e0..21cf0fc 100644 --- a/cmd/ipp/main.go +++ b/cmd/ipp/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/binary" "encoding/hex" "flag" "log" @@ -15,10 +16,39 @@ var follow = flag.Bool("f", false, "don't exit after response") func main() { flag.Parse() - log.SetFlags(log.Lshortfile) + log.SetFlags(log.Lshortfile | log.Ldate | log.Ltime | log.Lmicroseconds) + log.Println("start") wc := make(chan struct{}, 1) cv, err := cvend.Open(cvend.Path, func(msgType byte, msgData []byte) { - log.Printf("ipp %02x\n%s", msgType, hex.Dump(msgData)) + switch msgType { + case 0x07: + log.Printf("Heartbeat(%s)", hex.EncodeToString(msgData)) + case 0x0f: + log.Printf("Startup(%s)", hex.EncodeToString(msgData)) + case 0xed: + if len(msgData) == 0 { + log.Printf("Log()") + } else { + log.Printf("Log(%d) %q", msgData[0], string(msgData[1:])) + } + case 0xbe: + if len(msgData) < 22 || len(msgData) < 22+int(msgData[21]) { + log.Printf("PICCRead(short)\n%s", hex.Dump(msgData)) + } else { + _ = msgData[:11] // unknown + uid := msgData[11:18] + atqa := binary.LittleEndian.Uint16(msgData[18:20]) + sak := msgData[20] + atrLen := msgData[21] + atr := msgData[22 : 22+atrLen] + _ = msgData[22+atrLen:] // unknown + log.Printf("PICCRead(uid %s atqa 0x%04x sak %02x atr %s)\n%s", hex.EncodeToString(uid), atqa, sak, hex.EncodeToString(atr), hex.Dump(msgData)) + } + case 0xd1: + log.Printf("EMVTransactionSuccessUnk\n%s", hex.Dump(msgData)) + default: + log.Printf("ipp %02x\n%s", msgType, hex.Dump(msgData)) + } select { case wc <- struct{}{}: default: -- cgit v1.2.3