Endprogram (#884)

* moving end program logic to c++

* typo

* always stop on reset
This commit is contained in:
Peli de Halleux 2019-08-28 08:52:01 -07:00 committed by GitHub
parent 75cf8da396
commit aa40e7b169
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -162,7 +162,6 @@ namespace brick {
// this needs to be done in query(), which is run without the main JS execution mutex
// otherwise, while(true){} will lock the device
if (ret & DAL.BUTTON_ID_ESCAPE) {
motors.stopAll(); // ensuring that all motors are off
control.reset()
}
return ret

View File

@ -14,6 +14,7 @@
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
#include "ev3const.h"
#define THREAD_DBG(...)
@ -489,14 +490,22 @@ void runLMS() {
}
void stopMotors() {
uint8_t cmd[2] = { 0xA3, 0x0F };
uint8_t cmd[3] = { opOutputStop, 0x0F, 0 };
int fd = open("/dev/lms_pwm", O_RDWR);
write(fd, cmd, 2);
write(fd, cmd, 3);
close(fd);
}
void stopProgram() {
uint8_t cmd[1] = { opOutputProgramStop };
int fd = open("/dev/lms_pwm", O_RDWR);
write(fd, cmd, 1);
close(fd);
}
extern "C" void target_reset() {
stopMotors();
stopProgram();
if (lmsPid)
runLMS();
else