<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div style="direction: ltr;font-family: Arial;color: #000000;font-size: 10pt;">Hi all<br>
<br>
I ran into some problems while implementing an asynchronous interface towards the ds485 stack.<br>
First I register some callbacks.<br>
When they all return OK, I start scanning the bus for available devices.<br>
<br>
Some problems using the following example code:<br>
- the localBusStateCallback is used.<br>
- the localZoneDeviceCountAll is not used, yet I always receive synchronous answers (log sattements)<br>
- localDeviceInfoByIndex is not used, yet I always receive synchronous answers (log statements)<br>
<br>
Does anybody have some more experience with the asynchronous calls?<br>
<br>
EXAMPLE CODE:<br>
OneStatus_t localRegisterCallbacks(void)<br>
{<br>
    DsmApiCallback_t cbStruct;<br>
    cbStruct.arg = NULL;<br>
    cbStruct.function = (void*)&localBusStateCallback;<br>
    if(DsmApiSetBusStateCallback(apiHandle, &cbStruct) != ERROR_OK)<br>
    {<br>
        TRACE;<br>
        return One_Failure;<br>
    }<br>
<br>
    cbStruct.arg = NULL;<br>
    cbStruct.function = (void*)&localZoneDeviceCountAll;<br>
    if(DsmApiSetCallback(apiHandle, DS485_CONTAINER_RESPONSE, ZONE_DEVICE_COUNT, ZONE_DEVICE_COUNT_ALL, &cbStruct) != ERROR_OK)<br>
    {<br>
        TRACE;<br>
        return One_Failure;<br>
    }<br>
<br>
    cbStruct.arg = NULL;<br>
    cbStruct.function = (void*)&localDeviceInfoByIndex;<br>
    if(DsmApiSetCallback(apiHandle, DS485_CONTAINER_RESPONSE, DEVICE_INFO, DEVICE_INFO_BY_INDEX, &cbStruct) != ERROR_OK)<br>
    {<br>
        TRACE;<br>
        return One_Failure;<br>
    }<br>
<br>
    LOG("ds485 callbacks are registered.\n");<br>
    return One_Success;<br>
}<br>
<br>
OneStatus_t localScanBus(void)<br>
{<br>
    OneStatus_t status = One_Failure;<br>
<br>
    uint8_t result;<br>
    dsid_t members[DS_MAX_CIRCUITS];<br>
<br>
    if((result = DsmApiGetBusMembers(apiHandle, members, DS_MAX_CIRCUITS)) > 0)<br>
    {<br>
        // filter out the meters<br>
        for(uint8_t i = 0; i < result; ++i)<br>
        {<br>
            if(DsmApiIsdSM(members[i]))<br>
            {<br>
                uint16_t numberOfDevices;<br>
                // USE ZONEID 0 = BROADCAST TO ALL ZONES<br>
                if(ZoneDeviceCount_all(apiHandle, members[i], 0, &numberOfDevices) == ERROR_OK)<br>
                {<br>
                    LOG("Requesting ZoneDeviceCount_all\n");<br>
                    LOG("Devices found: %d\n", numberOfDevices);<br>
                    for(uint16_t index = 0; index < numberOfDevices; ++index)<br>
                    {<br>
                        uint16_t deviceId;<br>
                        if(DeviceInfo_by_index(apiHandle, members[i], 0, index, &deviceId, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_OK)<br>
                        {<br>
                            LOG("DevicesInfo for device: %d\n", deviceId);<br>
                            status = One_Success;<br>
                        }<br>
                    }<br>
                }<br>
            }<br>
        }<br>
    }<br>
<br>
    return status;<br>
}<br>
<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<p style="margin:0px"><b><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">ing. Dimitri Janssens</span></b></p>
<p style="margin:0px"><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">software engineer</span></p>
<p style="margin:0px"><u><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">___________________________________________________________</span></u></p>
<p style="margin:0px"><u><span style="font-size:9pt; font-family:Arial,sans-serif" lang="EN-US"><span style="text-decoration:none"><br>
</span></span></u></p>
<p style="margin:0px"><b><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">Sioux.</span></b><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US"> Source of your Technology</span></p>
<p style="margin:0px"><span style="font-size: 9pt; font-family: Arial, sans-serif; color: rgb(255, 102, 0); " lang="EN-US">Technical Software | Electronics | Industrial Mathematics | Remote Solutions</span><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US"></span></p>
<p style="margin:0px"><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US"> </span></p>
<p style="margin:0px"><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">Sioux Embedded Systems N.V. |  Welvaartstraat 14-1 bus 5 |  B-2200 Herentals | 
</span><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US"><span style="font-size: 9pt; font-family: Arial, sans-serif; ">Franklin Rooseveltlaan 348-349 | B-9000 Gent |
</span>Belgium</span></p>
<p style="margin:0px"><span style="font-size: 9pt; font-family: Arial, sans-serif; " lang="EN-US">BE 0470.946.282 - RPR Turnhout | T <a tabindex="0" value="+3214848718" style="color:rgb(17,85,204)">+32 (0)14 84.87.18</a> |  F  <a tabindex="0" value="+3214848719" style="color:rgb(17,85,204)">+32
 (0)14 84.87.19</a> |  <a target="_blank" href="mailto:dimitri.janssens@sioux.eu" tabindex="0" style="color:rgb(17,85,204)"><span style="color:blue">dimitri.janssens@sioux.eu</span></a> |  </span><span style="font-size:9pt; font-family:Arial,sans-serif" lang="NL"><a target="_blank" href="http://www.sioux.eu/" tabindex="0" style="color:rgb(17,85,204)"><span style="color:blue" lang="EN-US">www.sioux.eu</span></a></span></p>
<p><br>
</p>
</div>
</div>
</div>
</div>
</body>
</html>