I need answer for strange situation which occurs sometimes when I jamming the GSM.
I set JDR by AT#JDR=2,70,5 command
I start jamming.
I run “test()” in while with “cmd” = “+CREG?”
The “print s” result contain information about jammer and CREG but why the CREG “\r\nOK\r\n” was printed as “\r\nO” and “K\r\n”.
How to prevent for this?
Below code for test:
_STOP = “\r\nOK\r\n”
_ERROR = “\r\nERROR\r\n”
def test(cmd):
if MDM.send(“AT%s\r” % (cmd, ), 20) == -1:
raise IOError, “\r\nAT%s” % (cmd, )
l = “”
stop = None
while not stop:
s = MDM.receive(51)
print s # Test point
l = “%s%s” % (l, s)
if l.find(_STOP) != -1:
stop = 0xFF
s = _STOP
elif l.find(_ERROR) != -1:
stop = l
s = _ERROR
ans = 0
The return value will be the first string received no matter the timeout value.
If you want to ensure all data is received is better to implement a read routine based on 2 exit conditions, a group of expected characters and a max timeout, like below:
def Chat(command, expected, timeout): timer = MOD.secCounter() + timeout MDM.send(command, 5) b = command + MDM.read() while (MOD.secCounter() < timer) and (b.find(expected) == -1): b = b + MDM.read() return b
We use cookies to enhance your browsing experience and help us improve our websites. To improve our website, we carefully select third parties that use cookies to allow us to serve specific content and achieve the purposes set out in our cookie policy. For more information on how to make adjustments through your browser to the cookies being used on your device, please click Find Out More link. By closing this banner or continuing to browse our website, you agree to our use of such cookies. FIND OUT MORE
If you want to ensure all data is received is better to implement a read routine based on 2 exit conditions, a group of expected characters and a max timeout, like below: