473,606 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding Duplicate Messages off of COM port

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[i] != escapedmessage[i])
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[i] = escapedmessage[i];
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[i] != escapedmessage[i])
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[i] = escapedmessage[i];
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
} // end if(index != 17)
if(index == 17)
strcat(info,"UK N");

if(duplicate)
strcat(info,"DU P");
}
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;
};

Jul 11 '06 #1
7 1837
ucfcpegirl06 wrote:
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.
[snip code]

What's your question exactly?

Cheers! --M

Jul 11 '06 #2

ucfcpegirl06 wrote:
Hello,

I am trying to flag duplicate messages received off
of a com port.
OK
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.
OK
Here is the code:
[snip... ulgy code]

OK, what's your C++ question? I must have missed it.

-Brian

Jul 11 '06 #3
It detects m essages that are not duplicate messages as though they are
and some messages that are dup messages it doesn't detect. My question
is what is wrong w/ the code.
BigBrian wrote:
ucfcpegirl06 wrote:
Hello,

I am trying to flag duplicate messages received off
of a com port.

OK
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.

OK
Here is the code:
[snip... ulgy code]

OK, what's your C++ question? I must have missed it.

-Brian
Jul 11 '06 #4
ucfcpegirl06 wrote:
BigBrian wrote:
ucfcpegirl06 wrote:
Hello,
>
I am trying to flag duplicate messages received off
of a com port.
OK
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.
OK
Here is the code:
[snip... ulgy code]

OK, what's your C++ question? I must have missed it.

It detects m essages that are not duplicate messages as though they are
and some messages that are dup messages it doesn't detect. My question
is what is wrong w/ the code.
First, please don't top-post. Put your replies inline or below the post
you are responding to.

Second, have you tried going through the code with your debugger?
That's generally the way these things are solved. Additionally, this
newsgroup is for discussing the C++ language proper rather than
debugging code (cf. this FAQ
http://www.parashift.com/c++-faq-lit....html#faq-5.9).
Consequently, your question is off-topic. If you can reformulate the
question in terms that make it on-topic here, we'll be happy to try to
help, but otherwise, I think you're on your own.

Cheers! --M

Jul 11 '06 #5
ucfcpegirl06 wrote:
OK, what's your C++ question? I must have missed it.
It detects messages that are not duplicate messages as though they are
and some messages that are dup messages it doesn't detect. My question
is what is wrong w/ the code.
Still don't see a C++ question, at most a C question...
(OK, the first line seems to imply C++, but all the rest seems C).

Jul 11 '06 #6

"ucfcpegirl 06" <tr************ **@gmail.comwro te in message
news:11******** **************@ s13g2000cwa.goo glegroups.com.. .
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[i] != escapedmessage[i])
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[i] = escapedmessage[i];
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[i] != escapedmessage[i])
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[i] = escapedmessage[i];
dupArray[index].time_Tx = time;
dupArray[index].len_Tx = len;
}
} // end if(index != 17)
if(index == 17)
strcat(info,"UK N");

if(duplicate)
strcat(info,"DU P");
}
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;
};

1. Code is not complete. Can not compile as is. (Missing variable
declarations such as len, etc..
2. The BLADE constants are suspect. Specifically because of these snippets:

#define BLADE10 ((unsigned char)0x10)

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 == MM) index = 16;

BLADE10 is defined as ((unsigned char)0x10)
0x10 is 16. So index can be set to 16 if soure is either 0x10 or 0x0E.

Since I have no idea what source is used for, I can't say if this is what
you want or not.

I would try to ensure that BLADE10 through BLADE14 aren't supposed to be
declared this way:
#define BLADE10 ((unsigned char)0x0A)
#define BLADE11 ((unsigned char)0x0B)
#define BLADE12 ((unsigned char)0x0C)
#define BLADE13 ((unsigned char)0x0D)
#define BLADE14 ((unsigned char)0xOE)

but then MM and BLADE14 would have the same definition. Again, I couldn't
tell you if this was correct or not, because you haven't posted complete
code.

