Receiving "NO CARRIER" error while tring to make a call using GSM modem in Python -
i want make call using gsm modem. wrote below program:
import time import serial recipient = "+98xxxxxxxxxx" phone = serial.serial("com10", 115200, timeout=5) try: time.sleep(0.5) phone.write(b'atz\r') time.sleep(1) phone.write(b'atd"'+recipient.encode() +b'"\r') while(1): print(phone.readline()) time.sleep(0.5) finally: phone.close()
but when run receive output:
>>> ================================ restart ================================ >>> b'atz\r\r\n' b'ok\r\n' b'atdxxxxxxxxxx\r\r\n' b'no carrier\r\n'
what "no carrier" error means?
note can send sms successfully.
this program use send sms:
import time import serial recipient = "+98xxxxxxxxxx" message = "test" phone = serial.serial("com10", 115200, timeout=5) try: time.sleep(0.5) phone.write(b'atz\r') time.sleep(0.5) phone.write(b'at+cmgf=1\r') time.sleep(0.5) phone.write(b'at+cmgs="' + recipient.encode() + b'"\r') time.sleep(0.5) phone.write(message.encode() + b"\r") time.sleep(0.5) phone.write(bytes([26])) time.sleep(0.5) finally: phone.close()
i found origin of error :
the syntax atd+98xxxxxxxxxx;
followed terminating string. forgotten put semicolon @ end after number.
so replace
phone.write(b'atd"'+recipient.encode() +b'"\r')
with
phone.write(b'atd"'+recipient.encode() +b';"\r')
and works fine.
based on brackets in this documents, thought using ";" optional. seems wrong.
Comments
Post a Comment