Reading data after making ^HZA query

B Bobby Ren 3 years 6 months ago
10 0 0

I am using Zebra Link and writing commands directly to Zebra through the iOS SDK. I would like to make a printer description query using ^HZA. Currently, I wait a number of milliseconds before making a read command, but the time it takes for the printer to return the data varies, and sometimes I have to build in a timeout. Is there an accepted process to read the result data? Is there a callback function available in the iOS sdk to listen for printer responses, or is there a suggested timeout or time interval to read data from the printer connection until we receive data?
Sample code:
let opened = connection.open()
let zplCommand = "^XA^HZA^XZ"
guard opened, let data: Data = zplCommand.data(using: .utf8) else { return }
var error: NSError? = nil
connection.write(data, error: &error)
if let error = error {
return
}
usleep(1000) //

CONTACT
Can’t find what you’re looking for?