Commit fbed44eb authored by claes's avatar claes

Bugfix in Max_User_Prm_Data_Len

parent 31a7532f
...@@ -6,3 +6,4 @@ ...@@ -6,3 +6,4 @@
070207 rk - Adapted I/O routines to work with new driver for Softing Profiboard. 070207 rk - Adapted I/O routines to work with new driver for Softing Profiboard.
Incorporated driver API from Softing to work with new Softing driver. Incorporated driver API from Softing to work with new Softing driver.
Added diagnostics infomation to pwr_sClass_Pb_DP_Slave-class. Added diagnostics infomation to pwr_sClass_Pb_DP_Slave-class.
070209 cs - Bugfix in Ext_User_Prm_Data_Len.
\ No newline at end of file
/* /*
* Proview $Id: rt_pb_gsd.cpp,v 1.4 2006-07-25 11:01:19 claes Exp $ * Proview $Id: rt_pb_gsd.cpp,v 1.5 2007-02-09 10:26:25 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -1027,13 +1027,22 @@ int pb_gsd::build() ...@@ -1027,13 +1027,22 @@ int pb_gsd::build()
printf( "** Referenced ExtUserPrmData not found %d\n", ep->Reference_Number); printf( "** Referenced ExtUserPrmData not found %d\n", ep->Reference_Number);
} }
} }
if ( max_user_prm_data_len) {
if ( max_user_prm_data_len <
extuserprmdataconst->len + extuserprmdataconst->Const_Offset)
printf( "ExtUserPrmDataConst exceeds Max_User_Prm_Data_Len, line %d\n", line_cnt);
}
else
max_user_prm_data_len = extuserprmdataconst->len + extuserprmdataconst->Const_Offset;
// Check Module UserPrmDataLen // Check Module UserPrmDataLen
for ( gsd_sModule *mp = modulelist; mp; mp = mp->next) { for ( gsd_sModule *mp = modulelist; mp; mp = mp->next) {
if ( mp->Ext_Module_Prm_Data_Len == 0 && mp->extuserprmdataconst) if ( mp->Ext_Module_Prm_Data_Len == 0 && mp->extuserprmdataconst)
mp->Ext_Module_Prm_Data_Len = mp->extuserprmdataconst->len; mp->Ext_Module_Prm_Data_Len = mp->extuserprmdataconst->len +
mp->extuserprmdataconst->Const_Offset;
else if ( mp->extuserprmdataconst && else if ( mp->extuserprmdataconst &&
mp->Ext_Module_Prm_Data_Len != mp->extuserprmdataconst->len) { mp->Ext_Module_Prm_Data_Len <
mp->extuserprmdataconst->len + mp->extuserprmdataconst->Const_Offset) {
printf( "** ExtUserPrmDataLen differs (%d) (%d), Module %s\n", mp->Ext_Module_Prm_Data_Len, printf( "** ExtUserPrmDataLen differs (%d) (%d), Module %s\n", mp->Ext_Module_Prm_Data_Len,
mp->extuserprmdataconst->len, mp->Mod_Name); mp->extuserprmdataconst->len, mp->Mod_Name);
} }
...@@ -1998,12 +2007,12 @@ void pb_gsd::pack_ext_user_prm_data( char *data, int *len) ...@@ -1998,12 +2007,12 @@ void pb_gsd::pack_ext_user_prm_data( char *data, int *len)
prm_items_to_data( prm_dataitems, prm_dataitems_cnt, prm_items_to_data( prm_dataitems, prm_dataitems_cnt,
extuserprmdataconst->Const_Prm_Data, extuserprmdataconst->Const_Prm_Data,
extuserprmdataconst->len); max_user_prm_data_len);
data_idx = 0; data_idx = 0;
memcpy( &data[data_idx], extuserprmdataconst->Const_Prm_Data, memcpy( &data[data_idx], extuserprmdataconst->Const_Prm_Data,
extuserprmdataconst->len); max_user_prm_data_len);
data_idx += extuserprmdataconst->len; data_idx += max_user_prm_data_len;
for ( i = 0; i < module_conf_cnt; i++) { for ( i = 0; i < module_conf_cnt; i++) {
if ( !module_conf[i].module || !module_conf[i].module->extuserprmdataconst) if ( !module_conf[i].module || !module_conf[i].module->extuserprmdataconst)
...@@ -2011,11 +2020,10 @@ void pb_gsd::pack_ext_user_prm_data( char *data, int *len) ...@@ -2011,11 +2020,10 @@ void pb_gsd::pack_ext_user_prm_data( char *data, int *len)
prm_items_to_data( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt, prm_items_to_data( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt,
module_conf[i].prm_data, module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len); module_conf[i].module->Ext_Module_Prm_Data_Len);
memcpy( &data[data_idx], module_conf[i].prm_data, memcpy( &data[data_idx], module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len); module_conf[i].module->Ext_Module_Prm_Data_Len);
data_idx += module_conf[i].module->extuserprmdataconst->len; data_idx += module_conf[i].module->Ext_Module_Prm_Data_Len;
} }
*len = data_idx; *len = data_idx;
} }
...@@ -2027,24 +2035,24 @@ int pb_gsd::unpack_ext_user_prm_data( char *data, int len) ...@@ -2027,24 +2035,24 @@ int pb_gsd::unpack_ext_user_prm_data( char *data, int len)
data_idx = 0; data_idx = 0;
memcpy( extuserprmdataconst->Const_Prm_Data, &data[data_idx], memcpy( extuserprmdataconst->Const_Prm_Data, &data[data_idx],
extuserprmdataconst->len); max_user_prm_data_len);
data_idx += extuserprmdataconst->len; data_idx += max_user_prm_data_len;
prm_data_to_items( prm_dataitems, prm_dataitems_cnt, prm_data_to_items( prm_dataitems, prm_dataitems_cnt,
extuserprmdataconst->Const_Prm_Data, extuserprmdataconst->Const_Prm_Data,
extuserprmdataconst->len); max_user_prm_data_len);
for ( i = 0; i < module_conf_cnt; i++) { for ( i = 0; i < module_conf_cnt; i++) {
if ( !module_conf[i].module || !module_conf[i].module->extuserprmdataconst) if ( !module_conf[i].module || !module_conf[i].module->extuserprmdataconst)
continue; continue;
memcpy( module_conf[i].prm_data, &data[data_idx], memcpy( module_conf[i].prm_data, &data[data_idx],
module_conf[i].module->extuserprmdataconst->len); module_conf[i].module->Ext_Module_Prm_Data_Len);
data_idx += module_conf[i].module->extuserprmdataconst->len; data_idx += module_conf[i].module->Ext_Module_Prm_Data_Len;
prm_data_to_items( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt, prm_data_to_items( module_conf[i].prm_dataitems, module_conf[i].prm_dataitems_cnt,
module_conf[i].prm_data, module_conf[i].prm_data,
module_conf[i].module->extuserprmdataconst->len); module_conf[i].module->Ext_Module_Prm_Data_Len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment