WasabiFan / ev3dev-lang-js

JavaScript language bindings for ev3dev
56 stars 8 forks source link

What is the port address for the brickpi+ #22

Closed yashpatel21 closed 7 years ago

yashpatel21 commented 7 years ago

I am using a raspberry pi 2 along with a brickpi+ and mindstorms ev3. Since the port address on the brickpi+ for motors is not OUTPUT_A or B or C or D, what is it? I tried TTYAMA0_M1, but it is giving me error that the stop command is not supported by the device. My code is:

var ev3dev = require('ev3dev-lang');

var motor = new ev3dev.Motor(ev3dev.TTYAMA0_M1); if(!motor.connected) { console.error("No motor was found on port A. Please connect a tacho motor"); process.exit(1); }

motor.runForDistance(360 * 10, 500, motor.stopActionValues.brake);

console.log("Running the motor for 180 tacho counts...");

// Prevent Node from exiting until motor is done var cancellationToken = setInterval(function() { if(!motor.isRunning) clearInterval(cancellationToken); }, 200);

WasabiFan commented 7 years ago

The constants provided are intended to allow easy access to port names on some of the platforms; I haven't worked with the BrickPi (or, really, any platform but EV3) so I never got around to adding constants for it. Instead, you can use the port names for your platform directly as strings by doing new ev3dev.Motor('ttyAMA0:M1'), for example. It seems like you've already found the motor port names, but for reference they're available here: http://www.ev3dev.org/docs/platform-comparison/

yashpatel21 commented 7 years ago

Yeah, not many people use the BrickPi, but I had Lego Mindstorms and my raspberry pi lying around and I thought I could just get the BrickPi and use the power of a raspberry pi to program my Mindstorms kit. Anyway, thanks for the relatively quick reply! 😄