HI Curtis thanks for the response,
Well I tore my hair out for a couple of days. But I could never make any
sense of the string stored in the structure, nor could I find a string
terminator in it. I dont know exactly why as i am not very experieced in c
strings.
I ended up putting the property to a local string, then writing it into a
normal char array in the structure adding a teminator after the last
printable.
Certianly not elegant but works for now to load the stucture. A programer
would write it differently to me!
tempnode = node->getChild("registration");
pt = net->registration[i]; // pointer to array
in struct
pt[0] = '\0'; // put an end
of string for default
if ( tempnode != NULL ) {
temp = tempnode->getStringValue();
n=0;
x=0x31;
while ( (x > 0x19)& (x<0x7f) & (n < SL_MAX_REGISTRATION)){
x=temp[n]; // pointer
to prop string to send
pt[n] = x; // wite to
the struct string
n++;
}
pt[n] = '\0'; //0x0A;
}
>From the structure Its written into the other machine with
node->setStringValue("registration", net->registration[i]);
The file is a clone of the native controls io, purpose being to forward the
clouds, AI and multiplayer info to the slave pcs for display.
Now I have the Ai aircraft data across to the slaves, my next question is
where does FG pick up the AI items attached for display by the AIbase? Ie I
need to fool the slaves to display the imported aircraft from the data,
preferably with out diabling the Ai base as It is still used displaying the
multiplayer on the slaves from another protocol and port.
I know i could do it with a cloned Ai update funtion, but maybe i can do it
at a lower level?
BTW ref our mail of last weekend, I have been putting a drawing together of
how I have interconnected the sim aircraft hardware by can bus to FG I
would have mailed it by now if I had not been banging my head on the walls
with this string issue. I will revert with it shortly
Regards Harry
On Fri, Apr 17, 2009 at 2:30 AM, Curtis Olson <curtol...@gmail.com> wrote:
>
>
> On Thu, Apr 16, 2009 at 1:07 AM, Harry Campigli wrote:
>
>>
>>
>>
>> How fo write an FG string property from an indexed string in a structure?
>>
>> Possibly someone can help please , I have tried to find an example with no
>> luck, I am sure i had it working yesterday but now every way i try i end up
>> with it wrong at compile, a seg fault or a property node with an empty
>> string. The basic setup works fine with doubles ect, here i only show the
>> string code.
>>
>>
>> Its wrong, but this is what i want to do, where : index i is declared as
>> an int, path is a node, and path[i] is a string indexed in the structure
>> called buf- node->setStringValue("path",buf->path[i]);
>> )
>>
>> 1-The stucture called buf with indexed stings in it from the h file
>> >
>> enum {
>> FG_MAX_AIRCRAFT = 25
>> };
>> uint32_t num_aircraft;
>> string callsign[FG_MAX_AIRCRAFT];
>> string path[FG_MAX_AIRCRAFT];
>> >
>>
>>
>> 2- I write to the stucture with
>>
>> >
>> tempnode = node->getChild("path");
>> if ( tempnode != NULL ) {
>> net->path[i] = tempnode->getStringValue();
>> }
>>
>> >
>
>
> At a glance, this looks like it should work. I believe getStringValue()
> returns a const char * type and you should be able to assign this to a
> "string" variable like you show in your example code.
>
> If I was going to dig into this, I might start inserting some printf()'s to
> dump out the value of tempnode->getStringValue() to make sure that is sane.
> Make sure [i] is a sane index value, etc. Off by one errors are pretty easy
> to accidentally introduce. Hehe, I still have trouble with those off by an
> order of magnitude errors ... :-)
>
> Without seeing your surrounding code, I think I would be most interested in
> first checking the value of "i". That should remain between 0 and 24 (i=25
> would be an array overrun because you'd be referencing the 26th element of
> the array.)
>
> Best regards,
>
> Curt.
> --
> Curtis Olson:
> http://baron.flightgear.org/~curt/<http://baron.flightgear.org/%7Ecurt/>
>
>
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today.
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Flightgear-devel mailing list
> Flightgear-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/flightgear-devel
>
>
--
Regards Harry
19b Jln Danau Poso
Sanur, Bali
80228
H +62 361 285629
M +62 812 7016328
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel