U
ucfcpegirl06
Hello,
I have a dilemma. I am trying to flag duplicate messages received off
of a com port. I have a software tool that is supposed to detect dup
messages and flag and write the text "DUP" on the GUI of the software
tool to let the user know that a duplicate message was sent or
received.
Here is the code:
void CMessageEngine::checkDup(DWORD time){
//DUP dupArray[MAXCOMPONENTS]; //array that holds the last message
received and sent
// of each component of the Blade Center
int i;
int index=18;
int duplicate=0;
unsigned char dest = escapedmessage[0];
unsigned char source = escapedmessage[1];
// Identify duplicate received messages
if(dest == SDBYMM)
index = 0;
if(dest == BLADE1 || dest == BLADE2 || dest == BLADE3 ||
dest == BLADE4 || dest == BLADE5 || dest == BLADE6 ||
dest == BLADE7 || dest == BLADE8 || dest == BLADE9 ||
dest == BLADE10 || dest == BLADE11 || dest == BLADE12 ||
dest == BLADE13 || dest == BLADE14)
index = (int) dest;
if(dest == KERNEL)
{
index = 16;
// index = 15;
}
if(dest == MM)
{
// index = 16;
index = 17;
}
if(index != 17)
{
if(dupArray[index].len_Rx != 0 && dupArray[index].len_Rx == len
)
{
if((time - dupArray[index].time_Rx) < CUTOFF_TIME)
{
for(i =0;i<len;i++)
{
if(dupArray[index].msg_Rx != escapedmessage)
break;
if(i == len-1)
duplicate =1;
}// end for
}
}
if(duplicate){
dupArray[index].time_Rx = time;
dupArray[index].len_Rx = len;
}
else
{
for(i=0;i<len;i++)
{
dupArray[index].msg_Rx = escapedmessage;
dupArray[index].time_Rx = time;
dupArray[index].len_Rx = len;
}
}
} // end if(index != 17)
//Identify duplicate sent messages
if(source == SDBYMM) index = 0;
if(source == BLADE1 || source == BLADE2 || source == BLADE3 ||
source == BLADE4 || source == BLADE5 || source == BLADE6 ||
source == BLADE7 || source == BLADE8 || source == BLADE9 ||
source == BLADE10 || source == BLADE11 || source == BLADE12 ||
source == BLADE13 || source == BLADE14)
index = (int) source;
if(source == KERNEL) index = 15;
if(source == MM) index = 16;
if(index != 17)
{
if(dupArray[index].len_Tx != 0 && dupArray[index].len_Tx == len
)
{
if((time - dupArray[index].time_Tx) < CUTOFF_TIME)
{
for(i =0;i<len;i++)
{
if(dupArray[index].msg_Tx != escapedmessage)
break;
if(i == len-1)
duplicate =1;
}// end for
}
}
if(duplicate){
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
else{
for(i=0;i<len;i++)
dupArray[index].msg_Tx = escapedmessage;
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
} // end if(index != 17)
if(index == 17)
strcat(info,"UKN");
if(duplicate)
strcat(info,"DUP");
}
In Header file:
//Used to check duplicate messages
#define MAXCOMPONENTS (17)
#define SDBYMM ((unsigned char)0xD0)
#define BLADE1 ((unsigned char)0x01)
#define BLADE2 ((unsigned char)0x02)
#define BLADE3 ((unsigned char)0x03)
#define BLADE4 ((unsigned char)0x04)
#define BLADE5 ((unsigned char)0x05)
#define BLADE6 ((unsigned char)0x06)
#define BLADE7 ((unsigned char)0x07)
#define BLADE8 ((unsigned char)0x08)
#define BLADE9 ((unsigned char)0x09)
#define BLADE10 ((unsigned char)0x10)
#define BLADE11 ((unsigned char)0x11)
#define BLADE12 ((unsigned char)0x12)
#define BLADE13 ((unsigned char)0x13)
#define BLADE14 ((unsigned char)0x14)
#define KERNEL ((unsigned char)0x0F)
#define MM ((unsigned char)0xE0)
//Time to check for duplicate messages
#define CUTOFF_TIME (60000)
//Structure that holds duplicate messages
struct DUP {
DWORD time_Rx;
unsigned char msg_Rx[MAXMESSAGE];
int len_Rx;
DWORD time_Tx;
unsigned char msg_Tx[MAXMESSAGE];
int len_Tx;
};
I have a dilemma. I am trying to flag duplicate messages received off
of a com port. I have a software tool that is supposed to detect dup
messages and flag and write the text "DUP" on the GUI of the software
tool to let the user know that a duplicate message was sent or
received.
Here is the code:
void CMessageEngine::checkDup(DWORD time){
//DUP dupArray[MAXCOMPONENTS]; //array that holds the last message
received and sent
// of each component of the Blade Center
int i;
int index=18;
int duplicate=0;
unsigned char dest = escapedmessage[0];
unsigned char source = escapedmessage[1];
// Identify duplicate received messages
if(dest == SDBYMM)
index = 0;
if(dest == BLADE1 || dest == BLADE2 || dest == BLADE3 ||
dest == BLADE4 || dest == BLADE5 || dest == BLADE6 ||
dest == BLADE7 || dest == BLADE8 || dest == BLADE9 ||
dest == BLADE10 || dest == BLADE11 || dest == BLADE12 ||
dest == BLADE13 || dest == BLADE14)
index = (int) dest;
if(dest == KERNEL)
{
index = 16;
// index = 15;
}
if(dest == MM)
{
// index = 16;
index = 17;
}
if(index != 17)
{
if(dupArray[index].len_Rx != 0 && dupArray[index].len_Rx == len
)
{
if((time - dupArray[index].time_Rx) < CUTOFF_TIME)
{
for(i =0;i<len;i++)
{
if(dupArray[index].msg_Rx != escapedmessage)
break;
if(i == len-1)
duplicate =1;
}// end for
}
}
if(duplicate){
dupArray[index].time_Rx = time;
dupArray[index].len_Rx = len;
}
else
{
for(i=0;i<len;i++)
{
dupArray[index].msg_Rx = escapedmessage;
dupArray[index].time_Rx = time;
dupArray[index].len_Rx = len;
}
}
} // end if(index != 17)
//Identify duplicate sent messages
if(source == SDBYMM) index = 0;
if(source == BLADE1 || source == BLADE2 || source == BLADE3 ||
source == BLADE4 || source == BLADE5 || source == BLADE6 ||
source == BLADE7 || source == BLADE8 || source == BLADE9 ||
source == BLADE10 || source == BLADE11 || source == BLADE12 ||
source == BLADE13 || source == BLADE14)
index = (int) source;
if(source == KERNEL) index = 15;
if(source == MM) index = 16;
if(index != 17)
{
if(dupArray[index].len_Tx != 0 && dupArray[index].len_Tx == len
)
{
if((time - dupArray[index].time_Tx) < CUTOFF_TIME)
{
for(i =0;i<len;i++)
{
if(dupArray[index].msg_Tx != escapedmessage)
break;
if(i == len-1)
duplicate =1;
}// end for
}
}
if(duplicate){
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
else{
for(i=0;i<len;i++)
dupArray[index].msg_Tx = escapedmessage;
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
} // end if(index != 17)
if(index == 17)
strcat(info,"UKN");
if(duplicate)
strcat(info,"DUP");
}
In Header file:
//Used to check duplicate messages
#define MAXCOMPONENTS (17)
#define SDBYMM ((unsigned char)0xD0)
#define BLADE1 ((unsigned char)0x01)
#define BLADE2 ((unsigned char)0x02)
#define BLADE3 ((unsigned char)0x03)
#define BLADE4 ((unsigned char)0x04)
#define BLADE5 ((unsigned char)0x05)
#define BLADE6 ((unsigned char)0x06)
#define BLADE7 ((unsigned char)0x07)
#define BLADE8 ((unsigned char)0x08)
#define BLADE9 ((unsigned char)0x09)
#define BLADE10 ((unsigned char)0x10)
#define BLADE11 ((unsigned char)0x11)
#define BLADE12 ((unsigned char)0x12)
#define BLADE13 ((unsigned char)0x13)
#define BLADE14 ((unsigned char)0x14)
#define KERNEL ((unsigned char)0x0F)
#define MM ((unsigned char)0xE0)
//Time to check for duplicate messages
#define CUTOFF_TIME (60000)
//Structure that holds duplicate messages
struct DUP {
DWORD time_Rx;
unsigned char msg_Rx[MAXMESSAGE];
int len_Rx;
DWORD time_Tx;
unsigned char msg_Tx[MAXMESSAGE];
int len_Tx;
};