Apologies in advance in case this has been covered but I couldn't find anything. So if this has been covered getting pointed in the right direction would be great. I am using an old demo code I found awhile ago to read an rs232 device without using VISA. I have to do this because The device I am using does not have the proper protocol implemented to be able to communicate with VISA. The device continuously sends out data but breaking a 16 bit data packet into two bytes so the data can be sent faster. On the LabVIEW side I have to take those two bytes and combine them into one 16 bit integer which I then do some simple math on to get the final value I want. So to summarize LabVIEW has to take two bytes and combine them with join numbers. The order that LabVIEW reads the bytes is extremely important because if the bytes are put together in the wrong order the final number will be wrong. My problem is that the initial buffer is a 3 element 1D array and as a result, when the bytes come in I will see the following: byte 1, byte 2, byte 1. Then, that array will get overwritten so the next array will be: byte 2, byte 1, byte 2. Since the array is over written the bytes will be combined differently each time. They will alternate as: byte 1 joined with byte 2, then byte 2 joined with byte 1. this is because join numbers never sees the third element of data from the buffer. Is there a way to change the size of the original buffer to a 2 element 1D array? When I try to change it, it becomes grayed out and it will not work.
Thank you in advance. I have attached the code I have been working on as well as the code I found which I have been building from.
Solved! Go to Solution.
"It" is the initial array that defines the buffer shown in first the pic I attached. I have so far been unable to do anything to this.
When I have tried it grays out as shown in the second image. The code does not give an error when this happens but it does not take data. I have tried to rebuild the array but whenever that happens it grays out as shown above. I have also tried to change the size by dragging the edge of the array to make it so that only two elements are shown but that does not seem to change the size at all as it will still take 3 bytes of data at a time.
I don't know what happened to my images the preview looked fine. I am new to this forum so forgive that. Here are the images in order:
It's just a diagram constant. The greyed out array is size=0, so just make it with two elements. (resize it back to three shown elements and enter 0 into the second element)
(you could also use "initialize array" to create an array of the desired size.)