add more tests
add network capability to example app
This commit is contained in:
27
cmd/zplgfa/network.go
Normal file
27
cmd/zplgfa/network.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
func sendDataToZebra(ip, port, str string) error {
|
||||
tcpAddr, err := net.ResolveTCPAddr("tcp", ip+":"+port)
|
||||
conn, err := net.DialTCP("tcp4", nil, tcpAddr)
|
||||
if err == nil {
|
||||
defer conn.Close()
|
||||
|
||||
payloadBytes := []byte(fmt.Sprintf("%s\r\n\r\n", str))
|
||||
_, err = conn.Write(payloadBytes)
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func sendFeedCmdToZebra(ip, port string) error {
|
||||
return sendDataToZebra(ip, port, "^xa^aa^fd ^fs^xz")
|
||||
}
|
||||
|
||||
func sendCalibCmdToZebra(ip, port string) error {
|
||||
return sendDataToZebra(ip, port, "~jc^xa^jus^xz")
|
||||
}
|
||||
Reference in New Issue
Block a user