BUG in emccanon.cc

More
3 years 10 months ago #260502 by dinodf
BUG in emccanon.cc was created by dinodf
Dear, 
I am trying to understand the correct way to remap M6 in python. If someone have infos may help me? :-) 

Reading the  emccanon.cc on line 3274  there is the WAIT function, it return 0 or -1 not wait_type if timeout didn't occur, it is correct?
Code:
/*! \function WAIT    program execution and interpreting is stopped until the input selected by     index changed to the needed state (specified by wait_type).    Return value: either wait_type if timeout didn't occur, or -1 otherwise. */ int WAIT(int index, /* index of the motion exported input */          int input_type, /*DIGITAL_INPUT or ANALOG_INPUT */      int wait_type,  /* 0 - immediate, 1 - rise, 2 - fall, 3 - be high, 4 - be low */      double timeout) /* time to wait [in seconds], if the input didn't change the value -1 is returned */ {   if (input_type == DIGITAL_INPUT) {     if ((index < 0) || (index >= EMCMOT_MAX_DIO))     return -1;   } else if (input_type == ANALOG_INPUT) {     if ((index < 0) || (index >= EMCMOT_MAX_AIO))     return -1;   }  EMC_AUX_INPUT_WAIT wait_msg;    flush_segments();    wait_msg.index = index;  wait_msg.input_type = input_type;  wait_msg.wait_type = wait_type;  wait_msg.timeout = timeout;    interp_list.append(wait_msg);  return 0; }

Regards
Dino 

Please Log in to join the conversation.

More
3 years 9 months ago #261220 by andypugh
Replied by andypugh on topic BUG in emccanon.cc
Can you explain further? I don't understand the link between a python remap and the emccanon WAIT function.

All the code above does is check that the input values are valid and then create an EMC_AUX_INPUT_WAIT object that is added to the motion queue. It is not the code that performs the waiting and returns the result of the wait. The code above just returns a -1 to indicate an invalid input to the interpreter.

The message is then parsed here:
github.com/LinuxCNC/linuxcnc/blob/master...emctaskmain.cc#L1924

And the actual inout checking is done here:
github.com/LinuxCNC/linuxcnc/blob/master...emctaskmain.cc#L2749

Please Log in to join the conversation.

More
3 years 9 months ago #261756 by dinodf
Replied by dinodf on topic BUG in emccanon.cc
Hi,
maybe I have not understand the code.

In the comment "Return value: either wait_type if timeout didn't occur, or -1 otherwise." but in the function the return is 0 or -1 never
wait_type, /* 0 - immediate, 1 - rise, 2 - fall, 3 - be high, 4 - be low */

But it work so I think I am in wrong... :-)
Regards

Please Log in to join the conversation.

More
3 years 9 months ago #261802 by andypugh
Replied by andypugh on topic BUG in emccanon.cc
Yes, the return value from the code you found is only used to report an error if t there is a problem adding the command to the motion queue.
The documented return value is actually set in emctaskmain.cc

Please Log in to join the conversation.

Time to create page: 0.140 seconds
Powered by Kunena Forum