?
Solved

Interprocess communication

Posted on 2003-03-23
6
Medium Priority
?
677 Views
Last Modified: 2012-06-27
Dear,

do you have a good sample program that illustrates the communication via pipes between two C++ programs?
Is it possible to establish communication between a matlab.exe and a VisualC++.exe via pipelines?
Do you have some good information about this topic?

Thanks a lot,
kind regards,
Geert Craessaerts
0
Comment
Question by:Geert2003
  • 3
5 Comments
 
LVL 5

Expert Comment

by:Kocil
ID: 8190905
> Is it possible to establish communication between a matlab.exe and a VisualC++.exe via pipelines?

IMHO, pipes doesn't work between VC++ and Matlab because pipes is 'unknown terminology' on Windows.

I'm confused about what do you want to do.
If you want to communicate between VisualC++.exe and Matlab.exe (both are ready made executable) then the only posible way is by using DDE (Dynamic data exchange). Matlab.exe is able to act as DDE server or DDE client (try to type 'help dde' from Matlab command line). I can easily exchange data (matrix/table) between Matlab and Excel with this facility. However, I have no idea why do you want Matlab.exe to communicate with visualC++.

If, on the other hand, you want to communicate between Matlab.exe and another.exe made by Visual C++, then it  make sense. The complete Matlab package contains toolkit called Matlab-compiler. That toll-kit allows you to :
1. Make a C++ program (exe) that use Matlab library, so you can have powerfull matrix routine in your C++ program.
2. Make a C++ library (dll) that can be called from Matlab M-script. You may want to do this to make a fast routine, compare to usual M-file.

So please tell us which one is your intention ? If you say what is your application, we may give you better suggestion.

0
 

Author Comment

by:Geert2003
ID: 8191339
Dear,

I've written a control interface program in VisualC++ that has to communicate with Matlab because the control algorithms are written in Matlab. Every 200ms a VisualC++ program retrieves data from the machine and has to send this information to Matlab. Matlab performs the control algorithm and sends his output back to Visual C++. In a next step Visual C gives the information to the machine.

I've tried to establish a communication by using the matlab engine. But if I want to run the program on another computer, this computer will always need Matlab.
So I want to establish a communication between two executables(one from the Matlab program and one from the Visual C++ program) I've seen that this is possible between two C++ programs so I would think that it should also be possible between Matlab and VisualC++?
I thought that I should compile the matlab code in C++ code at first instance. Then I think I should write the code for establishing pipelines in both C++ code-programs and in a last step I should compile these two C++-code programs. Am I right?

A second question; Is it possible to exchange commandos between two applications via pipes?

Thanks a lot,
kind regards,
Geert Craessaerts
0
 
LVL 5

Accepted Solution

by:
Kocil earned 500 total points
ID: 8193855
That's a good system.

Yes, you may achieve that by using DDE (not pipes).
The system may work like this:

1. On Matlab, you have to make M-File that use matlab dde to act as a DDE server. See your Matlab documentation for DDE.

2. Your C++ program has to act as DDE client.

DDE is very convenient:
* You may send any data (commands, string, integer, float, image, etc) between DDE client and server.
* DDE can send the data across the network, so your Matlab and C++ program may run on different computer.

I did this long time ago, I'll see if I can find that old codes.
0
 
LVL 5

Expert Comment

by:Kocil
ID: 8207861
Hi, bad news.

My old code, it was made for Matlab 4.0, does not work anymore. I just found out that Matlab 6 has changed everything:
1. dde is now in winfun package. Try help winfun
2. Matlab can not act as dde server
 
So my previous suggestion must be reversed.
Your C++ program has to act as DDE server, and Matlab as a client with ddeack.

My friend said, she is the Matlab woman here, you have two more choices:
1. Matlab 6 can do good user interface now. Why not using it instead of using C++ ?
2. Use Realtime Toolbox to link VC++ and Matlab.

Cheers

0
 
LVL 11

Expert Comment

by:bcladd
ID: 9544046
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to Kocil

Please leave any comments here within the next seven days. Experts: Silence
means you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question