LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW serial port programming using the WinAPI and CreateFile() and CloseHandle()? Yes or no?

Solved!
Go to solution

Incidentally, when I saw the red dotted VISA option given the other day I went to try it on a trusty RS232 VISA-based interface I wrote a bit back...until I noticed the red dot and then abruptly halted. Returning to seek explanation is when I found Martin's response. Of course I tried that! I was very happy to find 1) my code was read, and 2) he was correct. I haven't looked back since. But, seeing these 'why are you doing this?!" questions pouring in I felt I should say something. I will put the time in to do something if I know it will work. I knew the WinAPI would work. I just had to get past that LabVIEW blockade, had to take my little Shawshank plinker and work on that wall, one chip at a time, plink, plink, plink. Hey look there goes another rubber tree plant. First I opened and then I closed, no matter what the COM port number. Success! Then I... Then I... Then I...  I absolutely love the state machine, step by step by step.

0 Kudos
Message 61 of 75
(965 Views)

It still works great!

 

Thank you so much, Martin, wherever you are out there!  I just say COM port number n to my VI and poof! in comes the response to my transmission. If n was a bogus number, then I just get no response because Windows couldn't configure the port that didn't exist. It is so dirt simple! ...no VISA involved anywhere. It's all Windows and Windows doing what its docs say it will do.

0 Kudos
Message 62 of 75
(851 Views)

Some may ask, "why resurrect this old thread -- I thought this was solved?"  To this I return to the post that started the thread where I said, "explain at least a little bit how it'll work."

 

I don't think the explanation ever came in, and I'd still like to hear it.

 

If using VISA, how could it be done? How could I successfully (not an attempt that may or may not succeed) do the equivalent of what's been done independent of VISA?

 

To recap, here's what's been done:

The VI

1) accepts only a number, a number that should be a valid COM port number but may not be valid

2) accepts a string of hexadecimal bytes, simply a string like 000102030405060708F1E2D3

3) transmits the string out the COM port, if possible, and receives the response, if there was one

4) if it wasn't possible simply identifies where there was an error and does not crash the VI

 

I still don't think it is possible using VISA. But yet, just because I think something it doesn't mean I am correct.

0 Kudos
Message 63 of 75
(815 Views)

You said, way back in the thread (I don't just start a new thread if the prior hasn't really completed, understand):

 

"I asked you if you have tried VISA Find Resources."

 

Yes, I did. It returned everything under the sun it could find, not what was actually there for my use. However, if you want more than that, I am sorry but I don't recall. Rather, I just remember it worked, but overworked and, therefore, wouldn't work without much more fixing to refine the search, fixing where I'd have to go dig to find answers. I find National Instruments leaves much to be desired in the answers department.

 

(True, perhaps it is how I ask the question. And? To find an answer, I've found, requires knowing the material enough to ask the correct question. But what if one doesn't know the material? Hmm? Back in the day one could pull out a manual (or a manual from a set of) and thumb through the pages, one-by-one. Or better said, one could see unfamiliar material and still learn. That isn't today. Searching today is, frankly, awful. Also, one cannot just bite the bullet and pay money for the manual, to be stored on the hard wooden bookshelf, either. ...without Kinkos and yet more work done, that is. The manual is free! No it isn't.)

0 Kudos
Message 64 of 75
(814 Views)

You (again, way back in the thread) said:

 

"Just use the right tool for the job. "

 

What are those tools that will do the job, not might do the job, but that actually will do the job? My VI actually does the job, and it does it without VISA. It does it all in one standalone VI. Seriously, there isn't even a single subVI used, not one. Which was harder to accomplish, in the end? Struggle with the WinAPI and succeed (thank you Martin!), dependent upon Windows, throughout, or still not having an answer, dependent upon NI and VISA? Really, which one is it? Yes, I do sound provocative/defensive, but see it from my perspective, please. I am not a LabVIEW professional by any stretch of the imagination, and I know and freely admit this; I come to such for guidance.

0 Kudos
Message 65 of 75
(812 Views)

Martin, I just shot you another kudo. You get it!

 

"Such a situation makes it very difficult to get the correct VISA resource name for the systems port COM12."

 

You so get it! ...but yet you, also, feel VISA should be used. I want to learn how it can be done. How do I accomplish what I have accomplished but using VISA? ...one VI, no subVIs, won't crash on the user, abruptly breaking a test dependent upon that VI...

 

Somehow I think you understand the importance of dependable deterministic testing.

0 Kudos
Message 66 of 75
(809 Views)

You also I shoot another kudo, for you are approaching the problem: the infinite.

 

"That's because Windows has a somewhat strange way of enumerating new Plug&Pray hardware. It uses the PCI and USB bus and device number on which the device is connected and its serial number to determine if it is a known device or not. If any of these things is different it will consider it a new unknown device and assign a new never before used device ID..."

 

Now, how do you deal with the infinite in a paradigm of VISA dependence? Windows does.

0 Kudos
Message 67 of 75
(808 Views)

"I recommend to place all those controls/indicators into a typedef'd cluster"

 

Wrong answer. Minus two. That requires a tag-along file.

0 Kudos
Message 68 of 75
(807 Views)

"The "kind of question" you refer to above is the kind of question that gets asked when someone wants to do something in a strange and non-standard way and their benefactor(s) are hoping that, by understanding the reason behind the strange request, they can help them to an alternative solution."

 

Yep, what's the alternative? If not for me, what about the others out there who will come along? Do they have to use the WinAPI, too? VISA is so much simpler, right? Here ya go. Here's your platform. Please explain how the same thing can be accomplished as has been accomplished, but using VISA.

 

I guarantee you you will be flooded with kudos if you do it. 😉

 

0 Kudos
Message 69 of 75
(800 Views)

"Also I will echo the rest of the people here... you're being REALLY combative for people trying to help you for free. The fact that we're on page 3 and we're still trying to figure out what you're trying to do indicates you haven't posed a clear question."

 

What you see as combat I see as trying to learn how to fish, but not from people sitting watching Bill Dance Outdoors. 😉

 

Was that combative?

0 Kudos
Message 70 of 75
(799 Views)