6

This problem doesn't seen to be very common around the Arduino community.

Basically, what's happening is that as soon as I click the upload button, the Arduino IDE tells me that my Arduino board is not connected. What's strange though is that the python application ino is able to upload my code just fine, so my only guess is that there is something wrong with the IDE itself.

Here's a copy of the error message I am getting at the time of uploading the sketch:

Binary sketch size: 444 bytes (of a 32,256 byte maximum)processing.app.SerialException: Error opening serial port '/dev/ttyACM1'.at processing.app.Serial.<init>(Serial.java:178)at processing.app.Serial.<init>(Serial.java:77)at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:174)at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)at processing.app.Sketch.upload(Sketch.java:1671)at processing.app.Sketch.exportApplet(Sketch.java:1627)at processing.app.Sketch.exportApplet(Sketch.java:1599)at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)at java.lang.Thread.run(Thread.java:744)Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameterat gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:213)at processing.app.Serial.<init>(Serial.java:163)... 9 moreprocessing.app.debug.RunnerException: Error opening serial port '/dev/ttyACM1'.at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:101)at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:174)at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)at processing.app.Sketch.upload(Sketch.java:1671)at processing.app.Sketch.exportApplet(Sketch.java:1627)at processing.app.Sketch.exportApplet(Sketch.java:1599)at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)at java.lang.Thread.run(Thread.java:744)

I am expecting to hear a few questions regarding this issue, so I'll go ahead and answer all the questions I can think of.

Is this the first time you trying to connect to the Arduino from this computer?

No. In fact, I was able to upload the same source code just fine less than two hours ago.

Did you try a different USB cord?

Yes, I did.

Can you upload the source code from a different computer?

Yes, I can.

Have you tried removing and reinstalling the IDE?

Yes, I have.

Have you tried a different USB port?

Yes, I have.

What seems to be the problem here?

chicks
  • 213
  • 4
  • 10
  • 1
    What platform are you on? – jippie Mar 06 '14 at 19:38
  • @jippie Peppermint Linux – Fadi Hanna AL-Kass Mar 06 '14 at 19:41
  • Does `ls -l /dev/ttyACM*` list the exact device that is mentioned in the error message, and is this the exact device set in the Arduino IDE under Tools => Serial Port? – jippie Mar 06 '14 at 20:05
  • `/dev/ttyACM1` was the port to the board until it got disconnected. So in short, when I click `upload`, it starts uploading then stops half way through and prints out the error message mentioned in the question above. I know the IDE is what is disconnecting the board. What I want to know is why! – Fadi Hanna AL-Kass Mar 06 '14 at 20:11
  • Are any devices / peripherals connected to the Arduino? If so, disconnect everything then try to program it. – jippie Mar 06 '14 at 20:16
  • Please consider switching to a more recent version of the IDE: version 1.5.6 has replaced buggy and old RXTX library with JSSC. Updating may not solve your problem, but at least it makes sure you're not facing old and already solved problems. – Federico Fissore Mar 06 '14 at 22:08
  • I'm having a similar situation on my older work computer.. I feel like it is the hardware on the computer (HP xw9400 Workstation) that is causing the the Arduino to keep connecting and diconnecting. Perhaps it is a low power signature coming in from the Arduino that the usb port "loses" the Arduino. I will try with another computer to see if this is the case. – jgmechengr19 Nov 30 '16 at 22:18

4 Answers4

4

First of all, you must test if the device that you are trying to access, actually exists. The device file may change when you replug the Arduino. The easiest way to accomplish that is to find the device name in the error message, in this case /dev/ttyACM1. Then check two things:

  1. Does the device file exist in the /dev tree? ls -l /dev/ttyACM*
  2. Is the Arduino IDE configured to use the correct device? Check under Tools => Serial Port.

Maybe another application is using the device. When working on Linux, you can verify this with the following commands:

$ lsof /dev/ttyUSB0
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
avrdude 7356   jippie    3u   CHR  188,0      0t0 266450197 /dev/ttyUSB0

or

€ fuser /dev/ttyUSB0
/dev/ttyUSB0:         7356

