InstallComCallback on Win7

I seem to have found a slight problem between Windows XP and Win7 computers target using InstallComCallback().

I developed my initial of the software on Windows XP.  The next two bits of code worked fine in WinXP with an eventMask = LWRS_RXFLAG | LWRS_RECEIVE.  But when I distributed the final software to Win7 machines, I was watching the callback called twice every time.

Here is my point:

// Callback scanner COM function
void BarcodeScanner(int scannerPortNumber, int eventMask, void *callbackdata)
{
    // re-init the output buffer
    memset(scannerData,0,SCANNER_MAX_BYTES);

    // go get the buffer
    ComRdTerm(scannerPortNumber,scannerData,SCANNER_MAX_BYTES,SCANNER_EOS);

    // raise the data flag
    scannerDataFlag = TRUE;

    // empty the buffer
    FlushInQ(scannerPortNumber);
}

And here's my use of InstallComCallback():

void InitScannerComm(void)
{
    int notifyCount = SCANNER_MIN_BYTES;
    int eventChar = SCANNER_EOS;    // terminator charactor
    //int eventMask = LWRS_RXFLAG | LWRS_RECEIVE;   // callback event won't happen unless the eventChar is received after notifyCount characters
    int eventMask = LWRS_RXFLAG;    // TODO: the InstallComCallback() function seems to be calling the callback twice each time, even though I get a verified buffer of only N number of bytes

    int dataBits = SCANNER_DATABITS;
    int stopBits = SCANNER_STOPBITS;
    int inputQueueSize = SCANNER_MAX_BYTES;
    int parity = SCANNER_PARITY;

    int comportRing = 0;
    int i;

    // close port if it's already open:
    CloseCom(scannerPortNumber);

    // open COM port one time
    OpenComConfig(scannerPortNumber,scannerDeviceName,scannerBaudRate,parity,dataBits,stopBits,inputQueueSize,-1);

    // Make sure Serial buffers are empty
    FlushInQ(scannerPortNumber);
    FlushOutQ(scannerPortNumber);

    // look up how many COM options there are in the control
    GetNumListItems(tabPage2Handle,TABPANEL2_COMPORT,&comportRing);

    // set up callback function for COM
    for (i=1; i<=comportRing; i++)
    {
        if (i != scannerPortNumber)
            // disable all the other callbacks
            InstallComCallback(i, 0, notifyCount, eventChar, BarcodeScanner, NULL);
        else
            // enable the port that's been selected
            InstallComCallback(i, eventMask, notifyCount, eventChar, BarcodeScanner, NULL);
    }
}

A little background... the device sends traffic COM is a Motorola/Symbol bar code scanner.  I put it in place in a virtual COM mode.  Use RealTerm hexadecimal display mode, I can confirm that this material is set up correctly, i.e. it sends what it should be (a string in the form: '012345' with a CR at the end).

And I know that the string is correct because the callback is called.  The strange thing is that in onlyWin7, the callback is called two times, and then it's done.  The second time, the string is all NULL values.

My fix was to remove the LWRS_RECEIVE option in the eventMask (i.e. remove the notifyCount threshold).  Phew!

Is this a bug?

At this stage, it is difficult to say. We saw a few COM port behavior problems during the comparison between XP and 7. So that we can verify that this is a bug, we need to be able to reproduce this on our end. If you could think of a way for us to reproduce this behavior without your hardware (scanner), then we would be happy to test this on and file a corrective measure asks the R & D review. We appreciate your time to post or forums and make a note of what this can happen to other developers and at least they can watch to your workaround for a working solution.

Tags: NI Software

Similar Questions

Maybe you are looking for

  • Since updates to firefox, it is not possible to add a document to my email c Telfort.nl

    Since one of the most recent updates to firefox, it is not possible to add a document to my email address is Telfort.nlI checked with Telfort and no problems of this type are known.

  • Windows Firefox keeps jumping up and down.

    I downloaded the latest version of Firefox, but I have a slight problem. Everytime I open Firefox it jumps up and down. How can I stop it? This has happened Each time Firefox opened == Earlier, I downloaded the latest version of firefox 3.6.6

  • How to create a backup on DVD - R,

    I tried, but it took too long. HP Pavilion DV6-6145dx, Windows 7 64 bit.

  • update security for Windows XP

    I use to install update security for Windows xp KB9811349, but their still another day KB956802, KB979683 KB970238, KB978338, what should I do for this new upcoming update KB numbers are lower than the 1st one i rescently installed

  • HP M251nw

    I tried to configure an ePrint. When I want to create an account, after that the printer print the installation instructions and I followed him to click on 'do not have an account, create an account', the page is returned to "Welcome!" Unleash the po