>  Because of this I also tried a bash script
>  that called the C program and got the same result (no response). Both work
>  from the command line.  I get no errors from EMC2.

>  I have entered a echo command in the bash script that is shown when I run it
>  from the command prompt. When run from EMC2 should it appear in a terminal
>  window?
>

Hi

I think you are heading down the classic ladder path to achieve your 
overall end, but I don't recall seeing your having solved the initial 
problem of executing scripts etc from a M1XX command.

I had some problems getting hal commands to run within a bash script 
called from M1xx, a while ago.

First off, unless your controller computer is permanently connected to 
the internet, (why would you, hardly going to improve latency)  just log 
in as, install as and run everything as root.
Sorts out all the problems with permissions, ownership etc.  The 
'middle-man will get you' paranoids will argue against it, but for a 
stand alone computer, I really do not see the problem.

Obviously ensure that M1xx file is in the path pointed to by 
PROGRAM_PREFIX in your .ini file
If somehow you have 2 entries in your .ini file, EMC only reads the 
first one.
Wonder how I found that out!

If you launch EMC as child process within a terminal (ie without the 
trailing & ) you will get stderr etc from emc and any processes launched 
from within it, eg bash or your C program.
It was seeing this and using debug outputs, that enabled me to discover 
that EMC reads M101 P3 and then passes 3.000000 instead of just 3, to my 
M101 script!

As an example the below M101 script uses calls to halcmd to adjust the 
scale and stepgen associated with my spindle, to account for pulley changes.

regards

Schooner

/#!/bin/bash

## sets scale gain to make output speed accurate
## for each of 4 pulley settings

if [ ! $# == 1 ]; then
   echo "Usage: M101 n - where n is speed range 1 - 4"
   exit 1
fi

## emc takes the M101 P3 for example and passes 3.000000
## to this script!!!
## need to convert first

float=$1
int=${float/\.*}
# DEBUG    echo "$float converted to $int"


case $int in

     1 ) halcmd setp scale.0.gain 0.8
         halcmd setp stepgen.4.maxvel 2400;;

     2 ) halcmd setp scale.0.gain 1.24
         halcmd setp stepgen.4.maxvel 1200;;

     3 ) halcmd setp scale.0.gain 3.55
         halcmd setp stepgen.4.maxvel 600;;

     4 ) halcmd setp scale.0.gain 6
         halcmd setp stepgen.4.maxvel 300;;
esac

exit 0/

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to