"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]>>

;
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