From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2 COM port swithching at once!!!


@Dennis_Knutson wrote:
You've been using LabVIEW for quite some time and an event structure shouldn't take more than a few minutes to write. Have two buttons (ie port1 and port2). In the value change event for each, just have a simple write and read. Configuration for each port should be done before the loop with the event structure starts. I'm assuming you get a termination character from both so the bytes to read can just be some large constant.
In my application, writing to different COM port is dynamic and will be depending on the initial character of data which I need to write to different COM port. Unfortunately I dont have any termination character. To be very frank with you guys. this code is working on my WIN7 and now changing again is a bit risky job, I agree that its a better way but now I dont want to take risk for now. Please understand my pressure also.
--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 51 of 117
(855 Views)

@johnsold wrote:

What does the Arduino port return from VISA Find Resource? If it returns "USB Serial Port", then the USB loop may close that port.

 

Look at the image below. The last VISA Resource Name value coming from the for loop goes to VISA Close. It also is passed to the property node in the next frame and the VISA Write in the following frame. Although there may be a value on that line which was a valid resource name, that resource was just closed. I am not sure what the property node and the VISA write do with that situation, but it does not seem right.

 

Close VISA.png

 

Does the timeout occur on the Write or the Read? What is the exact source string in the error cluster?

 

Lynn


Actually this VISA is not at all posing problem. Other VISA which is arduino is posing problem. In run time MY PC might have 3-4 VISA including arduino. I doubt this might possible of my issue but surprisengly this is working fine without any issue in development PC. This COM have different baud rate which needs to be initialized. Also why VISA write? In my case this USB is connected to PCB which is sending data continously which is used for some application,  After initialization, when I wrtie any data to it then it enters into test mode and my testing starts. After that I start my normal testing. Thats why I am not using my VISA read VI

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 52 of 117
(855 Views)

Hi lynn,

              I am getting timeout in VISA read and after that one more place where I am writing some data to arduino, eventhough before writing I am setting timeout timout as 10 sec then also I am getting timeout error there also after VISA write(Not using VISA read there).

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 53 of 117
(835 Views)

 

Actually this VISA is not at all posing problem. Other VISA which is arduino is posing problem.


 

 

My concern is that Find VISA Resource may find your Arduino VISA and then close that session. If you just make a simple VI which calls VISA Find Resource with the inputs set as in your program ?* and Aliases Only, what does the Arduino channel return?  If it also returns "USB Serial Port", which seems feasible, then the loop following VISA Find Resource in your program amy close the Arduino port and not the other port. It depends on the order it finds them, which one will be closed.

 

I am considering that the timeout error may be the result of the VISA session being closed.

 

Try removing the VISA Find Resource (temporarily) and wire a VISA Resource Name control which you manually set to the correct port for the other device. Do you still get timeout errors on the Arduino port then?

 

Lynn

0 Kudos
Message 54 of 117
(813 Views)
And remove the close as well. There's no point in doing that as far as I can see. The whole discovery process seems overly complicated and unnecessary. I would suggest you simply put the alias for each device in an ini file.

Since you do not appear interested in writing a simple VI to test the communication as I suggested, I'll not be responding any more.
0 Kudos
Message 55 of 117
(805 Views)

@Dennis_Knutson wrote:
And remove the close as well. There's no point in doing that as far as I can see. The whole discovery process seems overly complicated and unnecessary. I would suggest you simply put the alias for each device in an ini file.

Since you do not appear interested in writing a simple VI to test the communication as I suggested, I'll not be responding any more.

Its not like I dont want to write simple one. I need to rewrtie lots of thing and also need to validate again. When I have time then I will be re-writing this code again. Now I dont want to take risk

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 56 of 117
(788 Views)

Arduino code with COM port return. I agree that its a bug but why it is working on WIN7 all the time(Just a question)?

 

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 57 of 117
(785 Views)
I wasn't suggesting that you rewrite the entire code at this point. I was suggesting taking 10 minutes to write a simple VI without all the extra stuff that is on your present VI. Did you ever check the versions of the usb drivers?
0 Kudos
Message 58 of 117
(778 Views)

@Ranjeet_Singh wrote:

@Dennis_Knutson wrote:
And remove the close as well. There's no point in doing that as far as I can see. The whole discovery process seems overly complicated and unnecessary. I would suggest you simply put the alias for each device in an ini file.

Since you do not appear interested in writing a simple VI to test the communication as I suggested, I'll not be responding any more.

Its not like I dont want to write simple one. I need to rewrtie lots of thing and also need to validate again. When I have time then I will be re-writing this code again. Now I dont want to take risk


The idea Dennis is presenting to you is to quickly make something that reduces the code down to where you think the problem is.  You think it is the communications.  So make something that just does the communications so that you can test that.  Make refinements until you got something that works.  Then you can take what you learned and put it in your main project.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 59 of 117
(756 Views)

@crossrulz wrote:

The idea Dennis is presenting to you is to quickly make something that reduces the code down to where you think the problem is.  You think it is the communications.  So make something that just does the communications so that you can test that.  Make refinements until you got something that works.  Then you can take what you learned and put it in your main project.


Thanks for the suggestion,  I will implement the same and check. But any of you found any mistake in initializing the COM port for arduino and waiting for data and for next iteration becasue occasionaly it fails. also make sure after VISA find resource I am not closing the COM port 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 60 of 117
(727 Views)