cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Using the C SDK to read String Properties from thingworx

SOLVED
Regular Member

Using the C SDK to read String Properties from thingworx

Hi everyone,

 

I am trying to use the C SDK to get the thingname from the Generic thing property. The problem I am having is that my C SDK application connects using an identifier so I can bind it to different things on thingworx so that I do not have to re-build my program. I want to use the Thingname that my application has binded to in my code.

 

When I use the TW_GET_STRING_PROPERTY like this it returns null.

printf("The Name of the thing is%s\n", TW_GET_STRING_PROPERTY(thingName,"name"));

csdkerr.PNG

 

csdkerr2.PNG

 

Can anyone please give advice on how I can get the thingName that my application is bound to thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Using the C SDK to read String Properties from thingworx

Maybe try the following API instead :

twPrimitive* p_prim;
twApi_ReadProperty(TW_THING, thingName, "name", &p_prim, DEFAULT_MESSAGE_TIMEOUT, FALSE);
TW_LOG(TW_WARN, "************* %s name %s", thingName, p_prim->val.bytes.data);

It is working on my side when using an ID for thingname.

Note that you can use this API after a successful twApi_Connect().

View solution in original post

5 REPLIES 5

Re: Using the C SDK to read String Properties from thingworx

Hi,

 

Have you tried to use TW_GET_PROPERTY(thingName, "name").string  ?

 

Please let me know what value you get with TW_GET_PROPERTY.

 

Thanks,

Raluca Edu

Highlighted

Re: Using the C SDK to read String Properties from thingworx

Hi @raluca_edu ,

 

When I try using TW_GET_PROPERTY(thingName, "name").string my application does not compile and returns this error.

 

error: 'union <anonymous>' has no member named 'string'
printf("The Name of the thing is%s\n",TW_GET_PROPERTY(thingName, "name").string);

Re: Using the C SDK to read String Properties from thingworx

Try char, not string

Re: Using the C SDK to read String Properties from thingworx

Maybe try the following API instead :

twPrimitive* p_prim;
twApi_ReadProperty(TW_THING, thingName, "name", &p_prim, DEFAULT_MESSAGE_TIMEOUT, FALSE);
TW_LOG(TW_WARN, "************* %s name %s", thingName, p_prim->val.bytes.data);

It is working on my side when using an ID for thingname.

Note that you can use this API after a successful twApi_Connect().

View solution in original post

Re: Using the C SDK to read String Properties from thingworx

Hi @smainente,

 

Thank you for your assistance this worked.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________