read motor state into lms_motor

This commit is contained in:
Peli de Halleux 2017-12-19 16:18:17 -08:00
parent aa031036ee
commit c8ac770983

View File

@ -15,11 +15,13 @@ namespace pxsim {
MMapMethods.register("/dev/lms_motor", { MMapMethods.register("/dev/lms_motor", {
data, data,
beforeMemRead: () => { beforeMemRead: () => {
const outputs = ev3board().outputNodes;
console.log("motor before read"); console.log("motor before read");
for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) { for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) {
data[MotorDataOff.TachoCounts * port] = 0; // Tacho count const output = outputs[port];
data[MotorDataOff.Speed * port] = 50; // Speed data[MotorDataOff.TachoCounts + port * MotorDataOff.Size] = 0; // Tacho count
data[MotorDataOff.TachoSensor * port] = 0; // Count data[MotorDataOff.Speed + port * MotorDataOff.Size] = output ? outputs[port].getSpeed() : 0; // Speed
data[MotorDataOff.TachoSensor + port * MotorDataOff.Size] = output ? outputs[port].getAngle() : 0; // Count
} }
}, },
read: buf => { read: buf => {