#!/usr/bin/python
#****************************************
#   send_text.py
#   by Michael Wright, Y2kLeader.com
#   To execute type: 
#   pythone3 send_text.py
#****************************************
import sys
import os
import time
import serial
import io
#open the usb port for the modem
ser=serial.Serial('/dev/ttyUSB3',115200,timeout=.5)

def send(command):
   #This function sends the command to the modem
   command=command+"\r"
   ser.write(command.encode())
   time.sleep(.1)  

phone_number = input('The phone number of the receiver: ') 
message = input('Type your message here: ') 
send("AT+CMGF=1")
send('AT+CSCS="GSM"')
send('AT+CMGS="'+phone_number+'"')
send(message+"\x1a") #send Ctrl+Z
ser.close()


