Pages: [1]   Go Down
Author Topic: Problem with Linux (Mint) Arduino Uno and lost /dev/ttyACM0 ?  (Read 1140 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 22
Uno Otto Otto Cinque
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I lost my connection to /dev/ttyAMC0 after running a java app.
- I've got Arduino 1.01 installed on Linux MInt 14.  (I've also used Win 7, Mac OSX 10.5+, and Gentoo)
- My boards work.
- I also have Oracle JDK installed
cwc@dog26 ~/java $ java -version
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)

-  Here are my groups
cwc@dog26 ~ $ groups
cwc adm dialout cdrom sudo dip plugdev lpadmin sambashare

Here is my tty
- cwc@dog26 ~ $ ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Mar  7 19:01 /dev/ttyACM0,

Here's what happened.
I ran some simple arduino code that collected input from A0 and I was able to get this to work.
And use the serial monitor to get output.
int lightPin = 0;  //define a pin for Photo resistor
int ledPin=11;     //define a pin for LED
int input = 0;
int ainput = 0;
int count = 0;

void setup()
    Serial.begin(9600);  //Begin serial communcation
    pinMode( ledPin, OUTPUT );

void loop()

    analogWrite(ledPin, analogRead(lightPin)/4);  //send the value to the ledPin. Depending on value of resistor
      count ++;
     input = analogRead(lightPin);
     ainput = ainput + input;
     Serial.print('        ');
                                    divide by 4.
  // delay(1000); //short delay for faster response to light.
  if (input < 300) {
  // Serial.print(input);
 //   Serial.print('   ');
//   Serial.println(count);
      count ++;

Then I compiled and ran a application and I lost /dev/ttyACM0 via Arduino


Now I must say I compiled and ran the program with out setting this line correctly fist:
   private static final String PORT_NAMES[] = { "/dev/ttyACM0"};
Here's the Java I ran:
import java.util.Enumeration;

public class SerialTest implements SerialPortEventListener {
SerialPort serialPort;
        /** The port we're normally going to use. */
private static final String PORT_NAMES[] = { "/dev/ttyACM0"};
* A BufferedReader which will be fed by a InputStreamReader
* converting the bytes into characters
* making the displayed results codepage independent
private BufferedReader input;
/** The output stream to the port */
private OutputStream output;
/** Milliseconds to block while waiting for port open */
private static final int TIME_OUT = 2000;
/** Default bits per second for COM port. */
private static final int DATA_RATE = 9600;

public void initialize() {
CommPortIdentifier portId = null;
Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

//First, Find an instance of serial port as set in PORT_NAMES.
while (portEnum.hasMoreElements()) {
CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement();
for (String portName : PORT_NAMES) {
if (currPortId.getName().equals(portName)) {
portId = currPortId;
if (portId == null) {
System.out.println("Could not find COM port.");

try {
// open serial port, and use class name for the appName.
serialPort = (SerialPort),

// set port parameters

// open the streams
input = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
output = serialPort.getOutputStream();

// add event listeners
} catch (Exception e) {

* This should be called when you stop using the port.
* This will prevent port locking on platforms like Linux.
public synchronized void close() {
if (serialPort != null) {

* Handle an event on the serial port. Read the data and print it.
public synchronized void serialEvent(SerialPortEvent oEvent) {
if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
String inputLine=input.readLine();
} catch (Exception e) {
// Ignore all the other eventTypes, but you should consider the other ones.

public static void main(String[] args) throws Exception {
SerialTest main = new SerialTest();
Thread t=new Thread() {
public void run() {
//the following line will keep this app alive for 1000 seconds,
//waiting for events to occur and responding to them (printing incoming messages to console).
try {Thread.sleep(1000000);} catch (InterruptedException ie) {}

dog26 ~ # lspci
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 1 (rev 01)
00:1c.1 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 2 (rev 01)
00:1c.3 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 4 (rev 01)
00:1d.0 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #1 (rev 01)
00:1d.1 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #2 (rev 01)
00:1d.2 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #3 (rev 01)
00:1d.3 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #4 (rev 01)
00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 01)
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7-M Family) SATA Controller [IDE mode] (rev 01)
02:06.0 CardBus bridge: Texas Instruments PCIxx12 Cardbus Controller
02:06.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)
02:06.3 SD Host controller: Texas Instruments PCIxx12 SDA Standard Compliant SD Host Controller
02:06.4 Communication controller: Texas Instruments PCIxx12 GemCore based SmartCard controller
08:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5753M Gigabit Ethernet PCI Express (rev 21)
10:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection (rev 02)

« Last Edit: March 09, 2013, 06:38:13 am by 1885 » Logged

cwc 1885

Manchester NH
Offline Offline
Full Member
Karma: 1
Posts: 112
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm bumping this because I'm interested too. You gave good info, but I think you need to simplify a bit for other folks to make suggestions. I doubt there are many doing exactly what your doing so there is quite a bit of guess work in helping here. 

I'm also using mint 14 and I'm curious about something that may or may not be related.
Bugs-- off-set menus and selected menu items (board, port) completely whited out. Is this happening to you?

Offline Offline
Faraday Member
Karma: 47
Posts: 3504
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You say you have "lost" ttyacm0 but you haven't said exactly what error message you get.

I haven't read through your Java code (life is too short?) and I wonder if it closes the connection when it is finished.

You can't connect two programs to the same serial port at the same time afaik.

Does the problem sort itself out if you reboot the PC and run the Arduino program before the Java program?

Does the problem sort itself if you use system monitor to kill Java? (which won't do any harm unless you are running a life-support system!). There could be a few copies of Java running - kill them all.


Pages: [1]   Go Up
Jump to: