1

I have a label printer, a Brady i3300, that I am connecting to from my iPad using a tcp socket (using the CocoaAsyncSocket framework). Each time I send data to the printer, it prints, but the label is always blank.

Process

First, I run connectToPrinter, and the didConnectToHost delegate fires. After the successful connection, I call printLabelToPrinter, where the printer is sent the data. The didWriteDataWithTag delegate is called just after this, the printer begins / finishes printing, but the label is blank.

It has not mattered thus far what content is in the data file (explained below), so it feels like a connection issue...Regardless, the printer seems to be receiving the request without any data along with it.

Why is the printer printing blank labels?


Code & Files

Here is my connection setup:

- (void)connectToPrinter {

    // Create the socket
    self.socket = [GCDAsyncSocket.alloc initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    
    // Connect to the printer via IP and port
    NSError *err = nil;
    if (![self.socket connectToHost:@"10.0.0.147" onPort:9100 error:&err]) {
        // Something went wrong!
        NSLog(@"I goofed: %@", err);
    }

}

- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
    
    NSLog(@"connected to host!: %@", host);
    [self printLabelToPrinter];

}

Note: the .zpl file ref below contains a ZPL printing script, one of the supported languages of Brady printers

- (void)printLabelToPrinter {

    // Get the ZPL file and convert it over to data
    NSString *filePath = [NSBundle.mainBundle pathForResource:@"label" ofType:@".zpl"];
    NSData *data = [NSFileManager.defaultManager contentsAtPath:filePath];

    // Write the data to the printer
    [self.socket writeData:data withTimeout:10 tag:1];

}

- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag {
    NSLog(@"did write data: %ld", tag);
}

Here is the .zpl file

^XA
^CF0,60
^FO50,50^GB100,100,100^FS
^FO75,75^FR^GB100,100,100^FS
^FO50,300
^FO504,300^FDTest
^XZ
Community
  • 1
  • 1
Will Von Ullrich
  • 2,129
  • 2
  • 15
  • 42
  • 1
    On thermal printers it is quite common to print a label while the darkness or heat setting is not set high enough to activate the ribbon or the paper. Have you checked the darkness setting? – Elton Saunders Jan 09 '20 at 21:05
  • I am not familiar with objectiv-c or cocoa, but maybe you need to send the data with the correct encoding? ASCII should work... – Delphi Coder Jan 10 '20 at 06:47
  • @EltonSaunders I have been able to print without adjusting the settings on both Windows and my Mac, but perhaps the drivers are telling the printer to raise the heat setting to activate the ribbon. I’ll give it a look - thanks! – Will Von Ullrich Jan 13 '20 at 13:24
  • @EltonSaunders not the heat setting - turned it up to max and still nothing. I don't even hear the ribbon activating / turning during the print, that's what's bizarre. – Will Von Ullrich Jan 13 '20 at 19:11
  • does the printer have a "dump" mode? Basically a mode where it will print whatever it receives? – Elton Saunders Jan 14 '20 at 14:35
  • Not sure - looking through their docs it seems many Brady models have dump modes for character printing / testing, I'll see if that gets me anywhere. I'll try encoding differently as well, maybe the ASCII is causing issues ‍♂️ – Will Von Ullrich Jan 14 '20 at 16:45

0 Answers0