Serial: Port busy

Hi there!

After googling for more than 3 hours, i will post my question to you. Before i do that, please execute my bad english.

I'm trying to communicatio with my arduino over /dev/ttyACM0. The code on the arduino is OK and the processing code also does its job if i run processing with sudo rights. I can talk to my arduino over this Port within the arduino GUI as a normal user.

BUT: I can't access this serial port as a normal user in processing. I also can't access a USB2Serial Device on /dev/ttyUSB0 in processing.

I'm running processing under Linux Mint (newest Version) and added my user to this groups:

adm uucp dialout cdrom floppy sudo dip plugdev fuse lpadmin sambashare

If i run this code:

import processing.serial.*;  // Import Serial library to talk to Arduino 
import processing.opengl.*; //  Import OpenGL to draw a gradient window

int channel1;  // create a variable to hold the data we are sending to the Arduino
int channel2;
Serial myPort; 

// Send new DMX channel value to Arduino
void setDmxChannel(int channel, int value) {
  // Convert the parameters into a message of the form: 123c45w where 123 is the channel and 45 is the value
  // then send to the Arduino
  myPort.write( str(channel) + "c" + str(value) + "w" );

// Draw gradient window
void drawGradient() {
  // Draw a colour gradient
  fill(0,0,255); vertex(0,0); // Top left BLUE
  fill(255,0,0); vertex(width,0); // Top right RED
  fill(255,255,0); vertex(width,height); // Bottom right RED + GREEN
  fill(0,255,255); vertex(0,height); // Bottom left BLUE + GREEN

void setup() {
  println(Serial.list()); // shows available serial ports on the system
  // Change 0 to select the appropriate port as required.
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);

  size(512,512,OPENGL);  // Create a window

void draw() {
  channel1 = (255 * mouseX / width); // Use cursor X position to get channel 1 value
  channel2 = (255 * mouseY / height);// Use cursor Y position to get channel 2 value
  setDmxChannel(1,channel1); // Send new channel values to Arduino

  // You may have to set other channels. Some lamps have a shutter channel that should be set to 255.
  // Set it here:

  delay(50);  // Short pause before repeating

i get the following Error:

/dev/ttyACM0 /dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3 /dev/ttyS4 /dev/ttyS5 /dev/ttyS6 /dev/ttyS7 /dev/ttyS8 /dev/ttyS9 /dev/ttyS10 /dev/ttyS11 /dev/ttyS12 /dev/ttyS13 /dev/ttyS14 /dev/ttyS15 /dev/ttyS16 /dev/ttyS17 /dev/ttyS18 /dev/ttyS19 /dev/ttyS20 /dev/ttyS21 /dev/ttyS22 /dev/ttyS23 /dev/ttyS24 /dev/ttyS25 /dev/ttyS26 /dev/ttyS27 /dev/ttyS28 /dev/ttyS29 /dev/ttyS30 /dev/ttyS31 /dev/ttyUSB0
libEGL warning: failed to create a pipe screen for i965
Smooth is not supported by this hardware (or driver)
/dev/ttyACM0 /dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3 /dev/ttyS4 /dev/ttyS5 /dev/ttyS6 /dev/ttyS7 /dev/ttyS8 /dev/ttyS9 /dev/ttyS10 /dev/ttyS11 /dev/ttyS12 /dev/ttyS13 /dev/ttyS14 /dev/ttyS15 /dev/ttyS16 /dev/ttyS17 /dev/ttyS18 /dev/ttyS19 /dev/ttyS20 /dev/ttyS21 /dev/ttyS22 /dev/ttyS23 /dev/ttyS24 /dev/ttyS25 /dev/ttyS26 /dev/ttyS27 /dev/ttyS28 /dev/ttyS29 /dev/ttyS30 /dev/ttyS31 /dev/ttyUSB0
java.lang.RuntimeException: java.lang.RuntimeException: Error opening serial port /dev/ttyACM0: Port busy
    at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(
    at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(
    at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(
    at processing.opengl.PJOGL.requestDraw(
    at processing.opengl.PGraphicsOpenGL.requestDraw(
    at Source)
Caused by: java.lang.RuntimeException: Error opening serial port /dev/ttyACM0: Port busy
    at processing.serial.Serial.<init>(Unknown Source)
    at processing.serial.Serial.<init>(Unknown Source)
    at p1.setup(
    at processing.core.PApplet.handleDraw(
    at processing.opengl.PJOGL$PGLListener.display(
    at jogamp.opengl.GLDrawableHelper.displayImpl(
    at jogamp.opengl.GLDrawableHelper.display(
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(
    at jogamp.opengl.GLDrawableHelper.invokeGL(
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$ Source)
    at java.awt.EventQueue$ Source)
    at Method)
    at$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at Source)

Had anyone had the same problem or can someone help me please?

Thank You.



  • edited May 2014

    I am having similar issues with arduino and processing. If i run the following code I get:

    java.lang.RuntimeException: java.lang.RuntimeException: Error opening serial port /dev/ttyACM0: Port busy

    If I remove the "P3D" lines, I need for the keystone library to work, the connection to the arduino is successful. I guess there is something not working between P3D and arduino. as indicated here:

    import deadpixel.keystone.*; //keystone library
    import processing.serial.*; //arduino
    import cc.arduino.*; //arduino
    Keystone ks;
    CornerPinSurface surface;
    Arduino arduino;
    PGraphics offscreen;
    int buttonPin = 2; //arduino read pin
    int sau; //arduino switch
    int surp = 0; //increase of colour
    ///////////////////////////////// SETUP ////////////////////////////////
    void setup() {
      //Arduino Setup
      arduino = new Arduino(this, Arduino.list()[0], 57600);
      arduino.pinMode(buttonPin, Arduino.INPUT);
      colorMode(HSB); //change the color mode, so the whole color change thing is easier
      //keystone surface
      size(1000,1000, P3D); //P§D important for keystone, since it relies on texture mapping to deform
      ks = new Keystone(this);
      surface = ks.createCornerPinSurface(1000, 1000, 20);
      // We need an offscreen buffer to draw the surface we
        // want projected
        // note that we're matching the resolution of the
        // CornerPinSurface.
        // (The offscreen buffer can be P2D or P3D)
      offscreen = createGraphics(1000, 1000, P3D);
    ///////////////////////////////// DRAW ////////////////////////////////
    void draw() {
      //sau = arduino.digitalRead(buttonPin);
      // Convert the mouse coordinate into surface coordinates
      // this will allow you to use mouse events inside the 
      // surface from your screen. 
      PVector surfaceMouse = surface.getTransformedMouse();
      // Draw the scene, offscreen
      offscreen.ellipse(surfaceMouse.x, surfaceMouse.y, 75, 75);
      offscreen.vertex(660, 260);
      offscreen.vertex(860, 260);
      offscreen.vertex(860, 580);
      offscreen.vertex(660, 580);
      // render the scene, transformed using the corner pin surface
    //if (sau == 1) {  // when the button is pushed
    //        surp+=20;   //...set the color to black
    //void mousePressed(){ // pressing the mouse
    //  surp+=20; 
    void keyPressed() { //function for keystone
      switch(key) {
      case 'c':
        // enter/leave calibration mode, where surfaces can be warped 
        // and moved
      case 'l':
        // loads the saved layout
      case 's':
        // saves the layout;
  • I think I solved it, at least my problem.

    just moved the size() line to the beginning of void setup before the arduino stuff.

  • Yea. You got it.

    Your hint worked for me. "moved the size() line to the beginning of void setup". I'am still confused that it worked as root!?!?

    But Thank you very much sektionschef.

Sign In or Register to comment.