Problem with Simple example

3 posts / 0 new
Last post
Offline
Last seen: 4 years 6 months ago
Joined: 06/25/2019
Posts: 3
Problem with Simple example

Hi all - 

Just installed the SDK and am running a few examples and writing some code. 

I've found that the 'simple' example runs into a problem at about the 296th iteration of sending. It does not matter if the receiver is running - The app just hangs. Can anyone run the following and see what the problem is? 

Usage: >> Simple.exe pub

Thanks,

Dan

// (c) 2017 Copyright, Real-Time Innovations, All rights reserved.
//
// RTI grants Licensee a license to use, modify, compile, and create
// derivative works of the Software.  Licensee has the right to distribute
// object form only for use with RTI products. The Software is provided
// "as is", with no warranty of any type, including any warranty for fitness
// for any purpose. RTI is under no obligation to maintain or support the
// Software.  RTI shall not be liable for any incidental or consequential
// damages arising out of the use or inability to use the software.
namespace Simple
{
    using System;
    using System.Threading;
    using RTI.Connext.Connector;

    class Program
    {
        public static void Main(string[] args)
        {
            if (args.Length == 0 || (args[0] != "pub" && args[0] != "sub")) {
                Console.WriteLine("USAGE: Simple.exe pub|sub [count=0]");
                return;
            }

            string configPath = "ShapeExample.xml";
            string configName = "MyParticipantLibrary::Zero";
            bool publishMode = args[0] == "pub";
            int count = args.Length > 1 ? Int32.Parse(args[1]) : 0;

            Console.WriteLine("Initializating RTI Connector");
            using (var connector = new Connector(configName, configPath)) {
                if (publishMode)
                    Publish(connector, count);
                else
                    Subscribe(connector, count);

                Console.WriteLine("Finalizing RTI Connector");
            }
        }

        static void Publish(Connector connector, int count)
        {
            string outputName = "MyPublisher::MySquareWriter";
            Output output = connector.GetOutput(outputName);

            Instance instance = output.Instance;
            for (int i = 0; i < count || count == 0; i++) {
                Console.WriteLine("Writing sample {0}", i);

                // Optionally, clear the instance field from previous iterations
                output.ClearValues();
                instance.SetValue("x", i);
                instance.SetValue("y", i * 2);
                instance.SetValue("shapesize", 30);
                instance.SetValue("color", "BLUE");

                output.Write();
                Thread.Sleep(100);
            }
        }

        static void Subscribe(Connector connector, int count)
        {
            string inputName = "MySubscriber::MySquareReader";
            Input input = connector.GetInput(inputName);

            for (int i = 0; i < count || count == 0; i++) {
                // Poll for samples every second
                Console.WriteLine("Waiting 1 second...");
                Thread.Sleep(1000);

                // Take samples. Accesible from Input.Samples
                input.Take();
                Console.WriteLine("Received {0} samples", input.Samples.Count);
                foreach (Sample sample in input.Samples) {
                    if (sample.Info.IsValid) {
                        Console.WriteLine(
                            "Received [x={0}, y={1}, size={2}, color={3}]",
                            sample.Data.GetInt32Value("x"),
                            sample.Data.GetInt32Value("y"),
                            sample.Data.GetInt32Value("shapesize"),
                            sample.Data.GetStringValue("color"));
                    } else {
                        Console.WriteLine("Received metadata");
                    }
                }
            }
        }
    }
}
 

// (c) 2017 Copyright, Real-Time Innovations, All rights reserved.//// RTI grants Licensee a license to use, modify, compile, and create// derivative works of the Software.  Licensee has the right to distribute// object form only for use with RTI products. The Software is provided// "as is", with no warranty of any type, including any warranty for fitness// for any purpose. RTI is under no obligation to maintain or support the// Software.  RTI shall not be liable for any incidental or consequential// damages arising out of the use or inability to use the software.namespace Simple{    using System;    using System.Threading;    using RTI.Connext.Connector;
    class Program    {        public static void Main(string[] args)        {            if (args.Length == 0 || (args[0] != "pub" && args[0] != "sub")) {                Console.WriteLine("USAGE: Simple.exe pub|sub [count=0]");                return;            }
            string configPath = "ShapeExample.xml";            string configName = "MyParticipantLibrary::Zero";            bool publishMode = args[0] == "pub";            int count = args.Length > 1 ? Int32.Parse(args[1]) : 0;
            Console.WriteLine("Initializating RTI Connector");            using (var connector = new Connector(configName, configPath)) {                if (publishMode)                    Publish(connector, count);                else                    Subscribe(connector, count);
                Console.WriteLine("Finalizing RTI Connector");            }        }
        static void Publish(Connector connector, int count)        {            string outputName = "MyPublisher::MySquareWriter";            Output output = connector.GetOutput(outputName);
            Instance instance = output.Instance;            for (int i = 0; i < count || count == 0; i++) {                Console.WriteLine("Writing sample {0}", i);
                // Optionally, clear the instance field from previous iterations                output.ClearValues();                instance.SetValue("x", i);                instance.SetValue("y", i * 2);                instance.SetValue("shapesize", 30);                instance.SetValue("color", "BLUE");
                output.Write();                Thread.Sleep(100);            }        }
        static void Subscribe(Connector connector, int count)        {            string inputName = "MySubscriber::MySquareReader";            Input input = connector.GetInput(inputName);
            for (int i = 0; i < count || count == 0; i++) {                // Poll for samples every second                Console.WriteLine("Waiting 1 second...");                Thread.Sleep(1000);
                // Take samples. Accesible from Input.Samples                input.Take();                Console.WriteLine("Received {0} samples", input.Samples.Count);                foreach (Sample sample in input.Samples) {                    if (sample.Info.IsValid) {                        Console.WriteLine(                            "Received [x={0}, y={1}, size={2}, color={3}]",                            sample.Data.GetInt32Value("x"),                            sample.Data.GetInt32Value("y"),                            sample.Data.GetInt32Value("shapesize"),                            sample.Data.GetStringValue("color"));                    } else {                        Console.WriteLine("Received metadata");                    }                }            }        }    }}

 
Offline
Last seen: 4 years 6 months ago
Joined: 06/25/2019
Posts: 3

Looks like the QOS settings are the culprit. 

 

I commented out the Qos_Library and it works fine:

 <!-- Qos Library 
 <qos_library name="QosLibrary">
 <qos_profile name="DefaultProfile"
 base_name="BuiltinQosLibExp::Generic.StrictReliable"
 is_default_qos="true">
 <participant_qos>
 <transport_builtin>
 <mask>UDPv4 | SHMEM</mask>
 </transport_builtin>
 </participant_qos>
 </qos_profile>
 </qos_library>
-->
Offline
Last seen: 4 years 3 months ago
Joined: 04/13/2019
Posts: 9

I saw the same issue with the Python Connector simple\writer.py example. Same slowing after the 296th iteration.

Deleting the <qos_library....>   worked smoothly past 296 iterations, but I have to be able to specify the   <publisher_qos>    <partition>

I also found that in :

  <qos_profile name="TridentControl_Profile base_name="BuiltinQosLibExp::Generic.StrictReliable" is_default_qos="true">

changing is_default_qos="true" to "false" allowed the loop to proceed past 296, but the Subscriber didn't see the data. Partition issue?