07-12-2017 07:12 AM
Hello,
I did some troubleshooting to check that my serial comm port was working correctly using a write buffer constant \040000\02AA>0\03\r using '\' Codes Display to send a command to the VISA write function block. As expected after running the simulation I received a hex response of 06 (ACK). This verified that Tx and Rx were operating as expected on the RS232 port.
Now that the sequence has been verified, I wish to perform the same operation using a text file (.txt) to send the exact same command.
The issue I am having now is that I when I'm trying to send the exact same command \040000\02AA>0\03\r from a text file it is actually being sent as 0430\s3030\s3002\s4141\s3E30\s030D\s
Therefore the sequence of the command will not enable for a response of 06 (ACK) to be received.
So the question is, how can the text file (.txt) be formatted in the same way as write buffer constant so that VISA Write will send the command in the correct format?
Many Thanks
Solved! Go to Solution.
07-12-2017 08:11 AM
I would just have the text file be the hex values. Then your code does a Hex String To Number and then Byte Array To String to convert the data into the right format for sending the data.
07-13-2017 04:03 AM
Hi Crossrulz,
I attempted to follow your advice by implementing Hex String To Number and then Byte Array To String.
When trying to implement Byte Array to String I seemed to have compatibility issues implementing it into the block diagram.
I've actually included two separate VI's below to try to specify the problem exactly.
The first VI reveals that the constant has no formatting issues and is read as it is supposed to be at the RS-232 port and provides the correct response.
When trying to send the exact same command from a text file the formatting issue begins. I've tried searching in depth on how to resolve this.
All I want to achieve is for the text file to have the same formatting that is provided via the write buffer constant.
Many Thanks
07-13-2017 04:19 AM
Hi neunited,
make the display style indicator of your string constant visible. (This should ALWAYS be done!)
Then compare the display style of your string constant with the style of your "text" indicator…
When you want the exactly same result you should use the very same display style!
07-13-2017 04:29 AM
Hi GerdW,
I completely agree with you, I set the write buffer constant to '\' Codes Display which identifies the code correctly in the text box in the front panel.
But how can the display style indicator be achieved with a text file? Sorry I might be missing your point here.
Many Thanks
07-13-2017 04:35 AM
Hi neunited,
the point is: you are comparing apples with oranges when you don't use the same display style in those different places…
Either edit your "text" file to have the same content as your string constant - or you need to convert as has been suggested before! (Keep in mind: a "text" file is just a collection of bytes in a file with a filename suffix of "txt"…)
07-13-2017 04:49 AM
If you want the text into the file to have the \ Codes Display or Hex Display formatting, you can load its content into a string control or indicator featuring the very same display format. The control/indicator value will be the desired string.
07-13-2017 06:39 AM - edited 07-13-2017 06:40 AM
Hi Paolo,
What is the name of the function you used in String 1 (between the controls) please?
Many Thanks,
Neunited
07-13-2017 06:49 AM
07-13-2017 07:41 AM
Every LV "object" (controls and indicators, but also the Application and the Vi themselves, and others too) feature its own set of Properties (attributes) and Methods (functions). You can use a Property e.g. right-clicking on a control on the FP or its terminal on the BD, then selecting Create -> Property node -> ... You can find more information in the LabVIEW help.
Property nodes (and Invoke nodes for calling Methods) are very useful and practically unavoidable to write a good LabVIEW program in most applications (with some caution if you need very high performance).