Hello, I am not quite familiar with the method to add customized data type with code generator generated solutions in C#.
I have done this in C, though. This is how I did it. First, I write an idl file with this:
const long HELLO_MAX_STRING_SIZE = 256;
struct HelloWorld {
string<HELLO_MAX_STRING_SIZE> message;
};
And use code generator to generate a C project. Afterward, I add this under /* Modify the data to be written here */:
sprintf(instance->message, "DATA RECIEVED = (%d)", value); //The content is not revelent here
This way I can successfully read the "message" in my subscriber without problem.
My question is, I need to change this project into C#, so I generated a C# project using same idl file.
But I don't know what to add under /* Modify the data to be written here */ to achieve the result as C project. Apperantly not "sprintf(instance-> ...)". So what should I do?
Hi,
It seems that you may want to learn a little about programming in C#.
In C#, you just have to assign a string, e.g.,
instance.message = "DATA RECEIVED =" + value;
Hi isbn10391,
You may want to look at our c# source code example shipped with the product that is located in your workspace directory: \rti_workspace\6.0.1\examples\connext_dds\cs\hello_world\
specifically the function: public override void on_data_available(DDS.DataReader reader) {
After calling take(), that function prints the sample:
System.Int32 data_length = data_seq.length;
for (int i = 0; i < data_length; ++i) {
if (info_seq.get_at(i).valid_data) {
HelloWorldTypeSupport.print_data(data_seq.get_at(i));
}
}
Thank you for the reply, it works. I'm quite new to C and C# so I will try to learn more programming!