Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communications Intermittent Issue

Solved!
Go to solution

Hi, I'm having a strange issue while serially communicating with a device. 

 

I'm using the enlosed VI and trying to simply get the command prompt read from the device with a carriage return.

 

This works intermittently, at times it returns the prompt.  Other times it outputs an error that I can replicate using Tera-Term my sending a break command.

 

Any idea of how I can fix my vi to make it more stable and avoid the error?  Thanks!

0 Kudos
Message 1 of 9
(1,300 Views)

DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

 

You are using a termination character, so just tell the VISA Read to read more data than you ever expect to be returned.  This will also eliminate the need for the wait immediately after your write.


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 2 of 9
(1,294 Views)

I was afraid you were going to suggest that 😞

 

I read in many of the discussion groups to not use the Bytes At Port.  Unfortunately that is the only way I was able to get  the VI to run without a run error.

 

I can not set the Byte Count input to a high number as then I get a Visa Read Error and a long ~10 second time out. 

The only way I can get the VI to run successfully without an error is to enter the exact number of bytes at the VISA Read input as I am getting as a Return Count output.  

 

Hopefully there is just something fundamental that I am missing.  This is my first go at a serial port VI. 😖

 

Enclosed is my screenshot from today's trial. 

Thanks

 

 

0 Kudos
Message 3 of 9
(1,242 Views)

So this is interesting....

 

I made some changes to my VI to keep it simple (stupid=me) 😂 and now I can get a stable response to my commands..BUT I have to wait for the 10 second time out as I still get the read error.   If I can get past the error/delay I'll be in business!

 

0 Kudos
Message 4 of 9
(1,237 Views)

tom.pascente@gmail.com wrote:

So this is interesting....

 

I made some changes to my VI to keep it simple (stupid=me) 😂 and now I can get a stable response to my commands..BUT I have to wait for the 10 second time out as I still get the read error.   If I can get past the error/delay I'll be in business!

 


It's timing out because you are never getting 2000 bytes.  Try just enabling your termination character and it should work.


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 5 of 9
(1,233 Views)

tom.pascente@gmail.com wrote:

I was afraid you were going to suggest that 😞

 

I read in many of the discussion groups to not use the Bytes At Port.  Unfortunately that is the only way I was able to get  the VI to run without a run error.

 

I can not set the Byte Count input to a high number as then I get a Visa Read Error and a long ~10 second time out. 

The only way I can get the VI to run successfully without an error is to enter the exact number of bytes at the VISA Read input as I am getting as a Return Count output.


What I generally do for serial terminals is read 1 line at a time (Line Feed, 0x0A, is the termination character), using a queue to pass each line elsewhere for processing.  There is actually a lot more functionality I put into the terminal library (logging, handling errors, etc.), but the core is a queue to sending commands through the serial port and a different queue(s) for sending the data to where it is needed.

 

Here is a snippet of the VI I use for reading a line of data.  I am using the Bytes At Port only to see if there is data to read.  I am not using it to tell the VISA Read how many bytes to read.  The timeout here is typically 50ms.  This is to handle the terminal prompt.


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 6 of 9
(1,229 Views)

Thanks for your replies.  Seems the issue may be with my termination character.

The Enable Termination was set to False by accident, as I was changing various things to troubleshoot my issue.

When infact the Enable termination was set to True, I still have the timeout...thus my character is not correct.

 

I have two prompts on the device I'm connecting to.  My Pre-Login prompts:

ab-c-02 Login:

Password:

 

Then my logged in prompts

ab-c-02:~$

 

In the pre-login prompt when I set my termination character to :, it is not working

In the post -login prompt, $ does not work either

 

If I set the login prompts to the enter prompt character (ie ab-c-02 Login:), I no longer have the timeout but do not receive the right output I'm expecting.

 

 

Am I barking up the right tree in terms of chasing my issue down?

 

PS: thanks for your VI to read a line of data.  In my application unfortunately it didn't provide any output.  But it may be the termination character issue that may be preventing it from working?

 

 

 

0 Kudos
Message 7 of 9
(1,212 Views)

tom.pascente@gmail.com wrote:

I have two prompts on the device I'm connecting to.  My Pre-Login prompts:

ab-c-02 Login:

Password:

 

Then my logged in prompts

ab-c-02:~$

 

In the pre-login prompt when I set my termination character to :, it is not working

In the post -login prompt, $ does not work either


This goggles my mind.  There has something else happening.  Any other errors other than the timeout?


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 8 of 9
(1,203 Views)
Solution
Accepted by topic author tom.pascente@gmail.com

No other errors.

 

In fact, I can hack my way to getting my VI to work by setting the timeout from 10 seconds to 500 or 250 ms and accepting the error that is caused most likely by my prompt issue.

 

The output data is stable and duplicates what outputs from a tera-term connection.  I just have an ugly error red x to see on my VI panel.

 

I'd like to figure out what is going on, but for now I'll need to run with the bandaid to meet a schedule.  (I feel dirty) 

0 Kudos
Message 9 of 9
(1,191 Views)