On Sat, 8 Dec 2018 16:51:11 +0000
Chris Morley <[email protected]> wrote:

> 
> ________________________________
> From: Nicklas SB Karlsson <[email protected]>
> Sent: December 8, 2018 4:23 PM
> To: EMC developers
> Subject: Re: [Emc-developers] how to catch errors with waitcomplete command 
> in python
> 
> >No real idea but an exception is a common method to handle errors, it might 
> >however be a problem in a real time system.
> 
> In this case the python is a bit of a red herring...
> I'm using python to call the wait_complete() function but it actually is 
> programmed in C++
> Here is the function:
> 
> static int 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_DONE;
>            }
>            if (serial_diff == 0 &&
>                ( stat->status == RCS_DONE || stat->status == RCS_ERROR )) {
>                 return stat->status;
>            }
>         }
>         esleep(fmin(timeout - (now - start), EMC_COMMAND_DELAY));
>     } while (etime() - start < timeout);
>     return -1;
> }
> 
> It seems to decide if the command is done by it's serial number.
> But it does check it's status.
> It seems the RCS is probably a message frame that NML uses.

You know what serialnumber is? For some reason I got the feeling it might be 
some kind of counter counting upwards.


_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to