HELP C++ and Corba?

Discussion in 'C++' started by Bob Smith, Aug 27, 2003.

  1. Bob Smith

    Bob Smith Guest

    Hello all,
    I am having a very difficult time getting something to work. This
    involves CORBA, hopefully someone here will be able to answer it, and if not
    maybe someone can point me in the right direction to where I can get it
    answered. Using ACE/TAO.... Redhat 7.3 using Kdevelop.
    OK really I just want to copy a CORBA octet sequence to and array where I
    can get a pointer to point to it. The first 0-3 octets in the sequence are
    stored in the first int and so forth... so the array of ints would be one
    quarter of the size of the octet sequence.

    This is what I have and doesn't work:

    //corba object already declared.

    CORBA::Octet* ptempBuffer;
    ptempBuffer =payLoad_var->getBuffer();
    char* working_data =(char*)ptempBuffer;

    byte_index =0;
    for(analog_index = 0; analog_index <16; analog_index++)
    {

    working_data[byteIndex]=char(analog_data[analog_index]>>8);
    working_data[byteIndex+1]=char(analog_data[analog_index]& 0xFF);
    working_data[byteIndex+2]=char(0x00);
    working_data[byteIndex+3]=char(0x00);
    byte_index +=4;
    }

    This is what i have and it seems to crash!
    Can someone be kind and help a poor soul?
    thanks
    Bob Smith, Aug 27, 2003
    #1
    1. Advertising

  2. "Bob Smith" <> wrote in message news:<q5T2b.11004$>...

    > I am having a very difficult time getting something to work. This
    > involves CORBA, hopefully someone here will be able to answer it, and if not
    > maybe someone can point me in the right direction to where I can get it
    > answered. Using ACE/TAO.... Redhat 7.3 using Kdevelop.


    This is an ISO C++ newsgroup, which means (a) this is (mostly)
    off-topic, and (b) it's a crapshoot whether anyone here speaks CORBA.
    In the future, you should probably post to comp.object.corba, or else
    comp.soft-sys.ace (yes, they talk TAO) or one of the mailing lists for
    which it acts as a gateway:

    http://www.cs.wustl.edu/~schmidt/TAO-mail.html

    > This is what i have and it seems to crash!


    Looking at this code, I can only guess that the crash is due to
    accessing memory that isn't yours to access. analog_data ought to have
    at least 16 elements, and working_data ought to have 64 (4 bytes for
    each of analog_data's 16 elements). That's about all I can tell you
    from looking at this code. Except...

    <off-topic>
    CORBA sequences like payLoad_var (that's what it is, no?) seem to act
    a lot like C++ std::vector objects. As such, you have to resize them
    before you start using them. Also, they have an overloaded operator[],
    so you don't need to mess with pointers.

    (For future reference, even when using a pointer, you should be able
    to use CORBA::Octet without casting. That is, working_data should have
    been a pointer to CORBA::Octet and not a pointer to char, since that's
    what getBuffer() returns. And if you must cast, prefer C++-style casts
    [like static_cast] to C-style ones whenever possible [which it almost
    always is].)

    Putting everything together, something like this ought to do it:

    // allocate 64 octets (must be done before getBuffer!)
    payLoad_var->length(64);

    byte_index = 0;

    for(analog_index = 0; analog_index <16; analog_index++)
    {
    typedef CORBA::Octet octet;
    payLoad_var[byteIndex]=octet(analog_data[analog_index]>>8);
    payLoad_var[byteIndex+1]=octet(analog_data[analog_index]& 0xFF);
    payLoad_var[byteIndex+2]=octet(0x00);
    payLoad_var[byteIndex+3]=octet(0x00);
    byte_index +=4;
    }
    </off-topic>

    If that doesn't do the trick, a CORBA or ACE/TAO forum would be much
    better equipped to help you. Try there next.

    - Shane
    Shane Beasley, Aug 27, 2003
    #2
    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. Donnie Fuqua

    perl and corba?

    Donnie Fuqua, Jan 17, 2005, in forum: Perl
    Replies:
    0
    Views:
    515
    Donnie Fuqua
    Jan 17, 2005
  2. Mr. x

    Corba help for Java.

    Mr. x, Oct 8, 2003, in forum: Java
    Replies:
    1
    Views:
    354
    Chris Smith
    Oct 8, 2003
  3. Julien Klein

    Dynamic Cast (one more) and CORBA

    Julien Klein, May 4, 2004, in forum: Java
    Replies:
    1
    Views:
    1,559
    Mike Schilling
    May 6, 2004
  4. Tomek
    Replies:
    1
    Views:
    983
    Jack Klein
    Jun 1, 2006
  5. Andreas Leitgeb

    Corba SSLIOP help needed.

    Andreas Leitgeb, Apr 23, 2012, in forum: Java
    Replies:
    1
    Views:
    698
    xxxadult23
    Jul 3, 2012
Loading...

Share This Page