Runtime: move LC_NUMERIC locale setting to Beremiz_service.py.
authorEdouard Tisserant
Tue, 21 Feb 2023 11:38:45 +0100
changeset 3731 549763a28934
parent 3727 265fc8001d0a
child 3732 929276eea252
Runtime: move LC_NUMERIC locale setting to Beremiz_service.py.
Beremiz_service.py
targets/Linux/plc_Linux_main.c
targets/Win32/plc_Win32_main.c
--- a/Beremiz_service.py	Fri Feb 17 11:41:58 2023 +0100
+++ b/Beremiz_service.py	Tue Feb 21 11:38:45 2023 +0100
@@ -185,6 +185,12 @@
     return os.path.join(beremiz_dir, *args)
 
 
+import locale
+# Matiec's standard library relies on libC's locale-dependent
+# string to/from number convertions, but IEC-61131 counts
+# on '.' for decimal point. Therefore locale is reset to "C" */
+locale.setlocale(locale.LC_NUMERIC, "C")
+
 def SetupI18n():
     # Get folder containing translation files
     localedir = os.path.join(beremiz_dir, "locale")
@@ -205,7 +211,6 @@
     # Define locale domain
     loc.AddCatalog(domain)
 
-    import locale
     global default_locale
     default_locale = locale.getdefaultlocale()[1]
 
--- a/targets/Linux/plc_Linux_main.c	Fri Feb 17 11:41:58 2023 +0100
+++ b/targets/Linux/plc_Linux_main.c	Tue Feb 21 11:38:45 2023 +0100
@@ -108,7 +108,6 @@
 #define maxval(a,b) ((a>b)?a:b)
 int startPLC(int argc,char **argv)
 {
-    setlocale(LC_NUMERIC, "C");
 
     PLC_shutdown = 0;
 
--- a/targets/Win32/plc_Win32_main.c	Fri Feb 17 11:41:58 2023 +0100
+++ b/targets/Win32/plc_Win32_main.c	Tue Feb 21 11:38:45 2023 +0100
@@ -82,7 +82,6 @@
 {
 	unsigned long thread_id = 0;
     BOOL tmp;
-    setlocale(LC_NUMERIC, "C");
 
     debug_sem = CreateSemaphore(
                             NULL,           // default security attributes