cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Appending CR and LF to string

Solved!
Go to solution

Appending CR and LF to string

I'm interested in interfacing with an instrument which requires a CR and LF at the end of each message. I followed example 7 here but I get an error message telling me it times out. Can anybody offer advice as to my fault? The code is as below.

 

For further reference, I attempted to send the same command using termite, and with (what I believe) to be the exact same setup, I successfully read the result, as below.

 

Also, unfortunately the instrument does not have any feature for me to switch to a single termination character.

 

Thanks in advance for your help.

0 Kudos
Message 1 of 19
(242 Views)

Re: Appending CR and LF to string

Did you truly follow that example 7 all the way down to the note in the last sentence?

 

Right click your string constants and make sure they say \code style.  You should go to the Visible menu and make the display style visible.  My guess is that you have those as normal display and you are sending a literal backslash "r" backslash "n"

 

 

Message 2 of 19
(236 Views)

Re: Appending CR and LF to string

Magic time.

 

Consider showing the display style on string constantsSmiley Wink when set to escape codes display you will find out that there is no carriage return sent .

Message 3 of 19
(235 Views)

Re: Appending CR and LF to string

Many thanks for the very fast replies.

 

It turns out I didn't follow it exactly, I should have slowed down a little and been more observant. Smiley Embarassed I think I've corrected it as per your recommendations, however I still get the same error, which I've attached below. I've also attached the labview code in case that would be of more use.

 

Fwiw, I've also attached the relevant section of the manual, but I don't think there are any surprises there.

0 Kudos
Message 4 of 19
(218 Views)

Re: Appending CR and LF to string

According to your manual, you need to send both the CR and the LF.  The VISA Read timeout is because the equipment is just sitting there waiting for a LF that never comes.  Meanwhile, your VISA Read gets frustrated sitting there waiting for a response that never comes because the equipment is sitting around waiting for the LF, and finally VISA Read just gives up.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 19
(198 Views)

Re: Appending CR and LF to string


@billko wrote:

According to your manual, you need to send both the CR and the LF.  The VISA Read timeout is because the equipment is just sitting there waiting for a LF that never comes.  Meanwhile, your VISA Read gets frustrated sitting there waiting for a response that never comes because the equipment is sitting around waiting for the LF, and finally VISA Read just gives up.


Not exactly.   The term char is enabled and a linefeed....brb   ... and the handshake looks right.. but term mode for reads is term char not xoff... that looks odd

Message 6 of 19
(189 Views)

Re: Appending CR and LF to string

Thanks Bill, 

 

However I thought that the downwards arrow, before the typecast appended the LF on every message. My understanding is because Labview can't append two characters, you append the LF and have to add \r to the end of each message for the CR. Where have I gone wrong? Is it not appending the LF as I expected? I tried to add \n to the String with the escape codes display, but to no avail.

 

Edit: Just seen Jeff's post - good to know I'm not going crazy. Smiley Frustrated

0 Kudos
Message 7 of 19
(188 Views)
Highlighted
Solution
Accepted by topic author Demisicus
10-10-2018 08:17 AM

Re: Appending CR and LF to string

The problem is that you typecast the linefeed to a 32-bit integer.  You need to typecast it to a U8.  The I32 is being coerced into a U8.  It's probably sending a 00h rather than a 10h.

Message 8 of 19
(177 Views)

Re: Appending CR and LF to string


@Jeff·Þ·Bohrer wrote:

@billko wrote:

According to your manual, you need to send both the CR and the LF.  The VISA Read timeout is because the equipment is just sitting there waiting for a LF that never comes.  Meanwhile, your VISA Read gets frustrated sitting there waiting for a response that never comes because the equipment is sitting around waiting for the LF, and finally VISA Read just gives up.


Not exactly.   The term char is enabled and a linefeed....brb   ... and the handshake looks right.. but term mode for reads is term char not xoff... that looks odd


Oh, I get it.  I never use that property.  If I need to append an outgoing terminating character (or two), I add them explicitly to the outgoing message instead.  That, combined with the fact that I missed that setting in the picture (it is actually set twice) led to my mistake.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 19
(164 Views)

Re: Appending CR and LF to string

Many thanks RavensFan, it was that sneaky i32 causing the timeouts all along. Smiley LOL I now nearly have the program working, my returned String appears to be empty (displays only \r\n). I will have to be far more careful with my types.

Message 10 of 19
(159 Views)