fixing isReady query on motors (#197)

This commit is contained in:
Peli de Halleux
2018-01-06 00:00:04 -08:00
committed by GitHub
parent 77fb64043d
commit 9ae6482f28
3 changed files with 40 additions and 15 deletions

View File

@ -12,10 +12,24 @@ namespace pxsim {
data[i] = 0
},
read: buf => {
let v = "vSIM"
for (let i = 0; i < buf.data.length; ++i)
buf.data[i] = v.charCodeAt(i) || 0
console.log("pwm read");
// console.log("pwm read");
if (buf.data.length == 0) return 2;
const cmd = buf.data[0];
switch (cmd) {
case DAL.opOutputTest:
const port = buf.data[1];
let r = 0;
ev3board().getMotor(port)
.filter(motor => !motor.isReady())
.forEach(motor => r |= (1 << motor.port));
pxsim.BufferMethods.setNumber(buf, BufferMethods.NumberFormat.UInt8LE, 2, r);
break;
default:
let v = "vSIM"
for (let i = 0; i < buf.data.length; ++i)
buf.data[i] = v.charCodeAt(i) || 0
break;
}
return buf.data.length
},
write: buf => {