DDS program implementation and operation
[picture]
This paper records the whole process of OpenDDS environment construction, idl customization, code generation and code writing under Windows10 environment.
1, Environment construction
1. For details, please refer to the Development Notes: 1 Opendds environment construction - Windows 10 note
After compiling, two folders "OpenDDS-3.14" and "ACE_wrappers" are generated, which are the local runtime.
[picture]
2. Deploy two computers.
a) Copy the above two directory files,
b) Make sure both computers have the same development environment Set the same environment variable as The same path
Setting environment variables
1) System variable
ACE_ROOT F:\J18-ZaiJian\ACE_wrappers
MPC_ROOT F:\J18-ZaiJian\ACE_wrappers\MPC
TAO_ROOT %ACE_ROOT%\TAO
DDS_ROOT F:\J18-ZaiJian\OpenDDS-3.14
2)Path variable
Add in Path:
%ACE_ROOT%\lib
%ACE_ROOT%\bin
%DDS_ROOT%\lib
%DDS_ROOT%\bin
2, Generate relevant codes
0. New project directory name: ZJ-DDS-220301
Directory address: F: \ J18 Zaijian \ zj-dds-220301
[picture]
The following operations are all carried out under this project path, F: \ J18 Zaijian \ zj-dds-220301
1. Right click to create a new txt file named demo idl.
[picture]
[picture]
Write demo IDL contents are as follows:
module DemoIdlModule {
@topic
struct DemoTopic1 {
@key long id;
long counter;
string text;
};
};
[picture]
2. Right click to create a new txt file named demo MPC file,
[picture]
Compare it with demo IDL is placed in a folder, demo MPC file contents are as follows:
project(*idl): dcps {
TypeSupport_Files {
Demo.idl
}
custom_only = 1
}
project(*publisher) : dcpsexe_with_tcp {
exename = publisher
after += *idl
TypeSupport_Files {
Demo.idl
}
Source_Files {
Publisher.cpp
}
}
project(*subscriber) : dcpsexe_with_tcp {
exename = subscriber
after += *publisher
TypeSupport_Files {
Demo.idl
}
Source_Files {
Subscriber.cpp
DataReaderListener.cpp
}
}
[picture]
3. Right click to create a new txt file named publisher cpp,Subscriber.cpp and datareaderlistener h/DataReaderListener. cpp
[picture]
4. Use vs developer's command line tool to enter the command:
[picture]
1) Cut to demo IDL and demo Directory of MPC file;
cd F:\J18-ZaiJian\ZJ-DDS-220301
perl %ACE_ROOT%\MPC\mwc.pl -type vs2017
//Once I used this command with the same effect:
perl %ACE_ROOT%\MPC\mwc.pl -type vs2017 -include %DDS_ROOT%\MPC\config
[picture]
2) After the code is generated, the file is as follows:
[picture]
3) Double click ZJ_DDS_220301.sln, open with vs2017 as follows:
[picture]
5. Right click the solution and select "regenerate solution" to check whether it can be compiled.
[picture]
The files generated by vs solution and folder are as follows:
[picture]
6. Write a configuration file for the project separately_ Pub. Ini and config_Sub.ini
[picture]
It is used to configure the protocol and functions of OpenDDS, and config_Pub.ini and config_Sub.ini, as follows:
[common]
DCPSGlobalTransportConfig=$file
DCPSDefaultDiscovery=DEFAULT_RTPS
[transport/the_rtps_transport]
transport_type=rtps_udp
3, Write code
● Publisher: AAA from local file Txt read the data and publish it as DDS subject data.
● subscriber: after receiving the subject data, write the data to the local file BBB Txt.
- Publisher.cpp
#include <dds/DCPS/Service_Participant.h>
#include <dds/DCPS/Marked_Default_Qos.h>
#include <dds/DCPS/PublisherImpl.h>
#include <dds/DCPS/transport/tcp/TcpInst.h>
#include "dds/DCPS/StaticIncludes.h"
#include <ace/streams.h>
#include "DemoTypeSupportImpl.h"
using namespace DemoIdlModule;
int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) {
try {
//Initialize participants
argv[1] = "-DCPSConfigFile";
argv[2] = "config_Pub.ini";
argc = 3;
#if 1 //0. File / / read the parameters from the file, and then use them as the subject data transmitted by DDS.
FILE* fp;
//char c[] = "The counter is: 5";
char c[] = "2";
char buffer[50] = { 0 };
// char* buffer = { 0 };
// int bufsize = 0;
long _counter = 0; // For 6 Message of published data counter
char fname[80] = "F:\\J18-ZaiJian\\AAA.txt"; int charCount = 0;/** Number of characters to save the file**/ /* Open file for reading */ if ((fp = fopen(fname, "r")) == NULL) { printf("Open file failed!!\n"); exit(1); } while (fgetc(fp) != EOF) /** Count the number of characters**/ charCount++; /* Find the beginning of the file */ fseek(fp, 0, SEEK_SET); /* Read and display data */ // fread(buffer, strlen(buffer) + 1, 1, fp); fread(buffer, charCount+1, 1, fp); cout << buffer << endl; fclose(fp); /* String conversion long */ _counter = strtol(buffer, NULL, 10); cout << "Begin!!! _counter: " << _counter << endl;
#endif
// 1. Initialize participants
DDS::DomainParticipantFactory_var dpf =
TheParticipantFactoryWithArgs(argc, argv);
DDS::DomainParticipant_var participant = dpf->create_participant(111, PARTICIPANT_QOS_DEFAULT, DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(participant.in())) { cerr << "create_participant failed." << endl; return 1; } // 2. Registration data type //Here is Topic instead of Topics, which has different meanings and is reflected in the idl file. DemoTopic1TypeSupportImpl* servant = new DemoTopic1TypeSupportImpl();//This sentence corresponds to the Topic key name in the idl file according to the prefix in XXXXTypeSupportImpl, which is "DemoTopic1" here OpenDDS::DCPS::LocalObject_var safe_servant = servant; if (DDS::RETCODE_OK != servant->register_type(participant.in(), "")) { cerr << "register_type failed." << endl; exit(1); } // 3. Create a theme CORBA::String_var type_name = servant->get_type_name(); DDS::TopicQos topic_qos; participant->get_default_topic_qos(topic_qos); DDS::Topic_var topic = participant->create_topic("Movie Discussion List", type_name.in(), topic_qos, DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(topic.in())) { cerr << "create_topic failed." << endl; exit(1); } // 4. Create a publisher DDS::Publisher_var pub = participant->create_publisher(PUBLISHER_QOS_DEFAULT, DDS::PublisherListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(pub.in())) { cerr << "create_publisher failed." << endl; exit(1); } // 5. Create data writer DDS::DataWriterQos dw_qos; pub->get_default_datawriter_qos(dw_qos); DDS::DataWriter_var dw = pub->create_datawriter(topic.in(), dw_qos, DDS::DataWriterListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(dw.in())) { cerr << "create_datawriter failed." << endl; exit(1); } DemoTopic1DataWriter_var message_dw //This sentence is based on XXXXDataWriter_var, the prefix in XXXXDataWriter corresponds to the Topic key name in idl file, which is "DemoTopic1" here = DemoTopic1DataWriter::_narrow(dw.in()); // // Get default Publisher QoS from a DomainParticipant: DDS::PublisherQos pub_qos; DDS::ReturnCode_t ret; ret = participant->get_default_publisher_qos(pub_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default publisher QoS" << std::endl; } // Get default Subscriber QoS from a DomainParticipant: DDS::SubscriberQos sub_qos; ret = participant->get_default_subscriber_qos(sub_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default subscriber QoS" << std::endl; } // Get default Topic QoS from a DomainParticipant: DDS::TopicQos topic_qos2; ret = participant->get_default_topic_qos(topic_qos2); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default topic QoS" << std::endl; } // Get default DomainParticipant QoS from a DomainParticipantFactory: DDS::DomainParticipantQos dp_qos; ret = dpf->get_default_participant_qos(dp_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default participant QoS" << std::endl; } // Get default DataWriter QoS from a Publisher: DDS::DataWriterQos dw_qos2; ret = pub->get_default_datawriter_qos(dw_qos2); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default data writer QoS" << std::endl; } // 6. Publication of data DemoTopic1 message;//This sentence corresponds to the Topic key name in the idl file, which is "DemoTopic1" here message.id = 99; ::DDS::InstanceHandle_t handle = message_dw->register_instance(message); // message.counter = 0;
#if 1
message.counter = _counter;
cout << " RETT-message!!!: " << message.counter << endl;
#endif
char tMsg[50] = { 0 }; while (1) { message.counter++; memset(tMsg, 0, 50); sprintf(tMsg, "RETT-Msg Counter : %d", message.counter); message.text = ::TAO::String_Manager(tMsg); message_dw->write(message, handle); ACE_OS::sleep(1); cout << "RETT..." << endl; cout << "RETT-halo eyeryone!!!" << message.counter << endl; } // 7. Physical liquidation participant->delete_contained_entities(); dpf->delete_participant(participant); TheServiceParticipant->shutdown(); } catch (CORBA::Exception& e) { cerr << "PUB: Exception caught in main.cpp:" << endl << e << endl; exit(1); } return 0;
}
- Subscriber.cpp
/* 1. Initialize participants - Register data types and create topics
- Create subscriber
- Create listener
- Create data readers
- Clean up resources associated with OpenDDS*/
#include "DemoTypeSupportImpl.h"
#include <dds/DCPS/Service_Participant.h>
#include <dds/DCPS/Marked_Default_Qos.h>
#include <dds/DCPS/PublisherImpl.h>
#include <dds/DCPS/transport/tcp/TcpInst.h>
#include "dds/DCPS/StaticIncludes.h"
#include <ace/streams.h>
#include "DataReaderListener.h"
using namespace DemoIdlModule;
int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) {
try
{
//Initialize participants
argv[1] = "-DCPSConfigFile";
argv[2] = "config_Sub.ini";
argc = 3;
// 1. Initialize participants DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); DDS::DomainParticipant_var participant = dpf->create_participant(111, PARTICIPANT_QOS_DEFAULT, DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(participant.in())) { cerr << "create_participant failed." << endl; return 1; } // 2. Register data types and create topics DemoTopic1TypeSupportImpl* servant = new DemoTopic1TypeSupportImpl(); OpenDDS::DCPS::LocalObject_var safe_servant = servant; if (DDS::RETCODE_OK != servant->register_type(participant.in(), "")) { cerr << "register_type failed." << endl; exit(1); } CORBA::String_var type_name = servant->get_type_name(); DDS::TopicQos topic_qos; participant->get_default_topic_qos(topic_qos); DDS::Topic_var topic = participant->create_topic("Movie Discussion List", type_name.in(), topic_qos, DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(topic.in())) { cerr << "create_topic failed." << endl; exit(1); } // 3. Create subscribers DDS::Subscriber_var sub = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, DDS::SubscriberListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(sub.in())) { cerr << "Failed to create_subscriber." << endl; exit(1); } // 4. Create listener DDS::DataReaderListener_var listener(new DataReaderListener); DataReaderListener* listener_servant = dynamic_cast<DataReaderListener*>(listener.in()); if (CORBA::is_nil(listener.in())) { cerr << "listener is nil." << endl; exit(1); } if (!listener_servant) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: listener_servant is nil (dynamic_cast failed)!\n")), -1); } // 5. Create data readers DDS::DataReaderQos dr_qos; sub->get_default_datareader_qos(dr_qos); DDS::DataReader_var dr = sub->create_datareader(topic.in(), dr_qos, listener.in(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(dr.in())) { cerr << "create_datareader failed." << endl; exit(1); } // // Get default Publisher QoS from a DomainParticipant: DDS::PublisherQos pub_qos; DDS::ReturnCode_t ret; ret = participant->get_default_publisher_qos(pub_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default publisher QoS" << std::endl; } // Get default Subscriber QoS from a DomainParticipant: DDS::SubscriberQos sub_qos; ret = participant->get_default_subscriber_qos(sub_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default subscriber QoS" << std::endl; } // Get default Topic QoS from a DomainParticipant: DDS::TopicQos topic_qos2; ret = participant->get_default_topic_qos(topic_qos2); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default topic QoS" << std::endl; } // Get default DomainParticipant QoS from a DomainParticipantFactory: DDS::DomainParticipantQos dp_qos; ret = dpf->get_default_participant_qos(dp_qos); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default participant QoS" << std::endl; } // Get default DataReader QoS from a Subscriber: DDS::DataReaderQos dr_qos2; ret = sub->get_default_datareader_qos(dr_qos2); if (DDS::RETCODE_OK != ret) { std::cerr << "Could not get default data reader QoS" << std::endl; } while (1) { ACE_OS::sleep(1); } // 6. Clean up the resources associated with OpenDDS participant->delete_contained_entities(); dpf->delete_participant(participant); TheServiceParticipant->shutdown(); } catch (CORBA::Exception& e) { cerr << "PUB: Exception caught in main.cpp:" << endl << e << endl; exit(1); } return 0;
}
- DataReaderListener.h
//Implementation of data reader listener
#ifndef DATAREADER_LISTENER_IMPL
#define DATAREADER_LISTENER_IMPL
#include <dds/DdsDcpsSubscriptionExtC.h>
#include <dds/DCPS/LocalObject.h>
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
{
public:
DataReaderListener();
virtual ~DataReaderListener(void); virtual void on_requested_deadline_missed( DDS::DataReader_ptr reader, const DDS::RequestedDeadlineMissedStatus& status); virtual void on_requested_incompatible_qos( DDS::DataReader_ptr reader, const DDS::RequestedIncompatibleQosStatus& status); virtual void on_liveliness_changed( DDS::DataReader_ptr reader, const DDS::LivelinessChangedStatus& status); virtual void on_subscription_matched( DDS::DataReader_ptr reader, const DDS::SubscriptionMatchedStatus& status); virtual void on_sample_rejected( DDS::DataReader_ptr reader, const DDS::SampleRejectedStatus& status); virtual void on_data_available( DDS::DataReader_ptr reader); virtual void on_sample_lost( DDS::DataReader_ptr reader, const DDS::SampleLostStatus& status); virtual void on_subscription_disconnected( DDS::DataReader_ptr reader, const ::OpenDDS::DCPS::SubscriptionDisconnectedStatus& status); virtual void on_subscription_reconnected( DDS::DataReader_ptr reader, const ::OpenDDS::DCPS::SubscriptionReconnectedStatus& status); virtual void on_subscription_lost( DDS::DataReader_ptr reader, const ::OpenDDS::DCPS::SubscriptionLostStatus& status); virtual void on_budget_exceeded( DDS::DataReader_ptr reader, const ::OpenDDS::DCPS::BudgetExceededStatus& status); long num_reads() const { return num_reads_; }
private:
DDS::DataReader_var reader_; long num_reads_;
};
#endif /* DATAREADER_LISTENER_IMPL */
- DataReaderListener.cpp
// -- C++ --
//
#include "DataReaderListener.h"
#include "DemoTypeSupportC.h"
#include "DemoTypeSupportImpl.h"
#include <dds/DCPS/Service_Participant.h>
#include <ace/streams.h>
using namespace DemoIdlModule;
DataReaderListener::DataReaderListener() num_reads_(0){
}
DataReaderListener::~DataReaderListener()
{
}
void DataReaderListener::on_data_available(DDS::DataReader_ptr reader)
{
++num_reads_;
//0. file
FILE* fp;
//char c[] = "The counter is: 5";
char c[50] = "2";
char buffer[50] = { 0 };
long _counter = 0;
/*Open file for reading and writing*/
if (fp = fopen("F:\J18-ZaiJian\BBB.txt", "w+"))
cout << "RETT-Open file success— ";
try { DemoTopic1DataReader_var message_dr = DemoTopic1DataReader::_narrow(reader); if (CORBA::is_nil(message_dr.in())) { cerr << "read: _narrow failed." << endl; exit(1); } DemoTopic1 message; DDS::SampleInfo si; DDS::ReturnCode_t status = message_dr->take_next_sample(message, si); if (status == DDS::RETCODE_OK) { cout << "PP-Message: id = " << message.id << endl << " PP-DemoTopic1_Counter = " << message.counter << endl << " PP-DemoTopic1_Text = " << message.text << endl; cout << "SampleInfo.sample_rank = " << si.sample_rank << endl; _counter = message.counter; } else if (status == DDS::RETCODE_NO_DATA) { cerr << "ERROR: reader received DDS::RETCODE_NO_DATA!" << endl; } else { cerr << "ERROR: read Message: Error: " << status << endl; } } catch (CORBA::Exception& e) { cerr << "Exception caught in read:" << endl << e << endl; exit(1); } ltoa(_counter, c, 10); /* Write data to file */ fwrite(c, strlen(c) + 1, 1, fp); /* Find the beginning of the file */ fseek(fp, 0, SEEK_SET); /* Read and display data */ fread(buffer, strlen(c) + 1, 1, fp); cout << buffer << endl; fclose(fp);
}
void DataReaderListener::on_requested_deadline_missed(
DDS::DataReader_ptr,
const DDS::RequestedDeadlineMissedStatus&)
{
cerr << "DataReaderListener::on_requested_deadline_missed" << endl;
}
void DataReaderListener::on_requested_incompatible_qos(
DDS::DataReader_ptr,
const DDS::RequestedIncompatibleQosStatus&)
{
cerr << "DataReaderListener::on_requested_incompatible_qos" << endl;
}
void DataReaderListener::on_liveliness_changed(
DDS::DataReader_ptr,
const DDS::LivelinessChangedStatus&)
{
cerr << "DataReaderListener::on_liveliness_changed" << endl;
}
void DataReaderListener::on_subscription_matched(
DDS::DataReader_ptr,
const DDS::SubscriptionMatchedStatus&)
{
cerr << "DataReaderListener::on_subscription_matched" << endl;
}
void DataReaderListener::on_sample_rejected(
DDS::DataReader_ptr,
const DDS::SampleRejectedStatus&)
{
cerr << "DataReaderListener::on_sample_rejected" << endl;
}
void DataReaderListener::on_sample_lost(
DDS::DataReader_ptr,
const DDS::SampleLostStatus&)
{
cerr << "DataReaderListener::on_sample_lost" << endl;
}
void DataReaderListener::on_subscription_disconnected(
DDS::DataReader_ptr,
const ::OpenDDS::DCPS::SubscriptionDisconnectedStatus&)
{
cerr << "DataReaderListener::on_subscription_disconnected" << endl;
}
void DataReaderListener::on_subscription_reconnected(
DDS::DataReader_ptr,
const ::OpenDDS::DCPS::SubscriptionReconnectedStatus&)
{
cerr << "DataReaderListener::on_subscription_reconnected" << endl;
}
void DataReaderListener::on_subscription_lost(
DDS::DataReader_ptr,
const ::OpenDDS::DCPS::SubscriptionLostStatus&)
{
cerr << "DataReaderListener::on_subscription_lost" << endl;
}
void DataReaderListener::on_budget_exceeded(
DDS::DataReader_ptr,
const ::OpenDDS::DCPS::BudgetExceededStatus&)
{
cerr << "DataReaderListener::on_budget_exceeded" << endl;
}
4, Compile
0) click "rebuild solution" to recompile.
[picture]
1) After compilation, the generated exe file is as follows:
[picture]
2) Create a new file under the path with the name AAA Txt, content: 123
[picture]
3) Copy the compiled program directory to another computer that has built the same development environment before.
[picture]
5, Operation (1. Peer discovery mode; 2. Centralized discovery mode)
0. Preparation before operation
The operation is as follows: connect two computers with a network cable.
1) DUKTO is installed on computers of both parties Then the notebook computer copies all the compiled project directory F:\J18-ZaiJian\ZJ-DDS-220301 to the desktop computer
The path addresses are F:\J18-ZaiJian\ZJ-DDS-220301
2) Set the IP address and make sure all firewalls are turned off. You must first ensure that there is no problem with network communication.
1. Run in the way of peer discovery:
config_Pub.ini and config_ The contents of the sub.ini configuration file are basically the same:
[common]
DCPSDefaultDiscovery=DEFAULT_RTPS
DCPSGlobalTransportConfig=$file
[transport/the_rtps_transport]
transport_type=rtps_udp
1). As shown in the figure: run a Publisher or Subscriber instance on two computers in no order,
a) One computer, execute the following commands:
publisher -DCPSConfigFile config_PubEq.ini
b) Another computer, execute the following command:
subscriber -DCPSConfigFile config_SubEq.ini
c) You will see the running results as shown in the figure below. The subscriber will generate a file under F: \ J18 Zaijian: BBB txt
[picture]
[picture]
2). Of course, peer discovery only needs to be executed/ Publisher and/ Subscriber,
The default is to find config_Pub.ini and config_Sub.ini
[picture]
[picture]
- In addition, there is another way to run in the way of centralized discovery: (please check the following notes)
config_Pub.ini and config_ The contents of the sub.ini configuration file are basically the same:
[common]
DCPSDebugLevel=5
DCPSInfoRepo=corbaloc::192.168.2.112:65123/DCPSInfoRepo
DCPSGlobalTransportConfig=config1
[config/config1]
transports=tcp1
[transport/tcp1]
transport_type=tcp
[picture]
6, Specific centralized discovery operation (relatively cumbersome)
The operation is as follows: connect two computers with a network cable.
1) DUKTO is installed on computers of both parties Then the notebook computer copies all the compiled project directory F:\J18-ZaiJian\ZJ-DDS-220301 to the desktop computer
The path addresses are F:\J18-ZaiJian\ZJ-DDS-220301
2) Set the IP address and make sure all firewalls are turned off. You must first ensure that there is no problem with network communication.
A-side subscription - the operation of desktop computer is as follows: (ensure that the development environment \ environment variables and paths are set)
-
IP bit of desktop computer: 192.168.2.112
ipconfig / / check the local IP address and make sure it is set to 192.168.2.112, -
Open vs2017 developer command prompt: see if you can ping the laptop
ping 192.168.2.110
Pinging 192.168.2.110 with 32 bytes of data:
Reply from 192.168.2.110: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.110: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.110: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.110: byte = 32 time < 1ms TTL = 64 -
After the two computers ping each other,
1) Open the vs2017 developer command line prompt, first setenv cmd
%DDS_ROOT%\setenv.cmd
Then start the DCPS service
%DDS_ROOT%/bin/DCPSInfoRepo -ORBListenEndpoints iiop://192.168.2.112:65123
2) Then open the vs2017 developer command line prompt, and first setenv cmd
%DDS_ROOT%\setenv.cmd
Then execute: subscription
subscriber -DCPSInfoRepo corbaloc::192.168.2.112:65123/DCPSInfoRepo
B-side release - the operation of the laptop is as follows: (ensure that the development environment \ environment variables and paths are set)
-
IP bit of laptop: 192.168.2.110
ipconfig / / check the local IP address of the laptop and make sure it is set to 192.168.2.110 -
Open vs2017 developer's command prompt: see if you can ping the desktop computer ip
ping 192.168.2.112
Pinging 192.168.2.112 with 32 bytes of data:
Reply from 192.168.2.112: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.112: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.112: byte = 32 time < 1ms TTL = 64
Reply from 192.168.2.112: byte = 32 time < 1ms TTL = 64 -
After the two computers can ping each other successfully, open the command prompt of vs2017 developer,
1) Setenv cmd
%DDS_ROOT%\setenv.cmd
2) Then execute: publish
publisher -DCPSInfoRepo corbaloc::192.168.2.112:65123/DCPSInfoRepo
[summary] run OPenDDS routine (centralized discovery method) (F:\J18-ZaiJian\ZJ-DDS-220301)
The two computers operate as follows to run the test (the developer's command line prompt: the command line provided by vs2017 and vs2019)
☆☆. All firewalls on both sides must be closed, and confirm that host A and host B can ping ☆☆
Host A: (desktop IP:192.168.2.112) [remember to setenv.cmd in advance]
%DDS_ROOT%/bin/DCPSInfoRepo -ORBListenEndpoints iiop://192.168.2.112:65123
subscriber -DCPSInfoRepo corbaloc::192.168.2.112:65123/DCPSInfoRepo
host B:(Notebook computer IP:192.168.2.110)[Remember to advance setenv.cmd]
publisher -DCPSInfoRepo corbaloc::192.168.2.112:65123/DCPSInfoRepo