title: Send SMS via a USB Dongle/Python
body: <p>I want to send sms using a dongle. I found the following code from <a href="http://linux-101.org/script/python-code-sending-sms-messages-usb-connected-mobile-phone" rel="nofollow">this</a> site and adopted it. But it gives the flowing error.  Can somebody please help me to make this script working.</p>
  
  <p>Error: </p>
  
  <pre><code>   raise SerialException("could not open port %s: %s" % (self._port, msg))
  serial.serialutil.SerialException: could not open port /dev/ttyACM0: [Errno 2] No such file or directory: '/dev/ttyACM0'
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>import serial
  import time
  
  class TextMessage:
      def __init__(self, recipient="0123456789", message="TextMessage.content not set."):
          self.recipient = recipient
          self.content = message
  
      def setRecipient(self, number):
          self.recipient = number
  
      def setContent(self, message):
          self.content = message
  
      def connectPhone(self):
          self.ser = serial.Serial('/dev/ttyACM0', 460800, timeout=5)
          time.sleep(1)
  
      def sendMessage(self):
          self.ser.write('ATZ\r')
          time.sleep(1)
          self.ser.write('AT+CMGF=1\r')
          time.sleep(1)
          self.ser.write('''AT+CMGS="''' + self.recipient + '''"\r''')
          time.sleep(1)
          self.ser.write(self.content + "\r")
          time.sleep(1)
          self.ser.write(chr(26))
          time.sleep(1)
  
      def disconnectPhone(self):
          self.ser.close()
  
  sms = TextMessage("0123456789","This is the message to send.")
  sms.connectPhone()
  sms.sendMessage()
  sms.disconnectPhone()
  </code></pre>