Commit e346db0a authored by Marcus Nordenberg's avatar Marcus Nordenberg

Merge branch 'profinet configurator fixes'

parents 7c3237ad 4d8d02a1
This diff is collapsed.
......@@ -282,7 +282,10 @@ void GsdmlAttr::activate_cmd_ca()
}
}
GsdmlAttr::~GsdmlAttr() {}
GsdmlAttr::~GsdmlAttr() {
if (wow)
delete wow;
}
GsdmlAttr::GsdmlAttr(void* a_parent_ctx, void* a_object, pn_gsdml* a_gsdml,
int a_edit_mode, const char* a_data_filename)
......
......@@ -1471,13 +1471,21 @@ int GsdmlAttrNav::save(const char* filename)
(char*)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]
->Body.Name.p,
sizeof(cd->name));
//Make sure we null terminate these in case our buffer is too small to accomodate the entire diag name string.
cd->name[sizeof(cd->name) - 1] = '\0';
if (gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]
->Body.Help.p)
strncpy(cd->help,
(char*)gsdml->ApplicationProcess->ChannelDiagList
->ChannelDiagItem[i]
->Body.Help.p,
sizeof(cd->help));
{
strncpy(cd->help,
(char*)gsdml->ApplicationProcess->ChannelDiagList
->ChannelDiagItem[i]
->Body.Help.p,
sizeof(cd->help));
//Make sure we null terminate these in case our buffer is too small to accomodate the entire help string.
cd->help[sizeof(cd->help) - 1] = '\0';
}
dev_data.channel_diag.push_back(cd);
}
}
......
......@@ -62,8 +62,8 @@ GsdmlSlotData* GsdmlDeviceData::paste_slotdata = 0;
GsdmlChannelDiag::GsdmlChannelDiag() : error_type(0)
{
strcpy(name, "");
strcpy(help, "");
memset(name, 0, sizeof(name));
memset(help, 0, sizeof(help));
}
int GsdmlChannelDiag::print(std::ofstream& fp)
......@@ -89,9 +89,18 @@ GsdmlDataRecord::GsdmlDataRecord(const GsdmlDataRecord& x)
int GsdmlDataRecord::print(std::ofstream& fp, bool reverse_endianess)
{
char str[1024];
unsigned char* data;
unsigned char* data =
(reverse_endianess ? this->data_reversed_endianess : this->data);
// If we have allocated memory for reversed endianess we come from the pn configurator otherwise we use the data as is.
// The method SetIoDeviceData for instance reads the raw data and then recreates the pn configuration file.
if (data_reversed_endianess)
{
data = (reverse_endianess ? this->data_reversed_endianess : this->data);
}
else
{
data = this->data;
}
co_xml_parser::data_to_ostring(data, data_length, str, sizeof(str));
......
......@@ -63,6 +63,8 @@ public:
{
if (data)
free(data);
if (data_reversed_endianess)
free(data_reversed_endianess);
}
GsdmlDataRecord(const GsdmlDataRecord& x);
......@@ -170,7 +172,7 @@ public:
GsdmlChannelDiag();
unsigned short error_type;
char name[200];
char help[256];
char help[4096]; // We need a large buffer for most of the help text in the diagnostics...
int print(std::ofstream& fp);
};
......@@ -208,7 +210,10 @@ public:
static GsdmlSlotData* paste_slotdata;
std::vector<GsdmlChannelDiag*> channel_diag;
~GsdmlDeviceData() { device_reset(); }
~GsdmlDeviceData() {
device_reset();
channel_diag_reset();
}
void device_reset()
{
for (unsigned int i = 0; i < slot_data.size(); i++)
......
......@@ -229,7 +229,10 @@ static pwr_tStatus GetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile);
if (EVEN(sts))
{
delete data;
return sts;
}
sts = data->get_value(Attr, Buf, BufSize);
......@@ -250,7 +253,10 @@ static pwr_tStatus SetIoDeviceData(pwr_tAttrRef Object, const char* Attr,
GsdmlDeviceData* data = new GsdmlDeviceData();
sts = data->read(datafile);
if (EVEN(sts))
{
delete data;
return sts;
}
sts = data->modify_value(Attr, Value);
if (ODD(sts))
......
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