Data buffer too small with API driver when doing JSON operation

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
10 posts • Page 1 of 1
User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Data buffer too small with API driver when doing JSON operation

Post by adaneau »

Hi all,

I am having a kafka driver for WinCC OA (inspired from the one from CERN). We want to write big JSON strings to kafka (~1MB).

But we are blocked by internal WinCC OA choice of limiting the buffer size for the driver to being a PVSSushort.

We are getting the following message :
WCCOAKafka (14), 2022.04.22 13:44:26.393, IMPL, SEVERE, 54, Unexpected state, kafkaStringTrans::toPeriph, Data buffer too small; need:814232 have:40960

Is there a reason for not using 32 bits integer for buffer? In 2022 with the amount of ram on our servers this would make more sense than limiting it to a short. Buffer definition is located in api\include\ComDrv\HWObject.hxx
Is there a way to go around this?

Thanks

BR
Alexandre

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Data buffer too small with API driver when doing JSON operation

Post by gschijndel »

A workaround could be to store only a pointer in the buffer. In that case you will have to override the 'updateBufferLlc', 'compareLlc' and 'deleteData' functions.

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: Data buffer too small with API driver when doing JSON operation

Post by leoknipp »

I do not know a reason why the output buffer from the API to the external communication partner is limited.
Possibly the limit had no effect up to now as normally only small packages are send to the communication partner.

Best Regards
Leopold Knipp
Senior Support Specialist

User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Re: Data buffer too small with API driver when doing JSON operation

Post by adaneau »

Hi Leo and Gertjan,

Thank you for your answers. Yes I think we are probably the first one trying to write high frequency dataset via driver.

Anyway I will give a try to Gertjan solution, except if anyone at ETM thinks that this is not a good idea :lol:

BR
Alex

User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Re: Data buffer too small with API driver when doing JSON operation

Post by adaneau »

Ok I am now a bit lost on how to achieve this by using pointer:

I have my stringtrans class where I will save the pointer in buffer:

Code: Select all

PVSSboolean kafkaStringTrans::toPeriph(PVSSchar *buffer, PVSSuint len,
                                      const Variable &var, const PVSSuint subix) const
{
//something
  const TextVar& tv = static_cast<const TextVar &>(var);

  const TextVar* q = &tv;
  sprintf((char*)buffer, "%s", q);
}
So with this my pointer is now in buffer. This is a TextVar pointer.

But to retrieve the value I will be in my class HWService :

Code: Select all

PVSSboolean kafkaHWService::writeData(HWObject *objPtr)
{
  const TextVar* q =  objPtr->getDataPtr(); // that is not working as getDataPtr() is always returning a PVSSchar 
//something
}
So I cannot figure out how to retrieve my TextVar pointer in the other class as it is changed to PVSSchar. Do I miss something here?

BR
Alex

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Data buffer too small with API driver when doing JSON operation

Post by gschijndel »

To assign an unrelated type pointer you will need a reinterpret cast.

Code: Select all

VariablePtr varPtr = *reinterpret_cast<Variable**>(data);
In my project I have extended my HWObject type with some functions to get and set the variable pointer.
I would derive from HmiConnection and implement the writeData function there.

User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Re: Data buffer too small with API driver when doing JSON operation

Post by adaneau »

Hi Gertjan,

Do you use a void* pointer? Also by working in HmiConnection class, you would still have to deal with stringtrans as it is called before no? As the write data is called only after transformation and the buffer is already limited from the transformation fct toPeriph.

If you would have some example for the HWobject extension to deal with pointer that would be awesome too :D

Thanks a lot for help.

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: Data buffer too small with API driver when doing JSON operation

Post by gschijndel »

I do not use a void* pointer. Using the HmiConnection class will get the writeData call inside the connection instance instead of the HWService, otherwise there is not much difference in this regard. It still needs to deal with the transformation.

User avatar
kilianvp
Posts: 443
Joined: Fri Jan 16, 2015 10:29 am

Re: Data buffer too small with API driver when doing JSON operation

Post by kilianvp »

Is your fork public visible? I would be interested in the final solution.

User avatar
adaneau
Posts: 310
Joined: Tue Feb 21, 2012 9:49 am

Re: Data buffer too small with API driver when doing JSON operation

Post by adaneau »

Hey Kilian,

No it is not. I would need to clean it a lot for this but I will consider it and keep it updated here.

Post Reply
10 posts • Page 1 of 1