MKN96
Posts: 1
Joined: Tue Dec 12, 2017 10:11 am

error msg

Tue Dec 12, 2017 10:26 am

Hello guys
im quite new for the python
so i'm using raspberry pi3 model b
and im trying to connect a gsm/gprs sim900 arduino based shield directly to the gpio serial pins 8&10
i tried this this example below :
import serial
import os
import time
ser = serial.Serial ("/dev/ttyUSB0" , 9600 )
ser.write("AT\r")
response = ser.readlines(None)
ser.write("AT+CMGF=1\r")
response = ser.readlines(None)
ser.write('AT+CMGS=”++218922607837”\r')
response = ser.readlines(None)
ser.write("Hello Raspberry Pi")
ser.write(chr(26))
time.sleep(10)
ser.close( )

*****
im using python 2.7.13
when i run the module i get this error:
Traceback (most recent call last):
File "/home/pi/Desktop/GSMfinal.py", line 4, in <module>
ser = serial.Serial ("/dev/ttyUSB0" , 9600 )
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 236, in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 268, in open
raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
SerialException: [Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

****
know that the connection betxeen the gsm and rpi is:
GNd >>GND
TX>>RX
RX>>TX
and external power jack providing 6v with current 1A

****
Hope someone tell me what to do for sending a just one simple sms

User avatar
DougieLawson
Posts: 34175
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: error msg

Thu Dec 14, 2017 11:47 am

sudo apt install lsof # if it's not already installed.
sudo lsof /dev/ttyUSB0

That will tell you what process is using the device file.
Note:The use of baseball bats for educational purposes is completely disallowed on this forum.

Any DMs sent on Twitter will be answered next month.

Return to “Python”