LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using SetCommState to configure external device

Hello, I am trying to use the kernel32.lib function SetCommState to set the communications for and external I/O board. The board is by Sealevel Systems, and they supply VB example code. The problem I have is this: in the code, they run the function GetCommState, then they individually modify the baudrate, bytesize, parity, and stopbits to match the settings fo the device. Finally, they take the updaded settings and input them into the function SetCommState. This all works well in VB, where it is possible to set the baudrate, bytesize, etc. individualy, but in labview, I cannot seem to do this. So I either need to be able to set these individually, or I need to know the protocol for inputting all four parameters into SetCommState through labview. Another option is to use internal labview code (like VISA), but I am not sure that approach would work. Any help would be much appreciated. Thanks,
JOe
0 Kudos
Message 1 of 4
(2,599 Views)
If the I/O board presents its self as COM ports under windows (check this out using the Device Mangager) then I suspect that using VISA to configure the commstate should work nicely.

0 Kudos
Message 2 of 4
(2,594 Views)

responses to threads like this one would've been helpful

 

sometimes you can't use VISA!

 

so what then?

 

0 Kudos
Message 3 of 4
(697 Views)

@3d0g wrote:

 

sometimes you can't use VISA!



 

so what then?


You learn a LOT about C programming and head over to the Microsoft site and learn how the Win APIs in question work and then look at the LabVIEW example of how to pass various data types through the Call Library Node.

 

If you have a specific problem with a specific parameter dstatype you create a small VI showing the function in question, with the Call Library correctly configured for the other parameters, backsave it several versions and attach it to a post on here that you make. Or chances are very high that if you search on here you will actually find a similar problem with an answer or two from me and others, that explains the solution already. And yes those answers are highly technical and not always suited for someone without already some good base knowledge about C datatypes and C memory management and such.

 

DLL calling uses C syntax and principles and while the Call Library Node gives you the ability to call DLLs it can not take away the need to understand C programming details. If you insist on using it you must be willing to invest in learning these things too.

 

PS: The answer you reacted on for sure was meant as helpful remainder that there is VISA and that in most cases that is already enough to do serial communication. The OP did not specify why he feels that he needs to call this Windows API and there are many posts on here where users ask for a complicated solution because they do not yet know that LabVIEW comes with that specific functionality already out of the box.

 

If the OP really had felt that they need this complicated solution they could always have responded and explained why they feel that VISA did not work for them.But they didn’t so the answer was probably enough or they lost interest. 

The functionality of SetCommState for the parameters they mentioned for sure can be controlled through VISA!

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(685 Views)