I installed com0com 2.0 several weeks ago and it used to work until yesterday. No changes except maybe 'regular' WinXP updates. Now it truncates lines > about 100 chars. reboot changed nothing. I uninstalled 2.0, installed 2.1 and same problem.
I have 4 pairs all set up identically:
COM90-COM91,
emuBR? Y - N
enBuOv? N - Y
Plugin? N - N
Excl? Y - Y
Hidden? N - N
COM80-COM81,
COM70-COM71 &
COM60-COM6 (yes, I reduced 61 to 6 so my receiver can find it).
I have a console app that opens o/p COM90 9600-N-1,COM80 9600-N-1,COM70 4800-N-1 & COM60 4800-N-1, then opens all enumerated ports, looks for GPS string (which it finds on COM5), then reads on COM5 and writelines 128 char string on COM90 & COM80, then length 300-ish strings on COM70 & COM60. The very first write to very first output port (COM90) is truncated to about 100 chars, as verified via Hyperterm. splitting string to <=90 chars and Write + final WriteLine works just fine, but is too slow :-(
Opening steps:
SerialPort result = new SerialPort();
try
{
result.PortName = aPortName; // "COM90" etc
result.NewLine = "\r\n";
result.ReadTimeout = 1200;
result.WriteTimeout = 100;
result.BaudRate = 9600; // or 4800
result.DataBits = 8;
result.Parity = Parity.None;
result.StopBits = StopBits.One;
result.Open();
following code is work-around that works on writing:
const int kMaxWriteLen = 90;
private static void TransmitLineToPort(string aLine, SerialPort aPort)
{
// problem with truncatd lines
int pos = 0;
string frag;
while (pos < aLine.Length)
{
int fragLen = aLine.Length - pos;
if (fragLen > kMaxWriteLen)
fragLen = kMaxWriteLen;
frag = aLine.Substring(pos, fragLen);
pos += fragLen;
if (pos >= aLine.Length)
aPort.WriteLine(frag);
else
aPort.Write(frag);
}
}
I'm using C#/dotNet 2.0.50727 SP1/VS2005 Std Ed, on WinXP Pro SP3 on HP Compaq nx6125 notebook.
Any ideas?
Thanks.
Brewmanz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The Write Timeout seems important here - okay, maybe I changed that whilst trying to tune things. With Write T/O of 10 (rather than 100), only about 14 chars of each line get written, but there is no Timeout Exception raised - it is an insidious truncation. I'll raise the timeout to 1200 & see how it goes. I thought that with a 2K write buffer things would get written almost instantly.
So, there's still a problem somewhere with writes only being slowly written into the write buffer.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I installed com0com 2.0 several weeks ago and it used to work until yesterday. No changes except maybe 'regular' WinXP updates. Now it truncates lines > about 100 chars. reboot changed nothing. I uninstalled 2.0, installed 2.1 and same problem.
I have 4 pairs all set up identically:
COM90-COM91,
emuBR? Y - N
enBuOv? N - Y
Plugin? N - N
Excl? Y - Y
Hidden? N - N
COM80-COM81,
COM70-COM71 &
COM60-COM6 (yes, I reduced 61 to 6 so my receiver can find it).
I have a console app that opens o/p COM90 9600-N-1,COM80 9600-N-1,COM70 4800-N-1 & COM60 4800-N-1, then opens all enumerated ports, looks for GPS string (which it finds on COM5), then reads on COM5 and writelines 128 char string on COM90 & COM80, then length 300-ish strings on COM70 & COM60. The very first write to very first output port (COM90) is truncated to about 100 chars, as verified via Hyperterm. splitting string to <=90 chars and Write + final WriteLine works just fine, but is too slow :-(
Opening steps:
SerialPort result = new SerialPort();
try
{
result.PortName = aPortName; // "COM90" etc
result.NewLine = "\r\n";
result.ReadTimeout = 1200;
result.WriteTimeout = 100;
result.BaudRate = 9600; // or 4800
result.DataBits = 8;
result.Parity = Parity.None;
result.StopBits = StopBits.One;
result.Open();
following code is work-around that works on writing:
const int kMaxWriteLen = 90;
private static void TransmitLineToPort(string aLine, SerialPort aPort)
{
// problem with truncatd lines
int pos = 0;
string frag;
while (pos < aLine.Length)
{
int fragLen = aLine.Length - pos;
if (fragLen > kMaxWriteLen)
fragLen = kMaxWriteLen;
frag = aLine.Substring(pos, fragLen);
pos += fragLen;
if (pos >= aLine.Length)
aPort.WriteLine(frag);
else
aPort.Write(frag);
}
}
I'm using C#/dotNet 2.0.50727 SP1/VS2005 Std Ed, on WinXP Pro SP3 on HP Compaq nx6125 notebook.
Any ideas?
Thanks.
Brewmanz
The Write Timeout seems important here - okay, maybe I changed that whilst trying to tune things. With Write T/O of 10 (rather than 100), only about 14 chars of each line get written, but there is no Timeout Exception raised - it is an insidious truncation. I'll raise the timeout to 1200 & see how it goes. I thought that with a 2K write buffer things would get written almost instantly.
So, there's still a problem somewhere with writes only being slowly written into the write buffer.
> but there is no Timeout Exception raised - it is an insidious truncation.
At least it's raised with C++/dotNet 2.0.50727 (I'm not use C#).
Try something like this:
private static void TransmitLineToPort(string aLine, SerialPort aPort)
{
try
{
Console.WriteLine(Sending...);
aPort.WriteLine(aLine);
Console.WriteLine("OK");
}
catch (TimeoutException) {
Console.WriteLine("FAIL");
}
}