Serial interface busy

Some while ago I ran one of the example sketches which displayed the current time, having initialised the Arduino time from Linux/Ubuntu using “date +T%s\n >/dev/ttyACM0” at the console. This worked fine.

I am now trying to get the example sketch time serial to work (and hoping to incorporate this in my project sketch) on another machine, but when attempting to issue the date command get ‘device or resource busy’.

I can’t work out what is now different, nor how to resolve the issue. This appears to be more of an Ubuntu/Debian Linux issue, but I am not sure.

Any ideas/suggestions

You need to post the program that you are having trouble with.

What Arduino board are you using?

Also post the exact error message that you are getting.


I would guess that you already have /dev/ttyACM0 open displaying information received from the Arduino therefore when you attempt to transmit information using "date +T%s\n >/dev/ttyACM0" the command finds that /dev/ttyACM0 is already in use and displays the error message

My own code is based on the example code Time Serial reproduced below, and in essence they are behaving the same.

As Horace indicated it does seem that the serial link (this is the USB link between the laptop running IDE) and the Arduino Uno) remains busy after issuing the invitation "Waiting for sync message".

The failure is from the Linux end, in that the date command below fails with the message 'device or resource busy'. 

This worked before (on another laptop, with a recent but older installation of the IDE). An asynchronous serial link should in essence be bidirectional? - that is the definition of asynchronous as opposed to synchronous communication. 

I don't follow where to find the "processing example sketch included in the download of Linux, but am using the console command date. 


 * TimeSerial.pde
 * example code illustrating Time library set through serial port messages.
 * Messages consist of the letter T followed by ten digit time (as seconds since Jan 1 1970)
 * you can send the text on the next line using Serial Monitor to set the clock to noon Jan 1 2013
 * A Processing example sketch to automatically send the messages is included in the download
 * On Linux, you can use "date +T%s\n > /dev/ttyACM0" (UTC time zone)
#include <TimeLib.h>

#define TIME_HEADER  "T"   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

void setup()  {
  while (!Serial) ; // Needed for Leonardo only
  pinMode(13, OUTPUT);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");

void loop(){    
  if (Serial.available()) {
  if (timeStatus()!= timeNotSet) {
  if (timeStatus() == timeSet) {
    digitalWrite(13, HIGH); // LED on if synced
  } else {
    digitalWrite(13, LOW);  // LED off if needs refresh

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

void processSyncMessage() {
  unsigned long pctime;
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013

  if(Serial.find(TIME_HEADER)) {
     pctime = Serial.parseInt();
     if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013)
       setTime(pctime); // Sync Arduino clock to the time received on the serial port

time_t requestSync()
  return 0; // the time will be sent later in response to serial mesg

FWIW I have followed a thread experiencing similar problems, and experimented a bit, but I am a member of the dialout group, the permissions seem ok, and the same error occurs when command executed as sudo root.

The command works ok when first logged in, but as soon as the IDE is started it fails. It seems as if the IDE is holding onto the port.

If the Arduino is loaded with the sketch, and then reset, and the command issued before invoking the IDE, the board responds to the command. However, without the IDE there is nothing to see what is happening, if anything.

if you already have /dev/ttyACM0 open in a process you cannot run another process to use the console to transmit the date to /dev/ttyACM0 Are you using a the arduino IDE Serial Monitor or a Serial terminal emulator to communicate with the arduino? I seem to remember that some terminal emulators allow one to execute a shell command the results of which are transmitted it may be worth moving this tread to Interfacing w/ Software on the Computer

The Windows terminal emulator teraterm pro allows the execution of macros during interaction over a serial communications link. There are a number of UNIX terminal emulators (putty, minicom, etc) which allow excution of a script at startup (e.g. to login to a remote system) I have uploaded a terminal emulator implemented in Java swing. Using the menu Options > Execute Command a shell command may be executed and the output transmitted to the serial port. The image shows the terminal emulator running under Ubuntu Linux and executing the Unix date shell command