Recently I got a Desktop with Windows 7 Ultimate.
I installed VS2005 which I was using for more than four years on XP Machine.
My application which was working fine on XP is not working on windows 7 machine.
When bytes are read from the Serial Port ( I am using .NET 2.0 Serial Port ) BytesToRead is not getting reduced. it keeps increasing and eventually buffer is full and stops receiving any more data.
am I missing anything ?
code snippet which reads from serial port is given below.
public void PSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
ushort addr, Data,crc;
byte cmd;
char ch;
do
{
CharReceived = ch = (char)this.ReadByte(); // read char from port
} while (ch != '@');
Packet[0] = (byte)ch;
this.Read(Packet, 1, 13);
crc = CRCGenerator.GenerateCRC(Packet, 10, 0);
cmd = (byte)toint((char)Packet[1]);
addr = (ushort)( toint((char)Packet[10]) * 16 + toint((char)Packet[11]));
addr = (ushort)(addr * 256 + toint((char)Packet[12]) * 16 + toint((char)Packet[13]));
if (crc != addr) // if crc is non zero then ignore packet.
{
return;
}
addr = (ushort)(toint((char)Packet[2]) * 16 + toint((char)Packet[3]));
addr = (ushort)(addr * 256 + toint((char)Packet[4]) * 16 + toint((char)Packet[5]));
Data = (ushort)(toint((char)Packet[6]) * 16 + toint((char)Packet[7]));
Data = (ushort)(Data * 256 + toint((char)Packet[8]) * 16 + toint((char)Packet[9]));
rRPktNo++;
if (rRPktNo == 128)
{
rRPktNo = 0;
}
DataReceivedEventArgs de = new DataReceivedEventArgs(cmd,addr,Data);
OnDreceived(de); // activate event
return;
}
the application was deployed and working fine on four different XP machines, for more than three years.
Replies
Know the answer? Post it — somebody with the same question will find it here.