Where of course you have to replace /dev/ttyUSB0 with the device file as mentioned in the error message. In case of this question /dev/ttyACM1, but do notice that the number can change when you unplug the board for a moment and then replug it.

In both results, the 7356 is the PID of the process that is locking the device. In my example I was reading flash from the command line, so the output for your specific situation will be different. To identify the process, you can use:

$ ps -fp 7356
UID      PID  PPID  C STIME TTY          TIME CMD
jippie  7698 28116  1 20:34 pts/8    00:00:00 avrdude -patmega1280 -carduino -P/dev/ttyUSB002 -b57600 -D -Uflash:r:/tmp/flash:i

or a more portable command:

$ ps -ef | grep 7356
jippie  7698 28116  1 20:34 pts/8    00:00:00 avrdude -patmega1280 -carduino -P/dev/ttyUSB002 -b57600 -D -Uflash:r:/tmp/flash:i
jippie
  • 2,851
  • 12
  • 23
  • If another application is using the device, how come I can still upload to the board from `ino`? – Fadi Hanna AL-Kass Mar 06 '14 at 20:04
  • @FadiHannaAL-Kass Good question. Did `fuser` or `lsof` list a PID? Maybe there is something else going on. – jippie Mar 06 '14 at 20:09
  • @FadiHannaAL-Kass For example, I have a daemon running on my PC that queries my Arduino only every so many seconds. If I am attempting to program that Arduino, and the query comes along, then the program cycle fails. Maybe some serial monitoring program is running? – jippie Mar 06 '14 at 20:19
  • I have already used `ls -al` to make sure the device exists. I also unplugged the board and ran the command again to make sure I am looking for the right device. The Arduino IDE is pointing to the right port as well. When I `upload` and get the error message, the Tools --> Serial Port menu gets disables, so that's another way to know the device has been disconnected while uploading. `lsof`and `fuser`, however, don't list a PID, so now I also know no other application is interrupting the upload process! – Fadi Hanna AL-Kass Mar 06 '14 at 20:23
  • I might be able to get away with Installing a new Linux version, but I want to be prepared in case this happens ever again – Fadi Hanna AL-Kass Mar 06 '14 at 20:23
  • 2
    @FadiHannaAL-Kass Reinstalling Linux is not going to solve your issue. In the Windows world people reboot their system, reinstall their machine. In the Unix/Linux world, we figure out why things happen and fix them. – jippie Mar 06 '14 at 20:24
  • It most likely will, as I have performe the exact same process on a different Linux distro on the same machine, and everything worked fine – Fadi Hanna AL-Kass Mar 06 '14 at 20:25
  • @FadiHannaAL-Kass isn't it more effective to figure out why things go wrong and subsequently fix them, rather than reinstalling your PC every time something happens that you don't understand (yet)? – jippie Mar 06 '14 at 20:27
  • exactly. that's why I said I want to be prepared in case this ever happens again – Fadi Hanna AL-Kass Mar 06 '14 at 20:28
2

A pretty detailed troubleshooting guide is available at arduino.cc. Besides the checks already mentioned in the question and the answers, it is recommended to check that serial.download_rate is set to 19200 in ~/.arduino/preferences.txt.

19200 is the default baud rate used by most bootloaders, so this doesn't apply if you don't use one, or use a modified version.

Dmitry Grigoryev
  • 1,248
  • 9
  • 30
1

I have same problem after set baud rate to 14400. For fix this I manual set serial.debug_rate=115200 in config file ~/.arduino/preferences.txt

Pavel
  • 21
  • 1
1

Try setting the baud rate to 9600 in the Serial Monitor. You need a working serial port to open the Serial Monitor. Or go to >File >Preferences> and edit the preferences.txt (must close Arduino IDE before editing) "serial.debug_rate=9600"

I have several Arduino boards and had the exact same issue with the boards that use the Atmel mega8U2 as the USB - serial bridge. The boards with the FTDI USB bridge (SparkFun Red board, Pro mini) did not show the same problem. Setting the baud rate solved my problem.

There is a firmware upgrade for 8U2 that might fix it but I didn't want to risk making bricks. ;-)

mc789
  • 11
  • 2