Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:00:53+00:00 2026-06-04T10:00:53+00:00

I need to send a series of printer commands to a Sato barcode printer.

  • 0

I need to send a series of printer commands to a Sato barcode printer. For example:

<ESC>A
<ESC>H0120
<ESC>V0060
<ESC>$B,180,180,0
<ESC>$=Information
...

I have an open tcp/ip connection to the printer and simply want to write an NSData object, such as:

[connection write:data error:error];

wheras data is an NSData object. I realize that I can insert the escape into a string using the binary value with \x1B. For example:

NSString *printString=[[NSString alloc]initWithString:@"\x1BA\X1BH0120\X1BV0060\X1B$B,180,180,0/X1B$=Information"];  

The problem I’m having is that I don’t know how to translate my string to NSData for the write.

I appreciate any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:00:54+00:00Added an answer on June 4, 2026 at 10:00 am

    I’ll give an update on some of my findings in case someone stumbles upon a similar problem in the future. My problem was that I needed to send a series of printer commands to a Sato barcode printer. Sato uses a proprietary language that requires syntax like above whereas I needed to send commands like <ESC>A and <ESC>Z. I had an open tcp/ip connection and kept trying several methods to send the commands with no luck. I though the problem was in my translation to NSData. I was close, but not close enough. The problem turned out to be in my translation from a file to an NSString…not when I was converting the NSString to NSData. I also had problems trying to use \x “escapes” to send the binary equivalent of <ESC>. I finally settled on using the octal equivalent.

        // load the appropriate file as a string
        NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"sato.txt"];
        NSError *firstError=nil;
        NSString *satoData=[[NSString alloc]initWithContentsOfFile:filePath encoding:NSNonLossyASCIIStringEncoding error:&firstError]; // the NSNonLossyASCIIStringEncoding was the key to correcting my problem here.
        satoData=[satoData stringByReplacingOccurrencesOfString:@"Description" withString:self.description];
        satoData=[satoData stringByReplacingOccurrencesOfString:@"ItemID" withString:self.itemId];
        satoData=[satoData stringByReplacingOccurrencesOfString:@"Quantity" withString:self.printQty];
        NSDate *now=[NSDate date];
        NSString *formattedDate=[NSDateFormatter localizedStringFromDate:now dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
        satoData=[satoData stringByReplacingOccurrencesOfString:@"Date" withString:formattedDate];
        NSData *data=[satoData dataUsingEncoding:NSUTF8StringEncoding];
    
        [connection write:data error:error];
    

    Here is a sample of some of the contents of the sato.txt file

    \033A\033#E5\033Z
    \033A\033H0120\033V0060\033$B,180,180,0\033$=ItemID
    

    The \033 is the octal escapes for <ESC>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario where I need to send a series of data across
I need send AT commands to a usb GSM modem whith C#. The problem
I need send certain attributes(say, human readable user name) from server to client after
Hi i need send file to server i use this code public void PostFile()
I've a custom form (created with form API) that need send an uploaded file
I need to send mail with PHP and I use mail function like this:
I need to send the device token required for push notification in iOS to
I need to send a string to a website and get back a result.
I need to send a SOAP request to a URL. But i find this
I need to send mails with java mail from a webserver over an exchange

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.