Python Interface makes race conditions - mayby
12 Jan 2024 05:04 #290470
by zz912
Replied by zz912 on topic Python Interface makes race conditions - mayby
Today I did some experiments to remove my Issues. Unfortunately, nothing worked.
I wanted to ask why emcWaitCommandComplete has two returns?
github.com/LinuxCNC/linuxcnc/blob/d703c5...cmodule.cc#L213-L232
I didn't understand how this code works.
I wanted to add an IF statement to the code to make it wait for something, but I don't know where.
I wanted to ask why emcWaitCommandComplete has two returns?
static RCS_STATUS emcWaitCommandComplete(pyCommandChannel *s, double timeout) {
double start = etime();
do {
double now = etime();
if(s->s->peek() == EMC_STAT_TYPE) {
EMC_STAT *stat = (EMC_STAT*)s->s->get_address();
int serial_diff = stat->echo_serial_number - s->serial;
if (serial_diff > 0) {
return RCS_STATUS::DONE;
}
if (serial_diff == 0 &&
( stat->status == RCS_STATUS::DONE || stat->status == RCS_STATUS::ERROR )) {
return stat->status;
}
}
esleep(fmin(timeout - (now - start), EMC_COMMAND_DELAY));
} while (etime() - start < timeout);
return RCS_STATUS::UNINITIALIZED;
}
I didn't understand how this code works.
I wanted to add an IF statement to the code to make it wait for something, but I don't know where.
Please Log in or Create an account to join the conversation.
12 Jan 2024 06:09 #290471
by cmorley
Replied by cmorley on topic Python Interface makes race conditions - mayby
do{
check difference of stat echoed serial number - sent command serial number
if difference is greater then 0 then sent command finished -return
if the difference is 0 but RC status is in done or error - return
while timeout hasn't expired -continue
return because timeout expired
hopefully that helps.
check difference of stat echoed serial number - sent command serial number
if difference is greater then 0 then sent command finished -return
if the difference is 0 but RC status is in done or error - return
while timeout hasn't expired -continue
return because timeout expired
hopefully that helps.
The following user(s) said Thank You: zz912
Please Log in or Create an account to join the conversation.
15 Jan 2024 20:56 #290799
by zz912
Replied by zz912 on topic Python Interface makes race conditions - mayby
Hello,
I am trying export one variable from one file to another file. In my Arduino projects it works, but in LCNC not.
I need "int halui_sent_mdi" export from halui.cc to emctaskmain.cc.
I made header file:
In halui.cc:
In emctaskmain.cc:
If I declare halui_sent_mdi in emctaskmain.cc I can compile it but the value of halui_sent_mdi[halui.cc] != halui_sent_mdi[emctaskmain.cc]
If I dont declare halui_sent_mdi in emctaskmain.cc I can not compile it:
Can I ask for help?
I am trying export one variable from one file to another file. In my Arduino projects it works, but in LCNC not.
I need "int halui_sent_mdi" export from halui.cc to emctaskmain.cc.
I made header file:
#ifndef HALUI_HH
#define HALUI_HH
extern int halui_sent_mdi;
#endif /* ifndef HALUI_HH */
In halui.cc:
#include "halui.hh"
...
int halui_sent_mdi = 0;
...
In emctaskmain.cc:
#include "../../halui.hh"
...
printf("emc task: halui_sent_mdi = %i zz912\n", halui_sent_mdi);
...
If I declare halui_sent_mdi in emctaskmain.cc I can compile it but the value of halui_sent_mdi[halui.cc] != halui_sent_mdi[emctaskmain.cc]
If I dont declare halui_sent_mdi in emctaskmain.cc I can not compile it:
zdenek@cnc:~/linuxcnc/linuxcnc-2.9/src$ make
Reading 205/205 dependency files
Done reading dependencies
Reading 238/238 realtime dependency files
Done reading realtime dependencies
Linking milltask
c++ -std=gnu++17 -o ../bin/milltask objects/emc/motion/emcmotglb.o objects/emc/task/emctask.o objects/emc/task/emccanon.o objects/emc/task/emctaskmain.o objects/emc/motion/usrmotintf.o objects/emc/motion/emcmotutil.o objects/emc/task/taskintf.o objects/emc/motion/dbuf.o objects/emc/motion/stashf.o objects/emc/task/taskmodule.o objects/emc/task/taskclass.o objects/emc/task/backtrace.o ../lib/librs274.so.0 ../lib/liblinuxcnc.a ../lib/libnml.so.0 ../lib/liblinuxcncini.so.0 ../lib/libposemath.so.0 ../lib/liblinuxcnchal.so.0 ../lib/libpyplugin.so.0 ../lib/libtooldata.so.0 -L/home/zdenek/linuxcnc/linuxcnc-2.9/lib -Wl,-rpath,/home/zdenek/linuxcnc/linuxcnc-2.9/lib -ltirpc -lgpiod -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -lboost_python311 -L/usr/lib/x86_64-linux-gnu -lpython3.11 -ldl -lm
/usr/bin/ld: objects/emc/task/emctaskmain.o: warning: relocation against `halui_sent_mdi' in read-only section `.text'
/usr/bin/ld: objects/emc/task/emctaskmain.o: in function `mdi_execute_hook()':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:86: undefined reference to `halui_sent_mdi'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [emc/task/Submakefile:39: ../bin/milltask] Chyba 1
Can I ask for help?
Please Log in or Create an account to join the conversation.
23 Jan 2024 19:53 #291457
by zz912
Replied by zz912 on topic Python Interface makes race conditions - mayby
I asked the same question on the Czech forum:
forum.strojirenstvi.cz/viewtopic.php?t=45350
I was very unhappy that I was not able to create the header file correctly.
If I understood the Czech guys correctly, it is not possible to connect halui.cc and emctaskmain.cc using a header file. This is because halui.cc and emctaskmain.cc are each run in a different subroutine. This is prohibited by the kernel.
So I should study NML and send halui_sent_mdi using NML.
It is so?
forum.strojirenstvi.cz/viewtopic.php?t=45350
I was very unhappy that I was not able to create the header file correctly.
If I understood the Czech guys correctly, it is not possible to connect halui.cc and emctaskmain.cc using a header file. This is because halui.cc and emctaskmain.cc are each run in a different subroutine. This is prohibited by the kernel.
So I should study NML and send halui_sent_mdi using NML.
It is so?
Please Log in or Create an account to join the conversation.
Time to create page: 0.062 seconds