First of all, I apologize for this lengthy post but I wanted to include as many details as possible to give a better picture of the issue I am running into. I am using files from the generic project provided by Anybus. I am using the configurations for ADI as shown in the attached code snippet.
Class: Assembly (0x04)
Service: 0x0E - Get Attribute Single
Instance: Producing (0x64)
Attribute: Data (3)
Class: Assembly (0x04)
Service: 0x0E - Get Attribute Single
Instance: Consuming (0x096)
Attribute: Data (3)
const AD_AdiEntryType APPL_asAdiEntryList[] =
{
{513, "SetpointCurr", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, {{NULL, NULL}}, NULL, SetAdiValueCbf}, // register 0x3010
{514, "SetpointCurrQ", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, {{NULL, NULL}}, GetAdiValueCbf, NULL}, // register 0x3020
{515, "SetpointVolt", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, {{NULL, NULL}}, NULL, SetAdiValueCbf}, // register 0x3030
}
const AD_MapType APPL_asAsmObjWriteMap1[] =
{
{514, PD_WRITE, AD_MAP_ALL_ELEM , 0 },
{ AD_MAP_END_ENTRY }
};
const AD_MapType APPL_asAsmObjReadMap1[] =
{
{513, PD_READ, AD_MAP_ALL_ELEM , 0 },
{515, PD_READ, AD_MAP_ALL_ELEM , 0 },
{ AD_MAP_END_ENTRY }
};
const AD_MapType APPL_asAdObjDefaultMap[] =
{
{513, PD_READ, AD_MAP_ALL_ELEM , 0 },
{515, PD_READ, AD_MAP_ALL_ELEM , 0 },
{514, PD_WRITE, AD_MAP_ALL_ELEM , 0 },
{ AD_MAP_END_ENTRY }
};
const ASM_InstanceType APPL_sAsmWriteMapInst1 =
{
ABP_ASM_IA_DESC_WRITE | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
APPL_asAsmObjWriteMap1
};
const ASM_InstanceType APPL_sAsmReadMapInst1 =
{
ABP_ASM_IA_DESC_READ | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
APPL_asAsmObjReadMap1
};
const ASM_InstanceType* APPL_aasAsmInstances[] =
{
&APPL_sAsmWriteMapInst1, /* Instance 1 */
&APPL_sAsmReadMapInst1, /* Instance 2 */
};
/* following macros are also enabled in their respective header files */
#define ASM_OBJ_ENABLE TRUE
#define EIP_IA_PROD_INSTANCE_ENABLE TRUE
#define EIP_IA_CONS_INSTANCE_ENABLE TRUE
#define ABCC_CFG_REMAP_SUPPORT_ENABLED TRUE
#define ASM_IA_NAME_ENABLE TRUE
#define EIP_IA_ENABLE_PARAM_OBJECT_ENABLE TRUE
Adding the ADI instance to the default AD Object Map brings up the correct ad_WriteMapInfo and ad_ReadMapInfo structs with correct iPDSize (process data size) and bNumElements.
While adding the ADI Instances to Write/Read Maps and inturn to assembly mapping instances triggers a RemapProcessDataCommand() from the ABCC_CbfReceiveMsg() sent by Anybus device. This remap command overwrites the iPDSize and bNumElements to zero, thereby causing the Write Assembly command(Get Attribute Single, Class: Assembly(0x04), Instance(0x64), Attribute(3)) to corrupt. I get garbage results after each query. Read Assembly commands work all good.
Based on the datasheet, when I put a breakpoint on the Remap Process Data command I get the data as shown in the following screenshot
During the initialization phase, in the NW_INIT state, all write assemblies (e.g. the instances of the assembly mapping object with type“write”) will be remapped to the write process data area. For this to happen, the device will issue the Remap_ADI_Write_Area command to the application data object in the host.
case ABP_APPD_REMAP_ADI_WRITE_AREA:
RemapProcessDataCommand( psMsgBuffer, &ad_WriteMapInfo );
break;
Decoding above data shows:
- CmdExt[0…1] = 0, Start remap from mapping item 0
- Data[0…1] = 1, Remove 1 mapping item
- Data[2…3] = 1, Insert 1 mapping item
- Data[4…5] = 514, New mapping item 1: Instance no. #514
- Data[6] = 0, New mapping item 1: Map from element 0
- Data[7] = 0, New mapping item 1: Map 0 elements ???
The command ends up corrupting the iPDSize for ad_WrtieMapInfo and thus giving me erroneous results when trying to access producing instances.
Accessing the individual ADI using the ADI Object works too without any errors:
Class: ADI Object (A2h)
Service: 0x0E - Get Attribute Single
Instance: 514
Attribute: Data (5)
Is there anything else that I am missing on my side that’s causing the above-mentioned issue? Also, no command is issued from the network when the iPDSIze/bNumElements of the Map is overwritten.