Skip to content

Commit 656c300

Browse files
committed
Merge branch '2.9'
2 parents c5522b7 + 7b019a6 commit 656c300

8 files changed

Lines changed: 140 additions & 14 deletions

File tree

src/emc/motion-logger/motion-logger.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void log_print(const char *fmt, ...) {
255255
logfile = fopen(logfile_name, "w");
256256
if (logfile == NULL) {
257257
fprintf(stderr, "error opening %s: %s\n", logfile_name, strerror(errno));
258-
exit(1);
258+
exit(EXIT_FAILURE);
259259
}
260260
}
261261
}
@@ -276,7 +276,7 @@ int main(int argc, char* argv[]) {
276276
logfile_name = argv[1];
277277
} else {
278278
fprintf(stderr, "usage: motion-logger [LOGFILE]\n");
279-
exit(1);
279+
exit(EXIT_FAILURE);
280280
}
281281

282282
signal(SIGINT, sighandler); // ^C interrupt
@@ -288,28 +288,33 @@ int main(int argc, char* argv[]) {
288288

289289
if((mot_comp_id = hal_init("motion-logger")) < 0) {
290290
fprintf(stderr, "motion-logger: failed to init hal.\n");
291-
exit(1);
291+
exit(EXIT_FAILURE);
292292
}
293293
if(!(motion_logger_data = hal_malloc(sizeof(*motion_logger_data)))) {
294294
hal_exit(mot_comp_id);
295295
fprintf(stderr, "motion-logger: failed to allocate hal memory.\n");
296-
exit(1);
296+
exit(EXIT_FAILURE);
297297
}
298298
int r;
299299
if((r = hal_pin_bit_new("motion-logger.reopen-log", HAL_IO, &motion_logger_data->reopen, mot_comp_id)) < 0) {
300300
hal_exit(mot_comp_id);
301301
errno = -r;
302302
perror("hal_pin_bit_new");
303-
exit(1);
303+
exit(EXIT_FAILURE);
304304
}
305305
*motion_logger_data->reopen = 0;
306306
if((r = hal_ready(mot_comp_id)) < 0) {
307307
hal_exit(mot_comp_id);
308308
errno = -r;
309309
perror("hal_ready");
310-
exit(1);
310+
exit(EXIT_FAILURE);
311+
}
312+
313+
r = init_comm_buffers();
314+
if (r) {
315+
fprintf(stderr,"init_comm_buffer init failure\n");
316+
exit(EXIT_FAILURE);
311317
}
312-
init_comm_buffers();
313318

314319
while (!quit) {
315320
rtapi_mutex_get(&emcmotStruct->command_mutex);

src/emc/motion/axis.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,7 @@ int axis_calc_motion(double servo_period)
670670

671671
for (axis_num = 0; axis_num < EMCMOT_MAX_AXIS; axis_num++) {
672672
axis = &axis_array[axis_num];
673-
axis->teleop_vel_cmd = axis->teleop_tp.curr_vel;
674-
axis->pos_cmd = axis->teleop_tp.curr_pos;
673+
675674
// teleop_tp.max_vel is always positive
676675
if (axis->teleop_tp.max_vel > axis->vel_limit) {
677676
axis->teleop_tp.max_vel = axis->vel_limit;
@@ -680,6 +679,9 @@ int axis_calc_motion(double servo_period)
680679
violated_teleop_limit = 1;
681680
}
682681

682+
axis->teleop_vel_cmd = axis->teleop_tp.curr_vel;
683+
axis->pos_cmd = axis->teleop_tp.curr_pos;
684+
683685
if (!axis->teleop_tp.active) {
684686
axis->kb_ajog_active = 0;
685687
axis->wheel_ajog_active = 0;

src/emc/rs274ngc/interp_g7x.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ void g7x::pocket(int cycle, std::complex<double> location, iterator p,
788788
if (p==std::prev(end()))
789789
return;
790790

791-
if(std::abs(imag(location)-x)>tolerance) {
791+
if(std::abs(imag(location)-x)>tolerance || (*p)->ep()==location) {
792792
/* Our x coordinate is beyond the current segment, move onto
793793
the next
794794
*/

src/emc/tooldata/tooldata_common.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ int tooldata_read_entry(const char *input_line)
8383
return -1;
8484
}
8585
if (input_line[0] == ';') {return 0;} //ignore leading ';'
86-
strcpy(work_line, input_line);
86+
strncpy(work_line, input_line, sizeof(work_line)-1);
87+
work_line[sizeof(work_line)-1] = 0;
8788

8889
CANON_TOOL_TABLE empty = tooldata_entry_init();
8990
toolno = empty.toolno;

src/emc/tooldata/tooldata_mmap.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
** along with this program; if not, write to the Free Software
1717
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818
*/
19+
1920
#include <stdio.h>
2021
#include <sys/types.h>
21-
#include <unistd.h>
22-
#include <fcntl.h>
22+
#include <unistd.h> // write(2),lseek(2)
23+
#include <fcntl.h> // open(2)
2324
#include <sys/mman.h>
2425
#include <string.h>
2526
#include "config.h"
@@ -133,7 +134,7 @@ int tool_mmap_creator(EMC_TOOL_STAT const * ptr,int random_toolchanger)
133134
toolstat = ptr; //note NULL for sai
134135
creator_fd = open(tool_mmap_fname(),
135136
TOOL_MMAP_CREATOR_OPEN_FLAGS,TOOL_MMAP_MODE);
136-
if (!creator_fd) {
137+
if (creator_fd < 0) {
137138
perror("tool_mmap_creator(): file open fail");
138139
exit(EXIT_FAILURE);
139140
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2+
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3+
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4+
N..... SET_XY_ROTATION(0.0000)
5+
N..... SET_FEED_REFERENCE(CANON_XYZ)
6+
N..... ON_RESET()
7+
N..... COMMENT("interpreter: continuing to use same coordinate system")
8+
N..... COMMENT("interpreter: Lathe diameter mode changed to diameter")
9+
N..... SELECT_PLANE(CANON_PLANE_XZ)
10+
N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
11+
N..... SET_SPINDLE_MODE(0 1400.0000)
12+
N..... SET_SPINDLE_SPEED(0, 200.0000)
13+
N..... START_SPINDLE_CLOCKWISE(0)
14+
N..... COMMENT("interpreter: feed mode set to units per revolution")
15+
N..... SET_FEED_MODE(0, 1)
16+
N..... SET_FEED_RATE(0.0000)
17+
N..... SET_FEED_RATE(0.1200)
18+
N..... SET_G92_OFFSET(0.0000, 0.0000, -1.9000, 0.0000, 0.0000, 0.0000)
19+
N..... STRAIGHT_TRAVERSE(10.0000, 0.0000, 2.8000, 0.0000, 0.0000, 0.0000)
20+
N..... STRAIGHT_TRAVERSE(10.0000, 0.0000, 2.8000, 0.0000, 0.0000, 0.0000)
21+
N..... STRAIGHT_FEED(11.3630, 0.0000, 2.8000, 0.0000, 0.0000, 0.0000)
22+
N..... STRAIGHT_FEED(11.3630, 0.0000, 0.8229, 0.0000, 0.0000, 0.0000)
23+
N..... ARC_FEED(-0.5000, 11.8630, -0.5000, 9.8630, 1, 0.0000, 0.0000, 0.0000, 0.0000)
24+
N..... STRAIGHT_FEED(11.8630, 0.0000, -4.0318, 0.0000, 0.0000, 0.0000)
25+
N..... ARC_FEED(-5.0000, 12.1130, -5.0000, 10.1130, 1, 0.0000, 0.0000, 0.0000, 0.0000)
26+
N..... STRAIGHT_FEED(12.1130, 0.0000, -25.0000, 0.0000, 0.0000, 0.0000)
27+
N..... ARC_FEED(-27.0000, 10.1130, -25.0000, 10.1130, 1, 0.0000, 0.0000, 0.0000, 0.0000)
28+
N..... STRAIGHT_FEED(10.0000, 0.0000, -27.0000, 0.0000, 0.0000, 0.0000)
29+
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
30+
N..... COMMENT("interpreter: cutter radius compensation on right")
31+
N..... STRAIGHT_TRAVERSE(10.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000)
32+
N..... STRAIGHT_TRAVERSE(10.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000)
33+
N..... STRAIGHT_TRAVERSE(9.3630, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000)
34+
N..... STRAIGHT_FEED(9.3630, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
35+
N..... STRAIGHT_FEED(9.8630, 0.0000, -0.5000, 0.0000, 0.0000, 0.0000)
36+
N..... STRAIGHT_FEED(9.8630, 0.0000, -5.0000, 0.0000, 0.0000, 0.0000)
37+
N..... STRAIGHT_FEED(10.1130, 0.0000, -5.0000, 0.0000, 0.0000, 0.0000)
38+
N..... STRAIGHT_FEED(10.1130, 0.0000, -25.0000, 0.0000, 0.0000, 0.0000)
39+
N..... STRAIGHT_FEED(10.0000, 0.0000, -25.0000, 0.0000, 0.0000, 0.0000)
40+
N..... COMMENT("interpreter: cutter radius compensation off")
41+
N..... MIST_OFF()
42+
N..... FLOOD_OFF()
43+
N..... STRAIGHT_TRAVERSE(12.5000, 0.0000, -25.0000, 0.0000, 0.0000, 0.0000)
44+
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
45+
N..... SET_XY_ROTATION(0.0000)
46+
N..... SELECT_PLANE(CANON_PLANE_XY)
47+
N..... SET_FEED_MODE(0, 0)
48+
N..... SET_FEED_RATE(0.0000)
49+
N..... STOP_SPINDLE_TURNING(0)
50+
N..... SET_SPINDLE_MODE(0 0.0000)
51+
N..... PROGRAM_END()
52+
N..... ON_RESET()
53+
N..... ON_RESET()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#<_initial>=20
2+
#<_final>=19.726
3+
#<_champher>=0.5
4+
#<_zmax>=0
5+
#<_zmin>=-25
6+
#<doc>=2
7+
8+
G54
9+
G7
10+
G18
11+
G21
12+
13+
o100 sub
14+
o101 if [#<_champher> gt 0]
15+
G1 X[#<_final>-2.0001*#<_champher>]
16+
Z#<_zmax>
17+
X#<_final>C#<_champher>
18+
o101 else
19+
X#<_final>
20+
o101 endif
21+
W-5
22+
U0.5
23+
Z#<_zmin>
24+
X#<_initial>
25+
o100 endsub
26+
27+
M3 G96 S200 d1400
28+
G95 F0.12
29+
G52 z[0.1-#<doc>]
30+
;m7
31+
G71 Q100 Z[#<_zmax>+0.8+#<doc>] X#<_initial> D#<doc> I#<doc> R0.3
32+
G52 z0
33+
;m7
34+
g42
35+
G70 Q100 Z[#<_zmax>+1] X#<_initial> D#<doc> P1
36+
g40
37+
M9
38+
G0X[#<_initial>+5]
39+
40+
M2
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Demonstrate endless loop when encountering incorrect parameters in
4+
# G71 call. Note, the expected output is not verified. No idea what
5+
# it should look like on a successful termination of this endless
6+
# loop.
7+
8+
rs274 -g g71-endless-loop_2.ngc | awk '{$1=""; print}' > result &
9+
pid=$!
10+
11+
# Give it 10 seconds to complete
12+
count=10
13+
while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do
14+
sleep 1
15+
count=$(($count - 1))
16+
done
17+
18+
if kill -0 $pid > /dev/null 2>&1; then
19+
kill -9 $pid
20+
echo "error: g71-endless-loop.ngc program seem to be stuck, killing"
21+
exit 1
22+
fi
23+
24+
exit 0

0 commit comments

Comments
 (0)