sending <STX><ETX > charaters to RS232 port

Discussion in 'C++' started by jyotish.bora@gmail.com, Jan 19, 2006.

  1. Guest

    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
    , Jan 19, 2006
    #1
    1. Advertising

  2. wrote:
    > 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
    Victor Bazarov, Jan 19, 2006
    #2
    1. Advertising

  3. Ian Collins Guest

    wrote:
    > 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?

    --
    Ian Collins.
    Ian Collins, Jan 19, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fpgawizz
    Replies:
    5
    Views:
    4,240
    dutchgoldtony
    Mar 14, 2005
  2. Zsolt Koppany
    Replies:
    0
    Views:
    503
    Zsolt Koppany
    Nov 27, 2003
  3. PaullyB

    JMS over a serial port (rs232)

    PaullyB, Feb 22, 2005, in forum: Java
    Replies:
    0
    Views:
    465
    PaullyB
    Feb 22, 2005
  4. Laura Lucas
    Replies:
    4
    Views:
    972
    Alf P. Steinbach
    Oct 8, 2004
  5. Replies:
    8
    Views:
    454
    Peter Shaggy Haywood
    Oct 24, 2006
Loading...

Share This Page