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

"One more of many reason to seriously question the decision to want to go the Windows API route in spite of any good advice."

 

Teach! What is that VISA advice, rolfk?

0 Kudos
Message 71 of 75
(485 Views)

I saw the opportunity so I took it. +1

 

"Who hasn't started a DIY project, even though the result is perfect and ready in the shop around the corner?"

 

Hopefully the gravity of my situation is now understood. I haven't used it (your s/w tool), but I believe it works, because I believe you. You know how to fish.

0 Kudos
Message 72 of 75
(478 Views)

"It’s called the NIH (Not Invented Here) syndrome. It’s highly contagious among engineers and incurable.

3d0g_0-1684712199248.png

 

"

But is that really it?

 

Or, rather, is it I know it'll work if I do it? If you don't know exactly how something works, how do you know it'll continue to work as it has in the past? Perhaps there's a gotcha! in there. You don't want a gotcha! with Mr. Murphy's hypothesis about your domain. That's what engineering is about. It's about designing something that works and continues to work. That's the challenge.

 

Some engineering is designed not to work in perpetuity, as such engineering would crush the sales numbers. However, I submit that such engineering is actually successful engineering, for it is doing what it was designed to do: sustain and/or increase sales. But nowadays, sustaining is actually increase.

0 Kudos
Message 73 of 75
(473 Views)

@*3d0g wrote:

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.


This was said many weeks ago. VISA does this already. It takes 3 seconds. Wire "COM4" to the VISA Resource input and it works fine

 

If you want to simplify it to being just a single number, use a Format Into String with the format code "COM%d" and wire in the single number. That's it. That's all there is to it. Yes there is a coercion dot. No it's not a problem. If you don't like the dot you can use "Coerce to type" and it would've gotten rid of the dot.

0 Kudos
Message 74 of 75
(434 Views)

Can it be guaranteed that the COM number and the ASRL number are identical?

 

If yes, then how is it done?

 

Asked another way, why can they differ?

 

I needed to be able to communicate with a COM port that came into existence on the fly, upon the USB connection, and then, later, be able to remove it when it wasn't attached. ...not a good scenario to be dependent upon VISA imo, an opinion based on my limited experience in all this. Call it fear on my part. Yep, I'm scared to trust VISA for this. (Sure I use VISA, but not this time.)  I have to trust Windows -- there is no choice in the matter. Both LabVIEW and VISA are, with all said and done, dependent upon Windows.

 

Something I really like about the solution is each step sets a bit in a bit field, such that at the end the final value of the bit field tells the story about what failed where. It's actually a quite simple vi, once dealing with the WinAPI was handled. (Thanks so much again, Martin!) When it fails it doesn't crash. It just exits with "no, it didn't work, and here's why." If it doesn't fail then the bit field is the proper constant and there is either a response waiting or there isn't. It's simple, stands alone, no subvis nor typedefs to carry along. It's one vi that just simply runs.  

 

0 Kudos
Message 75 of 75
(405 Views)