On Sunday 12 March 2017 13:05:58 Sebastian Kuzminsky wrote:

> On March 12, 2017 5:31:42 AM MDT, MH <mhemc2nos...@googlemail.com> 
wrote:
> >Hello,
> >
> >I have a question about the behaviour of the halui bit pins and would
> >like to confirm that I understand the code correctly. I could not
> >answer
> >my question from the halui documentation.
> >
> >Do these pins activate on both a rising and a falling edge ?
> >
> >It like to use the input pin halui.program.pause to pause a running
> >program if I get a signal that might indicate that the material sheet
> >*might* have moved and the operator needs to check.
> >
> >Having a cursory look at the linuxcnc source code I suspect the halui
> >pins come from linuxcnc-dev/src/emc/usr_intf/halui.cc
> >
> >And in halui.cc these line (with lines numbers):
> >
> >   1114 static int sendProgramPause()
> >   1115 {
> >   1116     EMC_TASK_PLAN_PAUSE emc_task_plan_pause_msg;
> >   1117
> >   1118     return emcCommandSend(emc_task_plan_pause_msg);
> >
> >...
> >
> >   1544 static int check_bit_changed(bool halpin, bool &newpin)
> >   1545 {
> >   1546     if (halpin != newpin) {
> >   1547         newpin = halpin;
> >   1548         return halpin;
> >   1549     }
> >   1550     return 0;
> >   1551 }
> >
> >...
> >
> >   1654     if (check_bit_changed(new_halui_data.program_pause,
> >old_halui_data.program_pause) != 0)
> >   1655         sendProgramPause();
> >
> >That line 1654 looks to me as if both edges would trigger the msg
> >emc_task_plan_pause_msg to be send.
> >
> >Is that correct ?
>
> Almost.  Look at line 1548, if the pin has switched state it turns the
> new state.  So that function returns True on a positive edge, only.
>
I must be getting dense Seb, but I read that snippet around 1548 as 
changing the return if they are not equal. Its not checking for a rising 
edge, its checking for in-equality. Or so it looks to me.

line 1654 OTOH, would send it only on the rising edge with its !=0 test. 
I think...  I haven't carved any C to speak of since K&R #2 was out + 
maybe 5 years.

> I notice now that the names of the variables inside the function are
> the opposite of what it seems they should be, that's confusing...

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to