Menu

h_cov.c - Issue in the line invoke_id = tsm_next_free_invokeID() in cov_send_request()

2023-03-12
2023-04-21
  • kishore venki

    kishore venki - 2023-03-12

    We have ported the stack suitable for (B-SA) in PICS32 micro controller. We are facing issue of Controller not sending confirmed COV Notifcation when they are triggered. After a bit of analysis we noticed that the following code in the file h_cov.c under the function cov_send_request() is not getting executed:
    if (invoke_id) {
    cov_subscription->invokeID = invoke_id;
    len = ccov_notify_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
    sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id,
    &cov_data);

    Is it because tsm_next_free_invokeID() is not returning invokeID?
    Please help to resolve the issue.

    Thanks & Regards,
    Kishore

     
    • Steve Karg

      Steve Karg - 2023-03-12

      The example handler for COV should be using a transaction from the TSM pool, and then freeing it when the transaction is sent (for confirmed COV, not for unconfirmed COV). Without reviewing the code in question, and the version of the stack, it's not possible to know why ConfirmedCOV notififications are not being sent.
      Are you defining MAX_TSM_TRANSACTIONS=1 (or more) in your build?

       
  • kishore venki

    kishore venki - 2023-03-13

    MAX_TSM_TRANSACTIONS=5

     
  • kishore venki

    kishore venki - 2023-03-13

    Steve,
    After looking at your comments, we noticed that we never call the following code in our application
    handler_cov_timer_seconds(elapsed_seconds),
    tsm_timer_milliseconds(elapsed_milliseconds);

    Though without the above two lines, ucov notification works. Is the problem related to the absence of the above two lines?

    In the demo like server, these lines are present in main function. But our application is a bit complex having bluetooth connectivity running and other IP related application running along with BACnet. In that case based on your experience please suggest where could these timer related lines be placed for the right behavior?

    Thanks,
    Kishore

     
  • kishore venki

    kishore venki - 2023-03-13

    The lifetime parameters also did not change.

     
  • Steve Karg

    Steve Karg - 2023-03-13

    Here is a snippet from a product using COV:

    void bacnet_init(
        void)
    {
    ...
        /* initialize the time base for DCC */
        timer_interval_start_seconds(&DCC_Timer, 1);
        /* start the cyclic 1 second timer for COV */
        timer_interval_start_seconds(&COV_Timer, 1);
        /* start the cyclic 1 second timer for TSM */
        timer_interval_start_seconds(&TSM_Timer, 1);
    }
    
    void bacnet_task(
        void)
    {
    ...
        /* handle the timers */
        if (timer_interval_expired(&DCC_Timer)) {
            timer_interval_reset(&DCC_Timer);
            dcc_timer_seconds(timer_interval_seconds(&DCC_Timer));
        }
        if (timer_interval_expired(&COV_Timer)) {
            timer_interval_reset(&COV_Timer);
            if (dcc_communication_enabled()) {
                handler_cov_timer_seconds(timer_interval(&COV_Timer) / 1000);
            }
        }
        if (timer_interval_expired(&TSM_Timer)) {
            timer_interval_reset(&TSM_Timer);
    #if MAX_TSM_TRANSACTIONS
            tsm_timer_milliseconds(timer_interval(&TSM_Timer));
    #endif
        }
        handler_cov_task();
    ...
    }
    
     
  • kishore venki

    kishore venki - 2023-04-17

    Hi Steve,

    Thanks for your timely help and valuable information. I am sorry that I did not respond to you on time. With the above code, COV worked.

    Only thing I noticed now is while responding for the Active_COV_Subscriptions, the port is reversed. That is instead of BA C0, the response has C0 BA. I am looking at the code to fix.

    Thanks once again.
    Kishore

     
    • Steve Karg

      Steve Karg - 2023-04-20

      The BACnet dest address used in COV notifications is copied from src address which comes from whatever module is being used for incoming datalink handler and passed to the npdu_handler() and apdu_handler() and then handler_cov_subscribe() function. Are you using BACnet/IP or MSTP or some other datalink?

       
  • kishore venki

    kishore venki - 2023-04-20

    Hi,
    Please advise how to fix the swapping of MSB and LSB of BACnet Port in the response for Active COV Subscriptions.

    Thanks ....

     
  • kishore venki

    kishore venki - 2023-04-21

    BACnet/IP

     

Log in to post a comment.