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

  • SEARCH
  • Home
  • 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 8176583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:14:22+00:00 2026-06-06T23:14:22+00:00

I’m trying to make an app that communicate iPhone with another hardware using dock

  • 0

I’m trying to make an app that communicate iPhone with another hardware using dock to RS232 wire (I bought from RedPark). I’m also using the library provided by redpark. I made a simple code at beginning, it worked fine.
UInt8 infoCmd[5] = {0x3E,0x3E,0x05,0x80,0xff};
[rscMgr write:infoCmd Length:5];
Then I want to add more command to it, so I create a method that returns different combinations of command I need.

- (UInt8 *)requestCommand:(int)commandName{
    UInt8 * command;
    if (commandName == DATADUMP) {
        command=[Communication buildDataDump];
    }
    if (commandName == GETSERIALINFO) {
        command=[Communication buildGetSerailInfo];   
    }
    return command;
}
+ (UInt8 *)buildGetSerailInfo{
    UInt8 *command = malloc(sizeof(UInt8)*5);
    command[0]=SYN;
    command[1]=SYN;
    command[2]=ENQ;
    command[3]=GETSERIALINFO;
    //command[4] = {SYN, SYN, ENQ, GETSERIALINFO};
    return command;    
}

The thing is, some of my commands includes data that can be 200 bytes long. How can I create an UInt8 array that is easier for me to add bytes?
I’m new to programming, please explain to me in detail. Thank you a lot in advance.

  • 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-06T23:14:25+00:00Added an answer on June 6, 2026 at 11:14 pm

    Actually you will just send data, row byte over the wire. I do something similar in one project (not wire, but RS232 commands over TCP/IP), and it becomes quite simple, if you use an NSMutableData instance.

    A snippet from my code:

    static u_int8_t codeTable[] =   { 0x1b, 0x74, 0x10 };
    static u_int8_t charSet[]   =   { 0x1b, 0x52, 0x10 };
    static u_int8_t formatOff[] =   { 0x1b, 0x21, 0x00 };
    static u_int8_t reverseOn[] =   { 0x1d, 0x42, 0x01 };
    static u_int8_t reverseOff[]=   { 0x1d, 0x42, 0x00 };
    static u_int8_t paperCut[]  =   { 0x1d, 0x56, 0x0 };  
    
    
    NSMutableData *mdata = [NSMutableData dataWithBytes:&formatOff length:sizeof(formatOff)];
    [mdata appendBytes:&formatOff length:sizeof(formatOff)];
    [mdata appendBytes:&reverseOff length:sizeof(reverseOff)];    
    [mdata appendData: [NSData dataWithBytes: &codeTable length:sizeof(codeTable)]];
    [mdata appendData: [NSData dataWithBytes: &charSet length:sizeof(charSet)]];
    

    As you see, I am just appending the data byte by byte.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.