fixing isReady query on motors (#197)
This commit is contained in:
@ -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 => {
|
||||
|
Reference in New Issue
Block a user