ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with serial write string

Solved!
Go to solution

I am using labview to send commands to a device using the com1 serial port.  Using the example VI "Basic Serial Read and Write" I can communicate with my hardware just fine, can write and can read.   the problem comes when I want modify the VI by using my own string instead of the string supplied in the example.  When I create a string constant with the same exact text that was in the example's string box I cannot write to my hardware. 

 

I dont understand why this wont work.  Is there something special about the example VI's text box "string to write" that I dont know about?

 

Please help

 

 

0 Kudos
Message 1 of 3
(3,538 Views)

If you right click on the examples string control and select "\" codes display, you will see that \r\n is present which represents that a carriage return and new line character is added to the command, which most serial command writes require.

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 2 of 3
(3,535 Views)
Solution
Accepted by topic author nomeans

Thanks

I know what you mean and it isn't working that way.  For some reason if I use a string constant with \r\n it still does not work.  

Anyway I solved the problem in a roundabout manner.  The command I am sending is one word but two parts; first part text, second part number.  I want to create a loop where the number changes.  I was able to do this by combining three strings, the first is a copy of the example's string, the middle is my number converted to string, the third is a different copy of the examples string.  Now it works and I can get on with my life

 

0 Kudos
Message 3 of 3
(3,531 Views)