CBus Libraries (Time)

Discussion in 'C-Bus Serial Protocols' started by pspeirs, Sep 9, 2020.

  1. pspeirs

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    146
    Likes Received:
    5
    Location:
    Sydney
    Hi All,

    I'm after some information about the cbus libraries and getting the current cbus time.

    I am finding that after initialisation, it takes around 1 minute to get a valid cbus time returned. Is this normal as I would expect that once the cbus connection is successful the correct time should be immediately availablle. Is there a configuration in one of the header files that sets a delay or something else I'm missing.

    Snippet is basically as per below . . .

    Code:
                    
    if (cbus_ef_get_connect_state() == cbus_ce_module_normal_operation) {
    
                        cbus_time_vf_get_time(&cbus_time);
                        cbus_time_valid = (cbus_time.year > 2010) ? 1 : 0;
    
    
    . . .
    
    

    Cheers,

    Paul
     
    pspeirs, Sep 9, 2020
    #1
    1. Advertisements

  2. pspeirs

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    348
    Likes Received:
    44
    Location:
    Perth
    What is the device that is providing the time?

    Wiser2 takes about 90secs after its powered on to get its time sync from the internet time servers and then pass it out to the CBUS network.
     
    chromus, Sep 10, 2020
    #2
    1. Advertisements

  3. pspeirs

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    146
    Likes Received:
    5
    Location:
    Sydney
    I'm using the SHAC for timesource, this unit however does not get restarted, so the current time should be available already on the network.

    My issue is when I use the library call above to get the current time, it takes around a minute to return. It should respond with the correct time straight away in this scenario. I might as well write the ntp client to grab the time directly from the internet if this can't be resolved.
     
    pspeirs, Sep 10, 2020
    #3
  4. pspeirs

    chromus

    Joined:
    Jan 27, 2014
    Messages:
    348
    Likes Received:
    44
    Location:
    Perth
    Have you had a look at network load? it could be that your request is getting queued behind other traffic like temps and other things.

    What device is requesting/receiving the time data?
     
    chromus, Sep 10, 2020
    #4
  5. pspeirs

    pspeirs

    Joined:
    Nov 23, 2013
    Messages:
    146
    Likes Received:
    5
    Location:
    Sydney
    No, it isn't an issue with load, etc. Managed to solve it however . . .

    there is a function that can be called immediately after the cbus connection returns its first successful connection which will request a refresh as below:

    Code:
    if (cbus_status == cbus_first_connect) {
    
                // Once we get a first time connection, send refresh request
                cbus_time_vf_send_request_refresh();
    
                current_cbus.pci_serial_string = cbus_pf_get_PCI_serial_string();
                current_cbus.pci_unit_address = cbus_if_get_PCI_unit_address();
                current_cbus.pci_version = cbus_cf_get_PCI_version();
    
         ...
    
    }
    Additionally, registering the event handler below will enable time changes to be caught.

    Code:
    void cbus_time_vf_register_handler(void (*f)(cbus_boolean, cbus_time_st_time_type *, cbus_time_st_time_type *));
     
    pspeirs, Sep 10, 2020
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.