[dss-developer] DS485 API: response callbacks don't fire

Dimitri Janssens Dimitri.Janssens at sioux.eu
Thu May 30 12:55:10 CEST 2013


Hi all

I ran into some problems while implementing an asynchronous interface towards the ds485 stack.
First I register some callbacks.
When they all return OK, I start scanning the bus for available devices.

Some problems using the following example code:
- the localBusStateCallback is used.
- the localZoneDeviceCountAll is not used, yet I always receive synchronous answers (log sattements)
- localDeviceInfoByIndex is not used, yet I always receive synchronous answers (log statements)

Does anybody have some more experience with the asynchronous calls?

EXAMPLE CODE:
OneStatus_t localRegisterCallbacks(void)
{
    DsmApiCallback_t cbStruct;
    cbStruct.arg = NULL;
    cbStruct.function = (void*)&localBusStateCallback;
    if(DsmApiSetBusStateCallback(apiHandle, &cbStruct) != ERROR_OK)
    {
        TRACE;
        return One_Failure;
    }

    cbStruct.arg = NULL;
    cbStruct.function = (void*)&localZoneDeviceCountAll;
    if(DsmApiSetCallback(apiHandle, DS485_CONTAINER_RESPONSE, ZONE_DEVICE_COUNT, ZONE_DEVICE_COUNT_ALL, &cbStruct) != ERROR_OK)
    {
        TRACE;
        return One_Failure;
    }

    cbStruct.arg = NULL;
    cbStruct.function = (void*)&localDeviceInfoByIndex;
    if(DsmApiSetCallback(apiHandle, DS485_CONTAINER_RESPONSE, DEVICE_INFO, DEVICE_INFO_BY_INDEX, &cbStruct) != ERROR_OK)
    {
        TRACE;
        return One_Failure;
    }

    LOG("ds485 callbacks are registered.\n");
    return One_Success;
}

OneStatus_t localScanBus(void)
{
    OneStatus_t status = One_Failure;

    uint8_t result;
    dsid_t members[DS_MAX_CIRCUITS];

    if((result = DsmApiGetBusMembers(apiHandle, members, DS_MAX_CIRCUITS)) > 0)
    {
        // filter out the meters
        for(uint8_t i = 0; i < result; ++i)
        {
            if(DsmApiIsdSM(members[i]))
            {
                uint16_t numberOfDevices;
                // USE ZONEID 0 = BROADCAST TO ALL ZONES
                if(ZoneDeviceCount_all(apiHandle, members[i], 0, &numberOfDevices) == ERROR_OK)
                {
                    LOG("Requesting ZoneDeviceCount_all\n");
                    LOG("Devices found: %d\n", numberOfDevices);
                    for(uint16_t index = 0; index < numberOfDevices; ++index)
                    {
                        uint16_t deviceId;
                        if(DeviceInfo_by_index(apiHandle, members[i], 0, index, &deviceId, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_OK)
                        {
                            LOG("DevicesInfo for device: %d\n", deviceId);
                            status = One_Success;
                        }
                    }
                }
            }
        }
    }

    return status;
}



ing. Dimitri Janssens

software engineer

___________________________________________________________


Sioux. Source of your Technology

Technical Software | Electronics | Industrial Mathematics | Remote Solutions



Sioux Embedded Systems N.V. |  Welvaartstraat 14-1 bus 5 |  B-2200 Herentals |  Franklin Rooseveltlaan 348-349 | B-9000 Gent | Belgium

BE 0470.946.282 - RPR Turnhout | T +32 (0)14 84.87.18 |  F  +32 (0)14 84.87.19 |  dimitri.janssens at sioux.eu<mailto:dimitri.janssens at sioux.eu> |  www.sioux.eu<http://www.sioux.eu/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://forum.digitalstrom.org/pipermail/dss-developer/attachments/20130530/fdc8e0fd/attachment.html>


More information about the dss-developer mailing list