Python Sim900找不到网络

Python Sim900找不到网络,python,networking,at-command,sim900,Python,Networking,At Command,Sim900,我有一个来自的Sim900。我有一个从Raspberry Pi到Sim900的串行连接。我可以编写命令,接收响应,甚至可以从Sim卡查询我的电话号码等数据。我的Sim卡是AT&T卡。我无法让Sim900找到网络并尝试连接。据说,它应该自己做,但我也没有看到。我能想到的只有两件事,要么是固件错误,要么是芯片没有获得足够的电源。AT+CGMR的固件版本为:1137B06SIM900M64_ST_。这似乎是您可以从中获得的最新固件。至于电源,我非常肯定电源是足够的,因为我买了一个充电器usb电缆和适配

我有一个来自的Sim900。我有一个从Raspberry Pi到Sim900的串行连接。我可以编写命令,接收响应,甚至可以从Sim卡查询我的电话号码等数据。我的Sim卡是AT&T卡。我无法让Sim900找到网络并尝试连接。据说,它应该自己做,但我也没有看到。我能想到的只有两件事,要么是固件错误,要么是芯片没有获得足够的电源。AT+CGMR的固件版本为:1137B06SIM900M64_ST_。这似乎是您可以从中获得的最新固件。至于电源,我非常肯定电源是足够的,因为我买了一个充电器usb电缆和适配器,其中的适配器,随电缆承诺支持2安培。我剥去电缆,给它3安培的电源。当我尝试连接时,芯片也不会随机复位。我可以设置掉电时丢失的设置,但它们只有在我拔下芯片重置设置时才会消失

下面的输出来自我最近的一次测试,试图理解我为什么不能发送短信

----------------------------------------------------------------------------------------
Command: "b'AT\r\n\r\n'" Response: "AT


OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMEE=2\r\n'" Response: "AT+CMEE=2

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CFUN?\r\n'" Response: "AT+CFUN?

+CFUN: 1

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG=2\r\n'" Response: "AT+CREG=2

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG?\r\n'" Response: "AT+CREG?

+CREG: 2,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+COPS?\r\n'" Response: "AT+COPS?

+COPS: 0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+QBAND?\r\n'" Response: "AT+QBAND?

ERROR
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSQ\r\n'" Response: "AT+CSQ

+CSQ: 20,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+QENG?\r\n'" Response: "AT+QENG?

ERROR
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CIMI\r\n'" Response: "AT+CIMI

310REDACTED

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CNUM\r\n'" Response: "AT+CNUM

+CNUM: "","1678REDACTED",129,7,4

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMGF=1\r\n'" Response: "AT+CMGF=1

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSCS=?\r\n'" Response: "AT+CSCS=?

+CSCS: ("IRA","GSM","UCS2","HEX","PCCP","PCDN","8859-1")

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSCS="GSM"\r\n'" Response: "AT+CSCS="GSM"

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG?\r\n'" Response: "AT+CREG?

+CREG: 2,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMGS="978REDACTED"\r'" Response: "AT+CMGS="978REDACTED"

> "
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'Pi\x1a'" Response: "Pi
+CMS ERROR: operation not allowed
"
----------------------------------------------------------------------------------------
生成此输出的Python3脚本如下所示:

import serial
import time
import binascii

ser = serial.Serial(port='/dev/serial0',baudrate=9600,timeout=1)

command = bytes("AT" + '\r\n', 'utf-8') + binascii.a2b_hex('0D0A')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CMEE=2'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes("ATE0" + '\r\n', 'utf-8')) # Reverse it with ATE
#rcv = ser.read(1000)
#print(rcv)
#time.sleep(1)

command = bytes('AT+CFUN?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG=2'+'\r\n', 'utf-8') # What does 2 do?
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#command = bytes('AT+COPS=?'+'\r\n', 'utf-8')
#ser.write(command)
#rcv = ser.read(1000)
#print("----------------------------------------------------------------------------------------")
#print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
#print("----------------------------------------------------------------------------------------")
#time.sleep(10)

