Hi,
I see that there is a way to read the current tag and print the output to a label using the below ZPL.
^XA
^RB96,8,3,3,20,24,38^FS
^FO50,50^A0N,40^FN0^FS
^FN0^RFR,E^FS
^XZ
Two questions:
- Is there a way to read it through the SDK without printing it? The reason I am asking is, I need to encode and print on the tag. Before encoding though I need to know what the current data is on the tag. After that I can print.
- Do you have an example on how to read using your iOS SDK?
Thanks
Anybody?
Points: 0
You voted ‘up’
We have developed some pieces of ZPL code for this particular use case. The below ZPL code would allow you to encode a tag and receive back a response with the code for saving it a database.
^XA^MMP^LS0
^BY3,3,123^FT83,160^B3N,N,,Y,N^FDA11115J^FS
^WVN^RFW,H,1,14,1^FD300030543101DC6823901977360D^FS
^RU
^FN1^FDSerial Number: #Q^FS
^FH^HV1,44,,_0D_0A,L^FS
^PQ1,0,1,Y^XZ
Points: 1
You voted ‘up’
Thanks. Would I still use the write method of the iOS SDK?
Points: 0
You voted ‘up’
We do not have this implemented for IOS, but we have added a seudo code(see below) that will allow you to implement multithreads for continuous tags encoding/prints. The logic should be same to be implemented in IOS.
string ip = "000.000.000.000";
event epcFound(int threadID, string epc);
deligate epcFoundHandler epcFound;
int [] idList;
Main()
{
string [] jobList;
this += epcFoundHandler(handleFoundEPC);
Random rand = new Random();
while (true)
{
// open a maximum of 8 connections at a time
while ((jobList.Length > 0) && (idList.Length <= 8)
{
int threadID = rand.next();
Thread t = new Thread(printAndPullEPC);
t.parameters(jobList[0], threadID);
// store thread id and job
idList.push(threadID);
t.Start();
this.Thread.Sleep(500);
}
// check for new jobs
this.Thread.Sleep(500);
}
}
public handleFoundEPC(int threadID, string epc)
{
{
// store epc
idList.remove(threadID);
}
public void printAndPullEPC(string printJob, int threadID)
ZebraPrinter printer = new ZebraPrinter();
printer.connect(ip);
string epc = printer.sendAndWaitForResponse(printjob, 1000, 200);
printer.disconnect();
epcFound(threadID, epc);
}
Thanks,
Manuel Caicedo
Points: 0
You voted ‘up’
There is no sendAndWaitForResponse method available for that class in iOS.
Points: 0
You voted ‘up’
You can try with the ZebraPrinterConnection Class for this operation in IOS, then you can separate this with two different methods in IOS.
1.) ZebraPrinterConnection:write -> Send data to the printer
2.) ZebraPrinterConnection:Read -> Read data from the printer.
id<ZebraPrinterConnection, NSObject> thePrinterConn = [[TcpPrinterConnection alloc] initWithAddress:theIpAddress andWithPort:9100];
// Open the connection - physical connection is established here.
BOOL success = [thePrinterConn open];
// This example prints "This is a ZPL test." near the top of the label.
NSString *zplData = @"^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";
NSError *error = nil;
// Send the data to printer as a byte array.
success = success && [thePrinterConn write:[zplData dataUsingEncoding:NSUTF8StringEncoding] error:&error];
if (success != YES || error != nil) {
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}
// Close the connection to release resources.
[thePrinterConn close];
[thePrinterConn release];
Points: 0
You voted ‘up’
The Read function however does not take any arguments to send the command. How does it know what to read?
Points: 0
You voted ‘up’
One thought is based in the sequence of the data received while the connection is open. However, we do not have sample code at this time to test this use case. You probably would need to make three calls on the same connection object…first to ‘write’, second to ‘waitForData’, third to ‘read’…., it is possible that maybe you would need to make an additional call to ‘hasBytesAvailable’. You can try this suggested implementation, and you could let us know what results you got.
Points: 0
You voted ‘up’
Ok, but but I can not write first. I need to read before writing.
Points: 0
You voted ‘up’
Sonu,
On page 35 of the RFID programming manual, there is an example on how to read the data from the tag and then print it (it does assume that the
RFID Label Format is a specific format, namely that it uses Format 1, "Encode a Gen 2 Tag in Hexadecimal" on page 33 of the manual.
Pages 93 & 94, show Set Get Do commands that allow you to read data from the RFID tag. To use these commands in iOS you would need to use the SGD utility class. You can find details on this class in the SDK documentation. I would try the above commands and see if it gets you the information that you need.
Also, could you please help me understand better your use case, why do you need to read the tag before you write to it?
Thank you,
Beverly
Points: 0
You voted ‘up’
Please share iOS code to read the data into an iOS object so that it can be sent to our database.
Points: 0
You voted ‘up’