LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA serial interface works only in design mode

Solved!
Go to solution

@RavensFan

1.  There is no error thrown... everything is silent. Rest of the project runs as of nothing happened.

2. Yes the code is developed on the same PC which is connected to the machine … much easier to checkout as the code uses some 40 DIO and 18 AIO. 

 

As I write this I just got a flash - if it can be called that - I should have checked the status of the COM port on Windows Device Manager … will do when I get back to the macjhine

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 11 of 21
(1,184 Views)

@crossrulz wrote:

@RavensFan wrote:

I knew that and said that in my message.  I just wanted to hear directly from the people using Bytes at Port where they are getting the idea from.  Unfortunately, that is so pervasive that even fixing the example won't eradicate all the sources of bad information out there that used it.  I really wish NI would kill this example.


It really should be replaced with 4 to 6 new examples, each based on how the instrument communicates (Stream, Command-Response, or Intermittent transmission and ASCII or Binary/Hex/Raw data).  And only the Intermittent versions should have the Bytes At Port in it.


I completely agree.  There are a few more serial examples in the Finder than I had realized.  And I feel like they may have revised the names of them a bit over the years.  (Like I though Read/Write or Write/Read was part of the "Simple" example).  I don't think anyone looks at the others because why would you because the "Simple" one would be easier?

 

The ones you listed would be perfect, and should include inside some comments that accurately describe what the messages would look like.

0 Kudos
Message 12 of 21
(1,182 Views)

Definitely check in device manager.

 

But the code as written now will not show you an error even if there is one.  Just because you can't see an error doesn't mean that one isn't being thrown.

Put an error indicator inside the while loop right before the tunnel, that way you'll be able to SEE the error.

 

Are your bouncing back and forth between the development and executable?  If you run in development and you fail to close the com port properly, you'll get an error when you run the executable because it won't be able to access it since the PC sees it used by another application.  And vice versa.

0 Kudos
Message 13 of 21
(1,167 Views)

Yes will need to go the next level to track the offending part … maybe I will enable Debug option in the build and wire up an error indicator and see. 

 

And the point regarding improper closing of COM port - yes have suffered a lot on account of this earlier !!

 

Let me get my hands on the machine...

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 14 of 21
(1,153 Views)

Ok created a simple project and this one works both in design and standalone App mode. The serial device is a simple MCU that sends back a string in response to a command from the host.  But then this is on my laptop and only tomorrow I will access to the machine where I had a problem to start with.

 

In the meanwhile I just wanted to know the best way to choose the COM port when running as a standalone EXE. The project is attached as a zip

 

1. Create a separate VI that launches ahead of the main VI and allows you to choose the COM port ad then passes that reference to the main VI.

 

2. Instead of a separate VI, save the chosen COM port reference to disk and the next time the App starts read and load from the disk.  ut this one means that for every change of COM port the user has to launch twice. 

 

Any other method ? 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 15 of 21
(1,133 Views)
Solution
Accepted by topic author MogaRaghu

@MogaRaghu wrote:

In the meanwhile I just wanted to know the best way to choose the COM port when running as a standalone EXE.


I use a configuration file to save the serial port settings.  You can even use the executable's ini file.  Then you just have to use the Configuration File library to read the settings and set up your port.


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 16 of 21
(1,132 Views)
Solution
Accepted by topic author MogaRaghu

I like to use configuration files too in order to save settings between runs of VI's.  But I also like to put in an event structure and a button that tells whether the port is open or closed.  The event structure handles the value change on that button.  When it goes true, it opens the port, when it goes false it closes it.  Sometimes a value change on the VISA control so that if you change it it will trigger events for closing the current one and opening the new one.  Also, I include a Save Settings button that if you press that, the event case for that button saves the current settings to the configuration file.

Message 17 of 21
(1,124 Views)

@crossrulz wrote:

@MogaRaghu wrote:

In the meanwhile I just wanted to know the best way to choose the COM port when running as a standalone EXE.


I use a configuration file to save the serial port settings.  You can even use the executable's ini file.  Then you just have to use the Configuration File library to read the settings and set up your port.


Sounds good.  SO far have never used the INI file .. and for instance to bring in the COM port reference how do I it ? I am sure it requires a specific syntax to be followed ??

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 18 of 21
(1,111 Views)

@RavensFan wrote:

…... But I also like to put in an event structure and a button that tells whether the port is open or closed.  The event structure handles the value change on that button.  When it goes true, it opens the port, when it goes false it closes it.  Sometimes a value change on the VISA control so that if you change it it will trigger events for closing the current one and opening the new one. …...

 

How to create an event structure to tell if the port is open or closed ? And the only control for the VISA that is seen in the Event Structure is the VISA Resource name … Is that the one you are referring to ? Thanks  


 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 19 of 21
(1,110 Views)

@MogaRaghu wrote:

Sounds good.  SO far have never used the INI file .. and for instance to bring in the COM port reference how do I it ? I am sure it requires a specific syntax to be followed ??


For ini files, you have sections and keys.  The sections are in brackets and the keys are just Name=Value.  So as an example, I tend to have something like the following in my configuration file:

[Serial Port]
Port=1
Baud=115200

Now in my code, I read those section-key values (Read Key.vi) as whatever data type I need them.  To form the VISA session, I just use the Format Into String with a format of COM%d.  This will add what I had in for Port into the string after COM and then I can wire the resulting string into the VISA Configure Serial Port and just let LabVIEW coerce the string into a VISA Session.


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
0 Kudos
Message 20 of 21
(1,105 Views)