Unfortunately, the CP343 seems to be very cumbersome to work with. Any help would be greatly appreciated.
I wish there was a simple answer, but there isn't. Someday I'm going to write a book about S7 Comunications, and let Siemens give it away to everyone. Maybe it would make up for their confusing and dispersed help files.
I'll add a few comments to your comments:
am using the AG_SEND and AG_RECV blocks. I am not calling the blocks unconditionally all of the time. I call them when I am expecting information or when I need to send information.
Ok, that may or may not be ok. Typically, I'll just call comm functions unconditionally, but in the cases where I do not, I make sure any open jobs are completed, or I'll reset the job. Keep this in the back of your mind.
The problem is that sometimes the other equipment might have sent a reply when I am performing a reset on my equipment. That puts a "message" in my buffer at that point.
So what problem does this cause? Can't you just toss out this message? Are the messages time-stamped or is there some index telling you whether you've missed messages or not? If you send a message that you expect a reply to, could you include an ID that had to be returned so you could match it with your query?
The reason that I can't wait for a reply is that I am never sure if my other piece of equipment is turned on or not. For instance, I am working with an EPSON robot. The robot has a long cycle time and/or it wrecks sometimes. In that case, I need to send a reset signal to the robot to clear out the communication.
Is this reset signal over ethernet? Or do you have some sort of hardware signal? If you do it over ethernet, can you include some sort of heartbeat message, perhaps every 10 seconds? If the hearbeat goes down, you could clear the buffer until the heartbeat is reestablished.
The other problem is that I don't know when the communication link is established. If I knew when the communcation link was established, that would help greatly. I would then know if the external piece of equipment was ready to receive information.
Well, this is possible, but a little tricky. If you can't use the heartbeat, then you can experiment with the FC62(C_CNTRL) from the CP300 library. I've never used it, but maybe that would do the trick. You can also start screwing around with the SDBs which would give you even more info, but that will be a last resort. Let's see if FC62 works.
Oh, and which CP card are you using (Part# and Revision)?