LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA serial interface works only in design mode

Solved!
Go to solution

This  VI does what it is supposed to do in design mode ( Its part of a project ). But when I build the project it does not work.  The Serial Port reference is via the control which has the right port by default. 

 

What could be wrong ?  Using LV2017 / WIN10 Pro / VISA driver 17

 

Simple Serial Query-Response.png

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

Hi Raghunathan,

 

don't use BytesAtPort!

As you enabled the TermChar (at SerialPortInit) all you need to wire is a sufficient large number of bytes you expect to receive…

 

There's no (real) error handling in your VI: do you get any errors when running the executable?

Best regards,
GerdW


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

Ohhh MogaRaghu, Smiley Sad

 

You've been on the forums long enough to know that code is a bad idea.

I'm sure you've hear of not using Bytes at Port.

I'm sure you realize that having the false wired to the stop terminal makes it an infinite stop loop, forces you to abort the VI, and means the VISA close never runs.

 

And I'm sure you've heard that saying something "doesn't work" isn't helpful.  Explaining in what ways it doesn't work is.

 

Please tell me what you based your code off of.  I'm guessing it is the Simple Serial example which while simple, is a really poor example of how serial based communication works.

 

Everyday we see bad examples of serial port communication all with the same flaws.  It is like a virus.  I wish we could the source of it all and get rid of it.

 

You are saying you are building this into and exe, correct?  Are you running it on the same PC as your development environment?

0 Kudos
Message 3 of 21
(3,375 Views)

I did mention this code snippet is part of a large project where the stop signal is generated based on human interaction. I just simplified it here to make it simple. And so that explains the False constant wired to Stop. 

 

You wanted to know what the code is based off. Frankly it was copied from another of (my) project. And that's working the last year onwards.

 

Bytes at port  … ok maybe it is evil as death.  Will not use it. 

 

What works in design does not work when I build the App. That's what I wanted to know why. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 21
(3,365 Views)

@RavensFan wrote:

 

Everyday we see bad examples of serial port communication all with the same flaws.  It is like a virus.  I wish we could the source of it all and get rid of it.

 


Well the source of it is LabVIEW itself 

 

Go to Help--->Find Examples 

Then search for Serial and open the "Simple Serial" example 

SimpleSerial.png

We all need to lobby NI to replace this example with one that uses proper serial programing techniques.

 

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 21
(3,362 Views)

@RTSLVU wrote:

@RavensFan wrote:

 

Everyday we see bad examples of serial port communication all with the same flaws.  It is like a virus.  I wish we could the source of it all and get rid of it.

 


Well the source of it is LabVIEW itself 

 

Go to Help--->Find Examples 

Then search for Serial and open the "Simple Serial" example 

SimpleSerial.png

We all need to lobby NI to replace this example with one that uses proper serial programing techniques.

 


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.

 

So MogaRaghu, you still haven't answered our questions.

What error are you getting when it "doesn't work"?

Are you running the executable on the same PC you developed on?

0 Kudos
Message 6 of 21
(3,353 Views)

Not likely to be your problem, but your VISA Configure is set to use LF (\n) as termination character, yet your command is terminated with a CR (\r).  Is that really what you want?

0 Kudos
Message 7 of 21
(3,351 Views)

@Mancho00 wrote:

Not likely to be your problem, but your VISA Configure is set to use LF (\n) as termination character, yet your command is terminated with a CR (\r).  Is that really what you want?


I think that would be a problem, but it should cause a problem in the development environment as well as executable.

0 Kudos
Message 8 of 21
(3,348 Views)

@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.


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 9 of 21
(3,344 Views)

@RavensFan wrote:


I think that would be a problem, but it should cause a problem in the development environment as well as executable.


That's what I thought.   Sometimes things manage to work despite our best effort to mess them up, though.Smiley Wink I've had to deal with engineers managing to get CRLF backwords (LFCR?).  That was fun!

0 Kudos
Message 10 of 21
(3,343 Views)