使用getvar时如何让Zebra打印机返回换行符?

I wrote a simple Go program to connect to the printer, run a get command

! U1 getvar "zpl.system_status"

I was then trying to read the response but my read listener kept timing out. I was expecting a at the end of the data coming from the printer but was not getting it. Is there a way to tell the printer to respond and terminate the line with ?

If not, what's the best way to listen for a response. I ended up reading the stream and then setting a timeout to wait for more data, but that seems kind of hacky.

Is there a specific character I can wait for to indicate the printer is done sending the response?

I also logged in with a telnet client manually and saw the same behavior.

Here is the code I put together. It's rough at the moment, just trying to get things working before I clean it up. It does get the response with this code and with the commented out code, but I feel like I should be getting a line terminator from the server and I'm not.

package main

import (
    "bufio"
    "net"
    "os"
    "time"
)

func main() {
    dialer := net.Dialer{Timeout: 1 * time.Second}
    conn, err := dialer.Dial("tcp", "127.0.0.1:9100")
    if err != nil {
        println("Dial failed: ", err.Error())
        os.Exit(1)
    }
    defer conn.Close()

    rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))

    println("Sending string request")
    n, err := rw.WriteString("! U1 getvar \"interface.network.active.mac_addr\"
")
    if err != nil {
        println("Error getting status.", err)
    }
    println("Characters sent: ", n)

    err = rw.Flush()
    if err != nil {
        println("Error on flush", err)
    }

    err = conn.SetReadDeadline(time.Now().Add(1 * time.Second))
    if err != nil {
        println("Set Deadline failed: ", err)
    }

    // buffer := make([]byte, 0, 1024)
    // tmp := make([]byte, 128)
    // for {
    //  n, err := conn.Read(tmp[:])
    //  if err != nil {
    //      println(err)
    //      break
    //  }
    //  println(n)
    //  buffer = append(buffer, tmp[:n]...)
    // }
    // println(string(buffer))

    response, err := rw.ReadString('
')
    if err != nil {
        println("Read error: ", err.Error())
    }
    println("Response: ", response)
}

Response - I changed the mac address below but this is basically what I get.

Sending string request
Characters sent:  49
Read error:  read tcp i/o timeout
Response:  "07:4d:07:79:47:ef"

Use the JSON wrapping of SGD:

send {}{"zpl.system_status":null}

The response will come back in JSON to you can look for the closing }