07-01-2025 03:40 AM
Hello ladies and gentlemen,
I'm currently working with two COM/Serial ports and I would like to have the possibility of connecting to each port independently and also both at the same time. At the moment, my code only works if both ports are in use. In the event that one port is disconnected, this throws and error.
Question 1: Does anyone have an idea on how to go about this? currently the only solution I can think of is to implement a case structure to handle the port selection.
Question 2Additionally, is it possible to save data from the two loops into one file TDMS file or any file format
Attached is the vi. Heads up: It's a very block diagram but i will clean it up later once I'm done fixing some issues
07-01-2025 04:19 AM
Please do a "save for previous" (LabVIEW 2020 or below) and attach once more. This way more (including me) have a chance to look at your VI.
You can use as many ports as you want in parallel.
Why are there two loops? Do they run at different rates?
Saving data to file is trivial.
Once I can open your VI and see what you are doing, it should be easy to find a solution.
07-01-2025 05:39 AM
I have attached a new vi i really hope it works.
Yes its possible to use two ports in parallel but i have an error handler on each and if one is not enabled. an error is thrown but i want to implement the flexibility of bein able to select one port at a time or both.
Ideally the loop should run at the same time. If I have one loop enclosing all the code. i have some error handling issues generated by the unconnected port. Which I why I decide to solve one step at a time starting with com port selection
07-01-2025 06:04 AM
Sorry, I cannot really inspect your VI, because my laptop screen is not that gigantic, but from what I see there is some serious code smell.
What you need is a simple state machine that probably fits on a postcard properly modularized and handles all communications as desired (A, B, Both). I would start with simplifying the serial communication, so watch Tim's presentation in the link above.
07-01-2025 06:33 AM
Thanks for the feedback. I will get back to you once I've checked Tim's presentation you linked and also cleaned up the code (i understand it's unnecessarily large). I will reupload a new vi
As far as the current vi status is, the top section of code works as expected when I read from the sensor. The duplicate code was something that I was using to figure out some serial communication stuff and missed correcting some issues related to "stop"