InstallComCallback

Hello

I'm sorry if this question has already been asked but I'm trying to decotiquer a piece of encoder written on CVI and there are a few concepts that venture. Also I wonder the quetsion about the role of the function "InstallComCallback". D 'after I realized it allows d' access to the serial port, it that right?

Thanks in advance for your answer.

Sincerely,

Tok

Well, it's not easy to describe a situation in which it is better than the other methods. I can tell you that when InstallComCallback can be easily used instead.

Assuming that you have variable length messages and different message endpoint (for example because you are addressing different instruments) or no ending at all, you cannot implement reception through a com callback esily It could be done to intercept each ane uniqueness queues upward to reinforce the message, but it is: is your situation is worth it?

In addition, InstallComCallback introduced a degree of complexity, because the answer is performed asynchronously in a separate writing, a reminder if you need to synchronize the two functions any.

Tags: NI Software

Similar Questions

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

  • Installcomcallback - manage dynamic configurations

    Hi all I'm new with CVI and I have a simple question: I need to retrieve data of a rs232 line and I know in advance the exact size of the message that I expect. I have no particular character to look for trigger recall. Recalling every time that the function InstallComCallback that provide different notifyCount parameter is the correct procedure? It is also necessary to prescribe an eventChar and why?

    Thank you

    Mattia

    Hi Mattia,

    you could have a look at the example that you can find on this link.

    Best regards

    Serena

  • Change will warn County instead of doing installcomcallback every time...

    Hi all

    I do RS232 communication.

    My number of notify changes every time to receive the next package of ComRd().

    So far, I have "lived comcallback whenever for the next package to come".

    But install comcallback every time that slows down communication.

    I'm so not only installed a single comcallback but as number of notify is fix then,

    I read some time less or more (valid) data of ComRd.

    That's why I need to only change the number to notify for package instead of install new comcallback every time.

    Please give me suggestions.

    Same API Win solution will help...

    That seems like a replica of another discussion: see my response here

  • ComCallback works only with several .c files

    Hello

    I have a project using multiple .c files that require the use of a ComCallback.  The ComCallback works very well under the "first.c" where the reminder, but once the program runs under functions in the "second.c", the recall does not work when appropriate triggers are received on the serial port.

    A call to ProcessSystemsEvents() will allow the ComCallback to work, is not the ideal solution but I would need to call it repeatedly throughout the entire project.

    "first.c"

    void COMCallback (int portNumber, int eventMask, void * callbackdata) {}

    If (eventMask & LWRS_RXFLAG) {}
    Process tips
    }
    }

    int une_fonction (void) {}

    Open and config COM
    If (OpenComConfig (comNum, "", 19200, 0, 8, 1, 512, 512)) {}
    COMerror();
    Returns - 1;
    }
    CTS/RTS set
    If (SetCTSMode (comNum, LWRS_HWHANDSHAKE_CTS_RTS)) {}
    COMerror();
    Returns - 1;
    }
    Set timeout COM
    If (SetComTime (comNum, 5.0)) {}
    COMerror();
    Returns - 1;
    }
        
    FlushInQ (comNum);
    FlushOutQ (comNum);

    InstallComCallback (comNum, LWRS_RXFLAG, 0, 0 x 07, COMCallback, NULL);

    Call a function under 'second.c '.

    }

    I think I found the problem.  My reminder called a function (under //Process stuff) in order to process the serial data.  I eliminated the function and placed the code in the callback.  This seems to have changed priorities and solved the problem.

  • interruptions and serial Comms

    I collect data from a number of devices using RS485.

    Data collection is initiated by a request message sent from the PC to the device and a message is displayed.

    I need "divorce" the transformation data collection, and to this end, I tried using multithreading.

    It works to a certain extent, but the change of context seems to take too long.

    Data throughput is 115kBaud, messages are ~ 8 bytes for the request and ~ 30 bytes for the answer.

    There are up to 32 devices, and I need to acquire every 5 times per second.

    (This is equivalent to 5 * 32 * (8 + 30) = 6080 bytes 60800 bits every second.)

    This is feasible at a baud rate of 115 k baud rate, with about 53% of the use of the communication channels).

    To make this work correctly, I need to be able to "hang" for interrupts generated by the device drivers for transmit them and receive so that the passage of shipment to receive can be achieved with minimum latency.

    Maintenance of data for to transmit them and receive would not take too long, even if done on each of the characters.

    Is this possible without the need to write a device driver?

    If Yes, how would you please.

    I didn't program anything in RS485, but have you tried the function for InstallComCallback?  There you can set different reminders for the different characters received.

Maybe you are looking for