LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Send and receive an XML Stream through the network

Hi,

I'm building a measurement application using labWindows/CVI 7.1
for the validation of diodes characteristics in a diode factory's
production. As I need to use the collected measurement data in
differents formats, the choice of the XML came by itself.

My problem is that I can't find any documentation nor resources
on how can I build such a library. What I have in mind is to use the
CVI/Socket library to communicate with the server, and then generate the
XML tree while parsing the input TCP stream. But my problem is that
I wasn't able to find a function that does such a job.

Do you have any suggestions on how shall I do the job (if I'm
getting wrong in the way I'm doing it), or how can I convert the input
stream to a CVIXMLDocument ?

Finally, could you give some simple example code (without fancy
intefaces, printf()s at most) to illustrate how to get all this done ?

Thanks for assisting me,

--
Bernard Pratz
IT developer
Engineering service
Chelton Telecom & Microwave
--
Bernard Pratz
IT Developer
Engineering service
Chelton Telecom & Microwave
0 Kudos
Message 1 of 7
(3,863 Views)
Hi,
 
I dont know if it can help you but you can have a look to this Knowlegde Base : http://digital.ni.com/public.nsf/websearch/EA451498B828894886256F67007AE6B9?OpenDocument
 
Let me know if you need more explanations.
 
Regards,
 

Message Edited by Isabelle on 07-19-2005 04:11 PM

Isabelle
Ingénieur d'applications
National Instruments France
0 Kudos
Message 2 of 7
(3,854 Views)
Hi,

as I'm using libxml2 on the other side of the network communication,
would it be possible to do the same with the libxml2 DLL (that I found
on <>) ? (i.e. generate a fp and
integrate it).

Also, I'm not sure what's the correct design pattern I should use to
make the socket connection. What I thought would be better/easier to do
is to use a XML tree for the commands that will embed the XML trees of
data. Furthermore, as the client is sending data to a networked database,
any transmission is always initiated by the client, then as far as I've
read from ni.com's docs, shall I do :

ConnectToTCPServer(handle,port,server,cbFunc,cbData,0); // to initiate the connection

where
cbFunc(handle,type,err,cbData) {
if there's data ready then
call the xml conversion functions with ClientTCPRead(handle,buffer,bufsize,0);
if disconnection close the connection
}

and whenever I need to send data, I just need to do :
ClientTCPWrite (handle,buffer,bufsize,0);

where buffer is the output of my xml conversion functions ?

When I'm talking about xml conversion, that's actually because I
use structs to store the data in the application, which are designed
in the same way the data XML Trees has been done.

I'm not sure this is the right way though, because I need to
authenticate the user for the whole connection to the database, so
I need to keep the connection up for all the session (and restart the
connection whenever it is needed).

Usually, to get answers to those questions, I'd do code snippets,
and test them in real situation... But my boss is urging me to finish
the project ASAP, where ASAP is before next week (and I'm still working
on the measure library and the data library...), so any help would save
my holidays 😆

thanks for your time and your insightful assistance,
--
Bernard Pratz
IT Developer
Engineering service
Chelton Telecom & Microwave
0 Kudos
Message 3 of 7
(3,833 Views)
by the way, you can contact me by mail in French or on the French community forum in that thread... if you're more comfortable in that language (though in English here may be useful to more people 😉

Message Edité par Guyzmo le 07-19-2005 06:31 PM

--
Bernard Pratz
IT Developer
Engineering service
Chelton Telecom & Microwave
0 Kudos
Message 4 of 7
(3,837 Views)
I have the habit of putting URLs between <URL> but it seems
the forum portal is interpreting HTML, though I checked the box I don't
want my posts to be interpreted in HTML... So the URLs I talked about
in my second post is : libxml2 and the second one is :

the thread in French

nice evening,
--
Bernard Pratz
IT Developer
Engineering service
Chelton Telecom & Microwave
0 Kudos
Message 5 of 7
(3,830 Views)

You can use the TCP event handler or just sit in a loop reading the xml buffer. There is no wrong way to do it, it depends on the application and the amount of data being transfered. If you have alot of data in the tcp stream and you think you will be spending alot of time processing the stream, you could handle the tcp in another thread using the CVI threadpool functions.

CVI is an ANSI C compiler, so as the long as the xml library exports a C interface and can be used on windows, you should be able to use it in CVI. It's not something I've used before so I cannot tell you what kind of problems you might run into. You don't need to create a fp to use it. Just an import library and header will do.

I would think that since you are talking to databases, you are probably using ODBC with ADO? Or some sort of component that allows you to communicate with databases? Usually, the component is responsible for authentication and keeping the connection with db alive if that is what is necessary. You should not have to use the tcp library to keep this connection allive. All you should do with that is grab your data from the network, manipulate it and send it where ever it needs to go. Database connection components provide access for talking to dbs remotely as well, so it's not something you would need to explictly handle.

Just a couple of ideas here. I hope this helps. Good luck with the app.

Bilal Durrani
NI
0 Kudos
Message 6 of 7
(3,816 Views)
        Thanks for your answer, sadly I had to give up on that feature, as
    we're being too much in a hurry. I'm also having a better understanding
    of the CVI environment, and what it is _concretelly_. Sadly, I had to
    do more than half of the project to get to that...

        I'm not using an ODBC connection, as it seems much simpler to use
    directly the interface library given by the db-vendor (actually postgresql).
    I originally wanted to use XML for all db communications, as the data needed
    to be converted to different formats, and to different systems, with different
    authentication on the data.

    Anyway, that'll be another's work 😉

    Thanks again,

--
Bernard Pratz
Chelton Telecom & Microwave
--
Bernard Pratz
IT Developer
Engineering service
Chelton Telecom & Microwave
0 Kudos
Message 7 of 7
(3,782 Views)