Issue with using ArEventLog in a custom library

I made a small function block library that makes the logging of a message easier, But noticed a problem when writing messages to the logger. When a short message is written after sending a longer message part of the old message still shows.
This problem only occures when writing from the library, not when the function block internals are copy pasted in a program.

These messages show the difference where the bottom two are written form the library function block and the top two are from a program.
image

I thought the problem lies somwhere in the buffer that is used to write the message as ASCII data.
So instead of just using the following code snippet.
image

and then calling the write function like this:

To try and fix the issue I tried resetting and writing to the buffer with the memset function.

image
image
With these i can see that the buffer is reset correctly after each message but in the logbook the problem persists.

Does anyone know a possible fix for this or is it not possible to write from a logbook like this?

Hi,

as I remember ArEventLogWrite() needs the exact data length at .AddDataSize. So please try using the string length at .AddDataSize, e.g. brsstrlen(ADR(Global_buffer)) instead of sizeof(Global_buffer).

The internal buffers of the ArEventLogWritr() is used universal, I think that it isn’t initialized even if you initialize the data source buffer.

Best regards!

2 Likes

The string length at .AddDataSize was indeed the problem, Thank you.

1 Like