I would suggest (as someone else did) that you try to understand what this
code is doing, as only know can know if it is correct without a lot more
information.
Jul 12 '06 #7

"Jim Langston" <ta*******@rock etmail.comwrote in message
news:9i******** *******@fe03.lg a...
>
>#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)
>
1. Code is not complete. Can not compile as is. (Missing variable
declarations such as len, etc..
2. The BLADE constants are suspect. Specifically because of these
snippets:

#define BLADE10 ((unsigned char)0x10)

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 == MM) index = 16;

BLADE10 is defined as ((unsigned char)0x10)
0x10 is 16. So index can be set to 16 if soure is either 0x10 or 0x0E.
Check again on that. MM is defined as 0xE0, not 0x0E.
Since I have no idea what source is used for, I can't say if this is what
you want or not.

I would try to ensure that BLADE10 through BLADE14 aren't supposed to be
declared this way:
#define BLADE10 ((unsigned char)0x0A)
#define BLADE11 ((unsigned char)0x0B)
#define BLADE12 ((unsigned char)0x0C)
#define BLADE13 ((unsigned char)0x0D)
#define BLADE14 ((unsigned char)0xOE)

but then MM and BLADE14 would have the same definition. Again, I couldn't
tell you if this was correct or not, because you haven't posted complete
code.
MM is 0xE0. BLADE14 is 0x0E, so they're not the same.

But you're right about not having enough information (including what is
expected to happen, and _exactly_ what is actually happening that makes the
poster know there is a problem). And a debugger will undoubtedly be the
best way for the poster to investigate the problem, not simply asking us
"what's wrong with this code?".

-Howard


Jul 12 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
12078
by: Russell | last post by:
I'm using MySQL 4.1.1 I've inherited a database which has some (almost) duplicate rows. The databse is like this. userID userPosition userDepartment
0
2269
by: Helge Jensen | last post by:
Having posted in microsoft.public.dotnet.framework.sdk and microsoft.public.dotnet.framework.wmi without receiving any response, I posthere on the off-chance that someone who isn't following those groups knows a solution. I'm using code (roughly like): using System; using System.Management; public class Foo {
11
7500
by: Jean-Christian Imbeault | last post by:
I have a table with a primary field and a few other fields. What is the fastest way to do an insert into that table assuming that sometimes I might try to insert a record with a duplicate primary key and want that to fail? I know that if I try a plain insert this will work, but in the case where I am trying to insert a duplicate key, the insert fails (as it should) and an error is logged. I could first do a check to see if there is...
6
10304
by: pekspro | last post by:
I need some code that gets the address from a server. I read somewhere that you could do this by starting some broadcast server using UDP. The client should send an broadcast message, and when the server answering the client gets the address. But how do I implement this? I did this simple quick-hack: Server: Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
1
6669
by: Mike Hunter | last post by:
(Please CC me on any replies as I'm not on the list) Hi, After a recent power failure, a program that uses a pgsql backend (netdisco) started to send me nastygrams. I tried the author's suggestion of running a VACUUM FULL ANALYZE VERBOSE;, but it still sends me the messages. The data in the database isn't too important, i.e. I'm willing to blow away data to try to fix the problem. Any suggestions?
6
2258
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely PC, but has a significant number of Macs running OS X, too. Googling around quickly turns up IM Grabber for the PC, which would seem to be just what they need. But there is no equivalent to be found for OS X. So if anyone knows of any such...
1
2730
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do anything. I would love some help, here is the code: import socket import thread import time
1
2712
by: trytobreak | last post by:
Hey guys, I have a netscreen firewall which is configured to forward syslog messages to port 514 of my machine (specific ip on the network) and I am really puzzled as on how to capture these log messages using CSHARP/ VB.NET. Can you please forward on me some example code on how to go about this?
2
1228
by: cmrhema | last post by:
Hi, We have developed a socket program as below, The program works fine, except that it sometimes gives me jumbled messages or same message gets repeated twice. The whole code is produced below. I will let you know what exactly are we doing. This a socket program for tracking vehicle. The vehicle sends the signal through gprs+gsm mode, to our port.
0
8015
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7951
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5966
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1553
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1296
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.