command = bytes('AT+COPS?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes('AT+COPS=0'+'\r\n', 'utf-8'))
#rcv = ser.read(1000)
#print("\"%s\"" % rcv.decode())
#time.sleep(1)

command = bytes('AT+QBAND?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSQ'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+QENG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CIMI'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CNUM'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes('AT+CNMI=2,1,0,0,0'+'\r\n', 'utf-8'))
#rcv = ser.read(1000)
#print(rcv)
#time.sleep(1)

# TEXTING

command = bytes('AT+CMGF=1'+'\r\n', 'utf-8') # Select Message format as Text mode 
ser.write(command) 
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSCS=?'+'\r\n', 'utf-8') # Possible Value: GSM
ser.write(command) 
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSCS="GSM"'+'\r\n', 'utf-8') # Possible Value: (8859-1/latin-1)
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CMGS="978REDACTED"', 'utf-8') + binascii.a2b_hex('0D') # 0D is CR
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(5)

command = bytes("Pi",'utf-8') + binascii.a2b_hex('1A')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(5)

#ser.write(binascii.a2b_hex('0D0A')) # 0D is CR
#rcv = ser.read(1000)
#print("\"%s\"" % rcv.decode())
同样,在minicom中运行时也会发生同样的问题。这不是Python特有的问题。尽管在+COPS=?处显示AT命令中的数据时存在问题?在Python中。然而,显示错误是另一天的问题,因为我仍然可以在minicom中阅读它

编辑:澄清问题

基本上,我想知道为什么我不能发送短信,以及如何修复它!我确信这与没有在任何网络上注册有关,但是在+COPS=?。请列出任何可能的原因。如果需要的话,我可以做一些事情,比如给我的设置拍照

编辑:为AT+COPS=?提供一些见解

使用Minicom,我得到以下AT+COPS=?。我无法在Python3中测试此命令,因为它会使来自自身和所有其他未来命令的反馈为空,如空引号,例如。即使启用CMEE来提供详细的文本,这也是一个问题。当我重置Python程序时,它会被重置

AT+COPS=?
+COPS: (1,"Off Network","","310260"),,(0,1,4),(0,1,2)

OK
无论我将CREG设置为什么,每次运行命令时都会得到上述结果

链接:

事实证明,我的代码或硬件都没有问题。这是我的网络提供商AT&T的问题。现在,我知道他们已经摆脱了2G,但我不知道这也意味着电话和短信。因为我忘了打电话和发短信不是按照各自的协议。因为我是在手机上输入的,所以我会用截图来显示我的意思

这是网络子模式的列表。我的手机通常是LTE数据的首选。我的GSM芯片使用第二个选项,显然是GSM。我可能能够破解一个较慢的LTE连接,因为我仍然支持这种频段。我只需要看看破解固件的可行性

这就是我的LTE网络列表在基本上以+COPS=

这是我的GSM芯片看到的相同输出。这是与GSM选项。选择断开网络选项时,我无法呼叫任何人


有鉴于此,我需要找到一家支持GSM的运营商,将固件组装起来以支持慢速LTE,或者砍掉我的手臂,在黑市上出售一块昂贵的LTE芯片。

sim卡在智能手机上工作吗?是的,它工作正常,而且也没有pin码。如果我们到20日还不能找出问题所在,然后我将使用不同的sim卡进行测试。我应该在那一天从谷歌那里拿到我的项目Fi-sim,邮局将在下周一开放,这样我就可以知道它是否有AT&T,这就是问题所在。鉴于此,固件问题中链接的SimCom页面称AT&T是受支持的运营商。我想我们会找到答案的。你可能想问问这个。不!不不你应该。您必须读取并解析调制解调器返回的响应,否则您将丢失这些命令。所有AT命令都应与LTE兼容。其中一些命令在注册网络参数的访问技术中具有可见的痕迹。当然,网络可能配置了不同的支持,但不支持SMS消息似乎更为明智。