I hadn't forgotten this thread or suddenly magically succeeded... I have been trying to find out more info about what is going wrong in the gaps between other work. Unfortunately I'm stuck.

I built a debuggable release version as recommended, and thus am able to debug it in release mode effectively. It is failing, as expected - the good thing is, repeatably at the same place, same reason.

The bad thing is, I can't figure out why.

It's going wrong here each time:

        if (!::WaitCommEvent(rsThreadData.hPortHandle, &dwEvent,
                                        &rsNotifyOverlapData) )


And the fault is - access violation, because rsThreadData's address is now 0x00000001. Specifically that value, every time it fails. I had tried to put code on the outside of this call to see when exactly it went wrong, like this:

                while (!psThreadData->bTerminate)
                {
// JDEBUG
if ( (DWORD)psThreadData == 0x00000001)
        psThreadData->bTerminate = FALSE ;
                        dwNumBytes = WaitForRX(*psThreadData, sNotifyOverlapData);
// JDEBUG
if ( (DWORD)psThreadData == 0x00000001)
        psThreadData->bTerminate = FALSE ;
                        if (dwNumBytes > 0)
                                ReceiveBytes(*psThreadData, dwNumBytes);
// JDEBUG
if ( (DWORD)psThreadData == 0x00000001)
        psThreadData->bTerminate = FALSE ;
                }

Once it did manage to catch it there, but most times, it seems to NOT be wrong until it gets into the WaitForRX() call (which is where that WaitForComm() line is). It's as if it's getting corrupted on entry.

I DID change optimizations to 'minimum size' as recommended - I will bear this in mind in the future, I did not know this.

So now I'm stuck - I don't know how to try and find out why it's getting corrupted to such a specific value. If it was buffer overrun form the actual comms somehow, despite my efforts, I'd expect something different there, not 0x00000001 - that's no valid Modbus combination, so it can't be comms overrun.

Any further suggestions?

--
Jason Teagle
[EMAIL PROTECTED]
 

_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
subscription changes, and list archive.

Reply via email to