Marshall:
Technically speaking, viRead takes a ViUInt32, which means the max size should be 0xFFFFFFFF. In reality, many lower level drivers (and also the COM API, that's Microsoft COM not Serial COM) accept only a ViInt32, which means that the max is 0x7FFFFFFF.
But you'll never get anything close to either of these numbers over Serial. Why? Because the OS maintains a locked kernel buffer for each port to hold the data as it comes in off the UART. In VISA you set the size of this buffer with viSetBuf (in LabVIEW it's VISA Set Buffer Size). The default size is a smaller buffer than most apps need, but you can usually set it as high as 32KB-1 without a problem. (This is the max size on Mac OS 8/9, for example.) Windows does not specify a maximum
size but I've seen requests for buffers greater than 32KB fail.
The best way is to always preset the buffer size to a little more than the max you ever expect to read. Then, to read data, do as Dennis suggested and always query the number of bytes available, or just do a read operation with the maximum number of bytes you expect. If you're reading ASCII data, you can make the read request be a larger size than you need and VISA will automatically stop reading (by default) when it gets to the specified termchar (\n by default).
Good luck,
Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments