Hi Chris,
Thanks for the response. Termination character seems like a probable cadidate for the problem except SerialSession.TerminationCharacterEnabled indicates its set to false. Enclosed is trace output and trace output code demonstrating recent results. Since the number of bytes returned is always variable it would seem like the return stream might have a termination character at different point along the stream. Is it possible that the read is terminating even when SerialSession.TerminationCharacterEnabled is false?
I also tested getting bytes after the first read and there are more bytes to be had. We have tested the system with another SerialPort class and have verfied that the system works fine with other serial port software. So the issue is 100% isolated to NI.Visa.
Thanks for your time and interest.
Best Wishes,
Rana
--- Trace Output ---
remainingMessageLength: 6496
_SerialSession.AvailableNumber='320', _ListenStopwatch.ElapsedMilliseconds='827',
_SerialSession.AvailableNumber='544', _ListenStopwatch.ElapsedMilliseconds='847',
_SerialSession.AvailableNumber='796', _ListenStopwatch.ElapsedMilliseconds='869',
_SerialSession.AvailableNumber='1020', _ListenStopwatch.ElapsedMilliseconds='889',
_SerialSession.AvailableNumber='1258', _ListenStopwatch.ElapsedMilliseconds='909',
_SerialSession.AvailableNumber='1482', _ListenStopwatch.ElapsedMilliseconds='929',
_SerialSession.AvailableNumber='1706', _ListenStopwatch.ElapsedMilliseconds='950',
_SerialSession.AvailableNumber='1944', _ListenStopwatch.ElapsedMilliseconds='970',
_SerialSession.AvailableNumber='2280', _ListenStopwatch.ElapsedMilliseconds='1000',
_SerialSession.AvailableNumber='2518', _ListenStopwatch.ElapsedMilliseconds='1020',
_SerialSession.AvailableNumber='2742', _ListenStopwatch.ElapsedMilliseconds='1040',
_SerialSession.AvailableNumber='2966', _ListenStopwatch.ElapsedMilliseconds='1060',
_SerialSession.AvailableNumber='3218', _ListenStopwatch.ElapsedMilliseconds='1082',
_SerialSession.AvailableNumber='3442', _ListenStopwatch.ElapsedMilliseconds='1101',
_SerialSession.AvailableNumber='3876', _ListenStopwatch.ElapsedMilliseconds='1139',
_SerialSession.AvailableNumber='4100', _ListenStopwatch.ElapsedMilliseconds='1159',
_SerialSession.AvailableNumber='4324', _ListenStopwatch.ElapsedMilliseconds='1179',
_SerialSession.AvailableNumber='4562', _ListenStopwatch.ElapsedMilliseconds='1199',
_SerialSession.AvailableNumber='4786', _ListenStopwatch.ElapsedMilliseconds='1219',
_SerialSession.AvailableNumber='5010', _ListenStopwatch.ElapsedMilliseconds='1240',
_SerialSession.AvailableNumber='5388', _ListenStopwatch.ElapsedMilliseconds='1273',
_SerialSession.AvailableNumber='5626', _ListenStopwatch.ElapsedMilliseconds='1293',
_SerialSession.AvailableNumber='5850', _ListenStopwatch.ElapsedMilliseconds='1313',
_SerialSession.AvailableNumber='6074', _ListenStopwatch.ElapsedMilliseconds='1333',
_SerialSession.AvailableNumber='6312', _ListenStopwatch.ElapsedMilliseconds='1353',
_SerialSession.AvailableNumber='6496', _ListenStopwatch.ElapsedMilliseconds='1380',
bodyLengthInBytes: 6484
_SerialSession.TerminationCharacterEnabled: False
oim.Body: 224
secondAttempt: 109
_SerialSession.AvailableNumber='6163', _ListenStopwatch.ElapsedMilliseconds='1409',
--- Trace Output Code ---
Debug.WriteLine("remainingMessageLength: " + remainingMessageLength);
// Wait for remaining message
while (_SerialSession.AvailableNumber < remainingMessageLength)
{
// Check listen timeout
if (_ListenStopwatch.ElapsedMilliseconds > _ListenTimeInMilliseconds)
{
this.ThrowInterrogatorException();
}
StringBuilder sb = new StringBuilder(128);
sb.Append("_SerialSession.AvailableNumber='");
sb.Append(_SerialSession.AvailableNumber);
sb.Append("', _ListenStopwatch.ElapsedMilliseconds='");
sb.Append(_ListenStopwatch.ElapsedMilliseconds);
sb.Append("',");
Debug.WriteLine(sb.ToString());
Thread.Sleep(SLEEP_INTERVAL_IN_MILLISECONDS);
}
StringBuilder sb2 = new StringBuilder(128);
sb2.Append("_SerialSession.AvailableNumber='");
sb2.Append(_SerialSession.AvailableNumber);
sb2.Append("', _ListenStopwatch.ElapsedMilliseconds='");
sb2.Append(_ListenStopwatch.ElapsedMilliseconds);
sb2.Append("',");
Debug.WriteLine(sb2.ToString());
// Read body
int bodyLengthInBytes = remainingMessageLength - OcmInterrogatorMessage.FOOTER_LENGTH_IN_BYTES;
Debug.WriteLine("bodyLengthInBytes: " + bodyLengthInBytes);
Debug.WriteLine("_SerialSession.TerminationCharacterEnabled: " + _SerialSession.TerminationCharacterEnabled);
oim.Body = _SerialSession.ReadByteArray(bodyLengthInBytes);
Debug.WriteLine("oim.Body: " + oim.Body.Length);
byte[] secondAttempt = _SerialSession.ReadByteArray(oim.Body.Length);
Debug.WriteLine("secondAttempt: " + secondAttempt.Length);
StringBuilder sb3 = new StringBuilder(128);
sb3.Append("_SerialSession.AvailableNumber='");
sb3.Append(_SerialSession.AvailableNumber);
sb3.Append("', _ListenStopwatch.ElapsedMilliseconds='");
sb3.Append(_ListenStopwatch.ElapsedMilliseconds);
sb3.Append("',");
Debug.WriteLine(sb3.ToString());