I have been tinkering a little bit with a raspberry pi and Sqlite through codesys. I have noticed an instability when it comes to logging at high frequency and calling the function. I am not able to close the Database after writing but that shouldn't be an issue. What I have noticed when I monitor my processes on the pi is an unusual large number of processes that are open from the codesys runtime. After a few cycles, the Visualization hangs and the whole codesys process is killed by the Debian OS, i.e fatal crash of the application. The Sqlite was also successfully written, so the commands were performed as expected.
The code I ran is as follows almost every 1 second:
//HeaderMETHODmSqliteWrite : BOOLVAR_INPUTsCmd: STRING(255); // an sqlite write command//'INSERT INTO fooLog(foo1,foo2)Values('10','20')' (example not real command)END_VARVARcommand0 : STRING :='sqlite3 ';command1 : STRING :='/var/opt/codesys/PlcLogic/trend/LogBook.sql ';commandout : STRING(1000);stdout : STRING(1000) :=''; Result : RTS_IEC_RESULT;iSize : UDINT;END_VAR//concatthestringstoformtherightcommand"sqlite3 path/filename sqlite3 command"commandout :=CONCAT(command0,command1);commandout :=concat(commandout, sCmd);////ChecksizefortestingpurposesiSize :=SIZEOF(CommandOut);//////sendthecommandSysProcess.SysProcessExecuteCommand2(pszCommand:=commandout, pszStdOut:=stdout, udiStdOutLen:=SIZEOF(stdout),pResult :=ADR(Result));////Errorhandling//IFResult<>0THEN//Dosomething//ELSE//mSqliteWrite :=TRUE;//END_IF
Has anyone come across this problem ? Is there a way around it that doesn't need any kind of third party tools or libs? Is this something relevant to the runtime of the pi or general runtime on other linux based systems ?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yeah exactly I am talking abt my own database. It seems that when I do a write process as described above, the processes increase with every cycle and the process is killed. I am using my own database and it already worked but the application at the end crashes.
Best Regards,
Kay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes I am sure because I have a function that checks that. As I said it works, I see the log entries in the SQLite. My problem is the stability of the entire system. it seems to open so many processes and it just crashes.
Thanks again for your help marcel, much appreciated
Regards,
Kay
Last edit: kebek007 2021-05-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At least my two cents from the runtime perspective:
It should not be, that the number of processes increase, under normal
circumstances. But, indeed, if the command produces a lot of output, I can
imagine, that the current implementation of SysProcess might have such
problems.
So, I would recommend you to test it, by calling your own bash script,
which is in fact doing the same as you do now, but discards the output.
Well that is a very refreshing insight. I had no idea that it could have been on the output. I will definitely give that a whirl. Thanks a lot for your answer Ingo.
Regards,
Kay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello community,
I have been tinkering a little bit with a raspberry pi and Sqlite through codesys. I have noticed an instability when it comes to logging at high frequency and calling the function. I am not able to close the Database after writing but that shouldn't be an issue. What I have noticed when I monitor my processes on the pi is an unusual large number of processes that are open from the codesys runtime. After a few cycles, the Visualization hangs and the whole codesys process is killed by the Debian OS, i.e fatal crash of the application. The Sqlite was also successfully written, so the commands were performed as expected.
The code I ran is as follows almost every 1 second:
Has anyone come across this problem ? Is there a way around it that doesn't need any kind of third party tools or libs? Is this something relevant to the runtime of the pi or general runtime on other linux based systems ?
Thanks
hey,
you cannot simple reuse a sqlite database which the application uses.
If you want to do your own queries, create your own sqlite database.
Best regards,
Marcel
Thanks for your answer Marcel.
yeah exactly I am talking abt my own database. It seems that when I do a write process as described above, the processes increase with every cycle and the process is killed. I am using my own database and it already worked but the application at the end crashes.
Best Regards,
Kay
Hey
My bad, I stopped reading the path at PlcLogic/trend.
You are sure that you don't write outside of the bounds of e.g. the string?
Best regards,
Marcel
Yes I am sure because I have a function that checks that. As I said it works, I see the log entries in the SQLite. My problem is the stability of the entire system. it seems to open so many processes and it just crashes.
Thanks again for your help marcel, much appreciated
Regards,
Kay
Last edit: kebek007 2021-05-05
Could you maybe provide a simplified example application to let me debug the issue?
At least my two cents from the runtime perspective:
It should not be, that the number of processes increase, under normal
circumstances. But, indeed, if the command produces a lot of output, I can
imagine, that the current implementation of SysProcess might have such
problems.
So, I would recommend you to test it, by calling your own bash script,
which is in fact doing the same as you do now, but discards the output.
E.g. (untested):
command0 : STRING := 'mysqlite3 ';
I'm curious about your result!
Cheers,
Ingo
Well that is a very refreshing insight. I had no idea that it could have been on the output. I will definitely give that a whirl. Thanks a lot for your answer Ingo.
Regards,
Kay