7

I get this error when trying to connect to an Arduino through a USB serial connection. I'm using the Arduino IDE 1.0.1 and the 64bit version of Ubuntu 12.04. This has been a reoccurring problem since 10.04 and happens to a few other programs that use a serial connection too. I have no problem getting serial data from the Arduino using Python or Screen. The Arduino IDE seems to work just fine otherwise.

processing.app.SerialException: Error opening serial port '/dev/ttyACM0'.
at processing.app.Serial.<init>(Serial.java:178)
at processing.app.Serial.<init>(Serial.java:92)
at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:207)
at processing.app.Editor.handleSerial(Editor.java:2447)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:353)
at java.awt.Component.processMouseEvent(Component.java:6386)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
at java.awt.Component.processEvent(Component.java:6154)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4750)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4294)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2518)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
at java.awt.EventQueue.access$400(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:631)
at java.awt.EventQueue$2.run(EventQueue.java:629)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$3.run(EventQueue.java:645)
at java.awt.EventQueue$3.run(EventQueue.java:643)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.<init>(Serial.java:163)
... 35 more
JDD
  • 183
  • TYVM! it took hours to find out whats wrong. stopped working suddenly after playing around with various sketches. –  Mar 24 '13 at 22:13

4 Answers4

12

I had this problem too, it turns out it was caused by the Serial Monitor being set to speed 14400. Since you can't change the setting without having a working serial port, the only way to do it is to exit the Arduino UI and edit the preferences.txt file (in Unix, it's in ~/.arduino/preferences.txt). Look for Serial.debug_rate and change it to 9600. Restart the Arduino UI and try uploading a simple sketch (eg. 'blink') and see if it's fix the problem.

I'm not sure why this would happen - I've used 14400 and never had a problem. I guess it's just one of those weird problems that never seems to have a repeatable reason?

lambda23
  • 3,232
  • The two different versions I have were both set to 9600 already. – JDD Oct 04 '12 at 00:44
  • I'm using Ubuntu 14 and the preferences.txt was located at the same place. Speed rate was 38400. When I changed it to 9600 it worked.

    A few days ago it worked just fine without changing anything but ok. Glad this helped :)

    – Handoko Jun 17 '14 at 07:57
  • Yes this worked for me. Make sure you close all your arduino IDE before changing otherwise the IDE will overwrite your existing configuration – xjq233p_1 Jul 07 '14 at 17:29
1

I was having the same error. As far as I can tell, this is a permissions problem. The problem no longer occurred when I ran the Arduino IDE with root permissions. That is, I ran it as:

    sudo ./arduino

I know this is a bad solution, but for now it works. I tried adding read/write access to the serial device file as mentioned in https://wiki.archlinux.org/index.php/arduino, but this had no effect, and still caused the error if I tried running it without root permission. I'm still looking for a better solution.

EDIT :

This problem has been fixed by following the answer given in https://askubuntu.com/a/58122/206687. In short, if you add yourself to the dialout group, the problem should get fixed.

    sudo usermod -a -G dialout $USER

Just logout and log back in again after running this command, and you should be able to access the serial port without any problems.

0

Try to install the 1.0.5 version of the Arduino IDE.

Patterson
  • 1,360
  • 5
  • 16
  • 26
0

I found an easier way without using terminal. In the Arduino IDE, go to File-> Preferences and at the bottom of the popup, they give you a link for the 'preferences.txt' file. Click that and it'll open the text. MAKE SURE AT THIS POINT TO CLOSE YOUR ARDUINO IDE. Make the change to '9600' Serial debug rate and save and exit. Open up your IDE and it should work now.