sending <STX><ETX > charaters to RS232 port

J

jyotish.bora

Hi ,
i m trying to send a message packet to a RS232 port. I have created the
handle and set the parameters. Now the general format of the packet is
<STX>command<ETX><LRC>

I have also written the code to calculate <LRC>.

now i dont understand how to make the packet string. should i call
writefile with STX, command , ETX and LRC characters differently or in
a single string. can anyone give me the exact string for a command say
z42. should it be something like "\2z42\3\lrc". Plss help, thanks in
advance
 
V

Victor Bazarov

i m trying to send a message packet to a RS232 port.

Which is simply impossible using only the means of the standard C++
language. Neither the language proper nor the library contains any
mechanisms to control hardware. You need to post your query to the
newsgroup that deals with your OS, most likely.
> I have created the
handle and set the parameters. Now the general format of the packet is
<STX>command<ETX><LRC>

I have also written the code to calculate <LRC>.

now i dont understand how to make the packet string. should i call
writefile with STX, command , ETX and LRC characters differently or in
a single string. can anyone give me the exact string for a command say
z42. should it be something like "\2z42\3\lrc". Plss help, thanks in
advance

I am not sure what <STX> is (that's not defined in the language either),
but if it's a symbol with the value 1, then you may be better off using
three-digit octal notation: "\002z42\003". If this doesn't help, post
again to the forum that covers your OS. Whatever you think "\lrc" does,
we can't really help you. There is no such escape sequence in C++. The
accepted ones are \a \b \f \n \r \t \v \' \" \? \\. If your compiler
accepts it, there must be an extension to the language that allow that,
and you need to ask about it in the newsgroup that deals with your
compiler.

There is no such thing in C++ as "command say z42".

Read the FAQ, there are some suggestions where to post if your question
is OT here (and it is).

V
 
I

Ian Collins

Hi ,
i m trying to send a message packet to a RS232 port. I have created the
handle and set the parameters. Now the general format of the packet is
<STX>command<ETX><LRC>

I have also written the code to calculate <LRC>.

now i dont understand how to make the packet string. should i call
writefile with STX, command , ETX and LRC characters differently or in
a single string. can anyone give me the exact string for a command say
z42. should it be something like "\2z42\3\lrc". Plss help, thanks in
advance
Please don't use pseudo words like 'plss'.

Are you using a C style string, or a C++ string?

If the former, just assign the elements ( string[0] = STX; ...).

There are many ways of building a buffer, which have you considered?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top