Posts: 28
Joined: Mon May 26, 2014 9:21 pm

Port "busy" when trying to send AT commands to modem

Tue Dec 18, 2018 6:04 pm

I'm using a Telit USB modem. When I plug it into the latest Stretch image, I see it enumerate as several USB ports.


I want to send AT commands to it. But when I try, I get a port busy (I think). I've tried using both Screen and Python script to send AT commands. The python script returns an error that the port is busy. Screen just terminates without giving a reason.

I've included what my inputs and outputs are below. I do have modem and network manager installed, but it's not set to autoconnect.

Here's the output from Screen (I think ACM3 should be the correct port, but I tried both).
[email protected]:~/modem $ screen /dev/ttyACM3 9600
[screen is terminating]
[email protected]:~/modem $ screen /dev/ttyACM0 9600
[screen is terminating]
[email protected]:~/modem $
My python script using the serial library returns a port busy error:

Code: Select all

import serial
import time

phone = serial.Serial("/dev/ttyACM3", baudrate=9600, timeout=2.0)

print (result)
Traceback (most recent call last):
File "", line 4, in <module>
phone = serial.Serial("/dev/ttyACM3", baudrate=9600, timeout=2.0)
File "/usr/lib/python3/dist-packages/serial/", line 236, in __ini t__
File "/usr/lib/python3/dist-packages/serial/", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._p ort, msg))
serial.serialutil.SerialException: [Errno 16] could not open port /dev/ttyACM3: [Errno 16] Device or resource busy: '/dev/ttyACM3'

Here's the mmcli output. It seems to indicate that ttyACM3 is for AT commands.


User avatar
Posts: 5776
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Port "busy" when trying to send AT commands to modem

Wed Dec 19, 2018 6:58 pm

There is a commandline tool called "lsof" which lists all open files and which programs that uses them. It might point you in the direction of the culprit.

Posts: 64
Joined: Mon Dec 11, 2017 9:58 pm

Re: Port "busy" when trying to send AT commands to modem

Wed Dec 19, 2018 7:22 pm

You have to terminate screen correctly. Ctrl+A \ then answer yes to the question.
All other methods back to a command prompt leave a lock on /dev/ttyACMx
Using lsof which you will have to install will help.

Code: Select all

sudo apt-get install lsof
Then kill the processes which have the file in question open.

Code: Select all

kill -term <pid>

Posts: 693
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Port "busy" when trying to send AT commands to modem

Thu Dec 20, 2018 2:25 pm

if you are running Stretch with Desktop, it could be that ModemManager has grabbed the ports.

Code: Select all

sudo systemctl stop ModemManager
and see if the ports are then acessible.


Return to “Troubleshooting”