Commita3eaf3dd by developer29

Project added

parents
File added
File added
packagemain
import(
"C"
"fmt"
"syscall"
"unsafe"
"bufio"
"os"
"strings"
)
varufr_lib=syscall.NewLazyDLL("uFCoder-x86_64.dll")
funcReaderOpening(){
fmt.Printf("1. Simple reader open\n")
fmt.Printf("2. Advanced reader open\n")
varopen_choiceint
fmt.Scanln(&open_choice)
ifopen_choice==1{
varuFCoder=ufr_lib.NewProc("ReaderOpen")
ret,_,_:=uFCoder.Call()
fmt.Printf("ReaderOpen: 0x%02X\n",ret)
ifret==0{
fmt.Printf("==================================\n")
fmt.Printf("uFR NFC Reader successfully opened\n")
fmt.Printf("==================================\n")
fmt.Printf("Press ENTER to read card UID\n")
}
}elseifopen_choice==2{
fmt.Printf("Reader type:\n")
varreader_typeint
fmt.Scanln(&reader_type)
fmt.Printf("Port name:\n")
reader:=bufio.NewReader(os.Stdin)
varinput_port_namestring
input_port_name,_=reader.ReadString('\n')
varport_name=strings.TrimRight(input_port_name,"\r\n")
fmt.Printf("Port interface:\n")
varinput_port_interfacestring
input_port_interface,_=reader.ReadString('\n')
varport_interfaceint
ifstrings.TrimRight(input_port_interface,"\r\n")=="T"{
port_interface=84
}elseifstrings.TrimRight(input_port_interface,"\r\n")==“U”{
port_interface=85
}
fmt.Printf("Arg:\n")
varinput_argstring
input_arg,_=reader.ReadString('\n')
vararg=strings.TrimRight(input_arg,"\r\n")
port_name_CS:=C.CString(port_name)
argCS:=C.CString(arg)
varuFCoder=ufr_lib.NewProc("ReaderOpenEx")
ret,_,_:=uFCoder.Call(uintptr(byte(reader_type)),uintptr(unsafe.Pointer(port_name_CS)),uintptr(byte(port_interface)),uintptr(unsafe.Pointer(argCS)))
ifret==0{
fmt.Printf("==================================\n")
fmt.Printf("uFR NFC Reader successfully opened\n")
fmt.Printf("==================================\n")
fmt.Printf("Press ENTER to read card UID\n")
}
}
}
funcReaderUISignal(lightbyte,哔哔的声音byte){
varuFCoder=ufr_lib.NewProc("ReaderUISignal")
uFCoder.Call(uintptr(light),uintptr(哔哔的声音))
}
funcGetCardIdEx(sakbyte,uid[10]byte,uidSizebyte){
varuFCoder=ufr_lib.NewProc("GetCardIdEx")
ret,_,_:=uFCoder.Call(uintptr(unsafe.Pointer(&sak)),uintptr(unsafe.Pointer(&uid)),uintptr(unsafe.Pointer(&uidSize)))
ifret==0{
fmt.Printf("CARD DETECTED [type = 0x%02X",sak)
fmt.Printf(", uid[%d] = ",uidSize)
fori:=0;i<int(uidSize);i++{
fmt.Printf("%02X",uid[i])
}
fmt.Printf("]")
}elseifret==8{
fmt.Printf("NO CARD DETECTED")
}else{
fmt.Printf("GetCardIdEx(): 0x%02X",ret)
}
}
funcHandleUID(){
reader:=bufio.NewReader(os.Stdin)
varinputstring
input,_=reader.ReadString('\n')
ifstrings.TrimRight(input,"\r\n")==""{
varsakbyte
varuid[10]byte
varuidSizebyte
GetCardIdEx(sak,uid,uidSize)
}
}
funcmain(){
ReaderOpening()
ReaderUISignal(1,1)
for{
HandleUID()
}
}
\ No newline at end of file
    Markdownis supported
    0%or
    You are about to add0peopleto the discussion. Proceed with caution.
    Finish editing this message first!
    Pleaseregisteror发表评论
    Baidu
    map