From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-06-2011 05:39 AM
hello all,
I have a the .net code of a function to open a rs232 port using a dll.
here is the code:
I'm trying to implement this code in labview, but I'm having some dificulties.
I've attached an image that displays my troubles.
any help would be apreciated.
thanks,
Adam
Solved! Go to Solution.
04-06-2011 08:58 AM - edited 04-06-2011 08:59 AM
Is there a reason you're not just using the VISA functions to communicate over the serial port? Seems like it would be a lot less hassle...
TParamList rs232_settings = new TParamList();
TParamList rf_settings = new TParamList();
These indicate that you need to use the constructor to create two objects that are of the TParamList class type.
Rf rf_module = new Rf();
This is an instantiation of an object of the RF class. Same thing: constructor.
rs232_settings.Add(SettingsConst.RS232.COMPORT_PARAM, comPort);
rs232_settings.Add(SettingsConst.RS232.BAUDRATE_PARAM, baudRate);
Simple method calls. You are using the Property node. You need to use the Invoke node.
I could go on... do you know .NET?
04-06-2011 09:57 AM
thanks for the reply,
I'm not using the Visa functions because I don't know the commands to send to the device. All I have are the dlls and an small example in visual studio c#. If there is another way to do this I can try it as long as it is in Labview.
I'm not very experienced in visual studio c#.
If I understood correctly this is how I should program the .net function in labview.
However I still don't know how to input the com port or the baudrate. They should be integers however I have .net class in paramValue instead.
thanks again,
Adam
04-06-2011 10:38 AM
What is the instrument/device that you are trying to talk to? Do you at least have the documentation on the .NET API? Where did you get this .NET API?
04-06-2011 11:41 AM
It's a RF signal emitter that connects to the PC using the serial port.
All I have from the .NET API is a small example in visual studio c# that implements some basic functions using various dlls. I've tried the code in visual studio and it works.
That's why I am trying to replicate the visual studio code in labview. If I can understand how to implement this function I think I will be able to understand the rest of the VS code.
tks
Adam
04-06-2011 12:13 PM
Manufacturer? Model Number? Link?
If you don't have the documentation, then I don't see how we can help you. For instance, in the function you cited, comPort is an integer. Does this refer to a com port number? If so, does 0 mean COM1, or does 0 mean the first available COM port (so it could be, for example, COM3)? Is this a Windows.Forms application, or is it a console application?
You're not giving much information for us to go on...
04-07-2011 03:31 AM
Hello,
It´s a custom RF emitter built here at the company. I don't have documentation all I have is the code and it works in visual studio so I know that for example the function in the first post "public static Rf OpenDriver(int comPort, int baudRate, int rfRetries)" is called using the following arguments:
OpenDriver(1, 9600, 3) where "1" is COM1, "9600" is the baudrate and "3" number of retries all integers. My problem is that I don´t know how to translate the code in the function to labview code.
It´s a windows.forms.application and I'm sorry that I don't have any more info.
Any help in decoding the function to LabView would be very appreciated.
tks!
Adam
04-07-2011 04:07 PM
OK. Well, based on that, and seeing the code, it appears to me that the Add method's signature is basically Add(string paramName, Object paramValue). In this case you'd have to use the To .NET Object to connect a constant of 1 (for example for the COM port) to the paramValue input. As for the other parameter I can't really say because I can't see the rest of the C# code. I may be able to decode it if you upload the .NET assembly(ies) that you're using in LabVIEW.
04-08-2011 06:27 AM
I was able to replicate C# code in labview successfully
Thanks for your help!
Adam