?
Solved

Need to send a 'string' of know hex values over a serial connection.

Posted on 2005-03-21
11
Medium Priority
?
188 Views
Last Modified: 2010-04-15
The series looks like this (but there are several more bytes): '19 00 1A 1E 2D 7E FD...'

I need to understand how to represent this within C.  I think it as such:
char buffer[] = {0x19,0x00,0x1A,0x1E,0x2D,0x7E,0xFD...};

It will then be sent over the IR port on a Palm IIIxe to control one function on one remote control which operates my camcorder.

Thanks for your help,
Emory
0
Comment
Question by:KingDumbNo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 1600 total points
ID: 13591531

You can certainly do this like you've stated.  There are several ways to do this, all based on roughly the same logic.

#define BUFFER_SIZE 20

char buffer[BUFFER_SIZE] =
{
  0x19,
  0x00,
  0x1A,
  0x1E,
  0x2D,
  0x7E,
  0xFD,
...
};

or

char buffer[BUFFER_SIZE] =
{
  '0x19',
  '0x00',
  '0x1A',
  '0x1E',
  '0x2D',
  '0x7E',
  '0xFD',
...
};


Then use any of the standard I/O systems, probably streams, to write the data.

Kent
0
 
LVL 8

Assisted Solution

by:novitiate
novitiate earned 280 total points
ID: 13591760
use unsigned char instead of char
typedef unsigned char byte;

byte data[] ={0xa0, 0x1D};

_novi_
0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13591826
Thanks.  I'll try this this evening.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13592010

Unsigned chars are pretty important if you need to compare data values.  This is true regardless of the application.  The sign extension that occurs when recasting to an integer can be really deceptive.  (Especially on automatic recasting.)

If you're not going to compare the data, signed or unsigned should work equally well.

Kent


0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13592181
I believe getting this portion of my program working is the least of my issues.  According to more research, I think I have to change the baud rate between bytes, but the values to change to are unknown.  This is not a part of this question, but if you have any input as to how and where to better ask for more assistance then I would be grateful.  It has to do with consumer IR and the incompatibility with the Palm's IR hardware.  Some kind of hack is needed.  This has been done, but the commercial products (e.g., OmniRemote) do not fit my needs.

Thanks,
Emory
0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13592189
Increased points in hopes that further assistance can be gained.
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13592228

How do you determine when to change baud rates?

0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13592347
Kdo,

I've posted the question in the Palm Pilot area.  I have asked the question as though I can get the syntax of the code you verified to work, and that the camcorder didn't recognize the sequence.  This may seem pessimistic, but sending the data from a program written in another language for the Palm (NSBasic) did not work, so I am attempting to get a jump start on someone seeing the problem I am having and offering the solution to the varying baud rates question.

If no one knows then I will start with an educated guess and start the trial and error process.  Ugh!

Thanks again,
Emory
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 120 total points
ID: 13592464
You have to not only get the data right, but set the right baud rate, number of data bits, parity bits, type of parity, and perhaps number of stop bits.   Then you might have to send 1 to 27 bytes to flush the garbage out of the serial port.  Then you might have to figure out how to change the baud rate on the fly, and do so at the right time.  Sounds pretty hard to get right!.

0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13592747
Well, well...Have a look at this:
http://www.cswl.com/whiteppr/tech/pulseshaping.html

grg99: Yep, pretty hard!

Looks like I could do it, but not in the near future.  I'll close this question tomorrow.
0
 
LVL 6

Author Comment

by:KingDumbNo
ID: 13643920
Thanks again for help with the syntax.  With the help from that whitepaper that I found, I know I can get my project complete -- in about a month.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question