Hello again,
2). I imagine the format of the string written to the device (1 or 2 bytes at a time) is dependent on that device. I would try both ways and see if one fails. If both fail, you may want to contact the manufacturer or consult the user manual to be sure of the format.
5b and 5cii). If you can use a loop, the best way to read the latest 4 bytes always and deterministically, with best serial performance (not necessarily overall performance if other programs are running) is to set the UARTs receive FIFO size to 4 (I will describe how and why to do this below) and to read 4 bytes at a time in a loop. The reason for setting the FIFO size is to cause the interrupt necessary for transferring data from the FIFO to CPU memory as soon as 4 bytes are received. This way, you will have access to 4 bytes as soon as they are available (subject only to the interrupt processing time of your machine, which you do not have a great deal of control over). The "overall" performance reference I mentioned above is only to say that decreasing the number of bytes on which such an interrupt will occur will simply cause more interrupts to occur, using more processing time per byte (than would be having this value set to 14 for example, since fewer interrupts would occur). This is not really a problem, and it is relatively common to decrease this number to get better SERIAL performance as you seem to desire. You can set the FIFO size in software on most modern UARTs. The following should get you there on an XP machine (similar on others):
1. Open the Device Manager.
2. Expand the Ports (COM & LPT) tab.
3. Right click and select properties.
4. Click the Port Settings tab.
5. Click the Advanced... button.
Here you can change the receive buffer (FIFO) size to 4. Then you can read 4 bytes at a time in a loop and you will have the latest 4 bytes of data all the time. If necessary, you can keep an accumulator value in SW to monitor the total number of bytes received over multiple reads/loop interations. That way you can essentially throw away bytes until bytes 45-48 come around, and you will not have the overhead of dealing with all 48 bytes at once when you are only interested in the last 4.
As to which bytes are the last, you are correct in that the last bytes in the buffer that will be read are the last bytes that were sent; that is, bytes are read in the order they are received. If you cannot loop and read 4 bytes at a time, you will likely have to read all 48 and simply use the last 4.
The loop method mentioned above will eliminate the idea of reading only the 2 most recent bytes, along with 2 "old" bytes. If you definitely expect a multiple of 4 bytes to be returned, then reading in 4 byte chunks will cause the read function to return only when receiving 4 bytes; the "old" 2 bytes would have been read in the previous loop iteration, and the read function would simply wait (at least until the timeout period) until it received 4 new bytes. If you cannot use this method, then depending on method used to trigger your read vi, you may only have received 46 bytes at that time. However, if you read 46 bytes you would know that because the VISA Read function returns the number of bytes read (which presumable you specified as an input to the read function anyway, since it seems as though you are not using termination characters).
Thanks, and I hope you are able to accomplish your desired functionality!
Best Regards,
JLS