LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/ Disable Comport from PC

I would like to do, Re-scan method with Labview. 
Tasks:
1. want to see all connected comports
2. Then I will selelct which component I need to disable/eject.
3. Then i again install that disabled comport.
4. Again, I want to see all connected Comport

Please guide me through it, if you have a solution

0 Kudos
Message 1 of 11
(419 Views)

Hi Rshah,

 


@Rshah31 wrote:

I would like to do, Re-scan method with Labview. 
Tasks:
1. want to see all connected comports
2. Then I will selelct which component I need to disable/eject.
3. Then i again install that disabled comport.
4. Again, I want to see all connected Comport

Please guide me through it, if you have a solution


  1. Use the VISAFindResources function and filter for COM ports.
  2. How do you want to "disable" a COM port?
  3. How do you want to "install a disabled COM port"?
  4. Back to step 1…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(412 Views)

Thank you for the reply, 

I will select the Comport which I want to disable/eject from Scan list, and Press on the button "Disable" So that particular port will no longer be used.

After that, I again pressed the Enable button to install it again. 

This is what you want to ask!  Sorry if I misunderstood something!

0 Kudos
Message 3 of 11
(400 Views)

Hi Rshah,

 


@Rshah31 wrote:

I will select the Comport which I want to disable/eject from Scan list, and Press on the button "Disable" So that particular port will no longer be used.

After that, I again pressed the Enable button to install it again. 


I would do something like this:

  1. Use VISAFindResources to get all COM ports in the system.
  2. Display the list of ports in a listbox.
  3. Using two buttons next to this listbox ("Enable", "Disable") I would en-/disable items in the listbox…

I hope I understood your requirements correctly…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(397 Views)

Yes, perfectly matches my requirements.

Could you please guide me a bit more? Which VIs/Functions do I need to use? 

Sorry to ask these questions, but I am very new to LabVIEW, so I don't know much about that. If Possible, could you please share some examples 

0 Kudos
Message 5 of 11
(393 Views)

Hi Rsash,

 


@Rshah31 wrote:

Could you please guide me a bit more? Which VIs/Functions do I need to use? 


I already mentioned VISAFindResources several times.

I also mentioned a listbox and you can edit their properties (like item array, en-/disable items) using property nodes.

To react on user input (aka button actions) I recommend an event structure…

 


@Rshah31 wrote:

I am very new to LabVIEW, so I don't know much about that. If Possible, could you please share some examples 


There is a whole section on Training resources offered at the top of the LabVIEW board!

And LabVIEW comes with an example finder, stuffed with lots of example VIs…
 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(376 Views)

This is the fastest way I found to get the connected devices in LabVIEW:

COM Example.png

Tim
GHSP
0 Kudos
Message 7 of 11
(338 Views)

Thank you for your Help.

For the Enable/Disable button I am using User Event structure. 

But I could not understand What should I implement into the user structure. How can I do this task 

0 Kudos
Message 8 of 11
(335 Views)

When you say "Enable" and "Disable", you need to be more specific about what you are trying to accomplish here.

 

Are you trying to copy the functionality of "Device Manager"?  Meaning, that you want to add something in LabVIEW that makes it so when you tell it to "disable" a COM port, it's the same as if you had right-clicked the port and selected "Disable device", making it so that every single application on your PC could no longer use it until you enable it again?

Kyle97330_0-1753806698647.png

 

If this is the case, you probably can't do it in LabVIEW, or automate it in any way.

 

Please back up a few steps and explain why disabling COM ports is important to you.

 

If I had a guess, I would guess that you have a device that uses a COM port, and it sometimes stops working.  You have figured out that if you unplug the device and plug it back in, or disable and then enable it in Device Manager, that it starts working again.  So you want to add code to do this automatically.  If that's the case, then your real problem is something else, and your solution needs to reflect that.  If it's what I just guessed, then you probably either need to update the drivers for your COM port, or buy a different model of COM port adapter.

 

If I guessed, wrong, let me know.  But this problem you are trying to solve sounds like the middle part of something, not the beginning of something.  Tell us what the beginning is.

0 Kudos
Message 9 of 11
(320 Views)

@Kyle97330 wrote:

 

Kyle97330_0-1753806698647.png

 

If this is the case, you probably can't do it in LabVIEW, or automate it in any way.

It can be done using the device console, pnputil and probably, for the very adventurous, with direct calls to the windows setup API.

 

  Tell us what the beginning is.


 

Yes.

 

I can also imagine that this is about preventing the user to connect to a specific device by temporary de-listing a specific port from the drop-down. The question looks very much like an XY-Problem.

0 Kudos
Message 10 of 11
(303 Views)