Connecting Mindstorm Lego roboter

Hi im an art student from gemany and im working on a project with processing.
I have a mistake in my code and I can t figure out how to solve it. If you have any advice it would save me
a lot of time. I try to connect to my old Mindstorm Lego roboter.
Processing shows me this Error when i try to run the programm:

jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.openPort(Unknown Source)
at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.(Unknown Source)
at pt.citar.diablu.processing.nxt.LegoNXT.(Unknown Source)
at sketch_200501a.setup(sketch_200501a.java:60)
at processing.core.PApplet.handleDraw(PApplet.java:2432)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.

I would really appreciate if you can help me!
This is my code:

/*
 * NXTCommTest.pde
 *
 * Created on 07 de March 2007
 * Modified on 14 August 2014 
 *
 *  NXTComm: A java library to control the NXT Brick.
 *  This is part a of the DiABlu Project (http://diablu.jorgecardoso.org)
 *
 *  Copyright (C) 2007  Jorge Cardoso
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *  You can reach me by
 *  email: jorgecardoso <> ieee org
 *  web: http://jorgecardoso.org
 */
import processing.serial.*;
import pt.citar.diablu.processing.nxt.*;


int power = 50;
LegoNXT lego;


void setup() {
  size(400, 400);

  lego = new LegoNXT(this, "/dev/tty.NXT-DevB");
  frameRate(10);
}


void draw() {

}


void keyPressed() {
  println(key);

  if (key == '1') {
    lego.motorForwardLimit(LegoNXT.MOTOR_A, power, 360);
  }   
  else if (key == '2') {
    lego.motorForward(LegoNXT.MOTOR_A, power);
  } 
  else if (key == '+') {
    power += 5;
    println(power);
  } 
  else if (key == '-') {
    power -= 5;
    println(power);
  }
  else if (key =='q') {
    lego.motorHandBrake(LegoNXT.MOTOR_A);
  } 
  else if (key == 's') {
    System.out.println("TL: " + lego.getMotorTachoLimit(LegoNXT.MOTOR_A) + 
      " TC: " +lego.getMotorTachoCount(LegoNXT.MOTOR_A) +
      " BTC: " + lego.getMotorBlockTachoCount(LegoNXT.MOTOR_A) + 
      " RC: " + lego.getMotorRotationCount(LegoNXT.MOTOR_A) );
  } else if (key == 'r') {
    lego.resetMotorPosition(LegoNXT.MOTOR_A, false);
  }

}


void stop() {
  println("Stop");
  lego.motorStop(LegoNXT.MOTOR_A);
}
1 Like

Hello,

Welcome to forum.

Please format your code:
https://discourse.processing.org/faq#format-your-code

:)

1 Like

maybe you can ask the maker of the DiABlu Project or the writer of the code above.

I don’t know the Lego NXT but maybe you can tell it to clear the port?

Also try another port (physically) on your computer please

2 Likes

thank you for your awensers, really appreciate it! i tried to rech the maker but he doesn t awenser.
how do i physically do a port?

I mean just use another usb port on yor computer

Hello,

I have already explored the link and tested code examples and can offer my insight.

I can assist if you format your code and delete your duplicate post; please do this as a courtesy to others.
Try to cut and paste your code and you will see why this is an issue.
You can go back and edit it.

Also you have a duplicate post:

You should delete this.

:)

hey thanks for your awenser. I format the code now. But when i try to delete the duplicate post it says that I dont have permission.

ahh ok, unfortunately nothing changed its still the same error

Hey I try to use processing together with my old lego mindstorm roboter.
I spend a lot of time to research how to combine them and finally found a code online which looked helpfull. But now i get this ERROR can somebody please help me to fix this problem:

jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.openPort(Unknown Source)
at pt.citar.diablu.nxt.protocol.NXTCommBluetoothSerialChannelJSSC.(Unknown Source)
at pt.citar.diablu.processing.nxt.LegoNXT.(Unknown Source)
at sketch_200502a.setup(sketch_200502a.java:64)
at processing.core.PApplet.handleDraw(PApplet.java:2432)
Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.
RuntimeException: jssc.SerialPortException: Port name - /dev/tty.NXT-DevB; Method name - openPort(); Exception type - Port busy.

I merged these posts.

@kanktonk – I hope that you were able to resolve your problem. What did you find online? Where? Can you link to that code, and can you paste it here?

Hi jeremy this is what i found https://www.dexterindustries.com/howto/connect-the-arduino-and-the-lego-mindstorms-together/ but i switched to touchdesigner and arduiono which works quite well

1 Like