veeso / attila Goto Github PK
View Code? Open in Web Editor NEWPython module to communicate easily with modems and RF modules using AT commands
License: MIT License
Python module to communicate easily with modems and RF modules using AT commands
License: MIT License
Describe the bug
Very long execution time for at command AT+CSQ : about 3 seconds
To Reproduce
Run the following code :
atrunenv = ATRuntimeEnvironment(True)
atrunenv.configure_communicator(serial_port="/dev/ttyUSB2", baud_rate=9600, timeout=5)
atrunenv.open_serial()
response = atrunenv.exec("AT+CSQ;;OK;;0;;;;['AT+CSQ=?{rssi},','AT+CSQ=${rssi},?{ber}']")
print(response.full_response)
print(response.execution_time)
Expected behavior
An execution time lesser than 1 seconds
Desktop (please complete the following information):
Additional context
The command used below (AT+CSQ) ran through a minicom returns instantly.
The same code with command "AT;;OK;;0" takes about 950ms, which is also quite high.
Describe the bug
It appears that longer executing commands do not collect all the information from the output, e.g. commands such as AT+CGDCONT?
and AT+COPS=?
. Most of the time, the parser only catches the echo of the command and not the full response.
To Reproduce
atrunenv = ATRuntimeEnvironment(abort_on_failure=True)
atrunenv.configure_communicator(port_name, baud_rate)
atrunenv.open_serial()
# returns ['AT+CGDCONT?'] or ['AT+CGDCONT?', '', '+CGDCONT: 1,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0'], not all results
cgdcont_result = self.atrunenv.exec('AT+CGDCONT?')
# fails as it parses only the shortened results
cgdcont_result = self.atrunenv.exec('AT+CGDCONT?;;OK;;;;5')
# sometimes times out, sometimes gets the response if a recent scan - inconsistent
cops_result = self.atrunenv.exec('AT+COPS=?;;OK;;;;900')
Expected behavior
CGDCONT should capture all data, there were 3 other PDP contexts displayed normally. COPS should wait for the operator scan to complete and return the data.
Desktop (please complete the following information):
Additional context
There may be an additional consistency bug. Some of the normal commands failed with no output, but repeating the command succeeds. The CGDCONT always fails however.
Describe the bug
I often get bad response to the same command :
Exception : "Command 'AT+CSQ' got a bad response: '['AT+CSQ']' (and hasn't any doppelganger)!"
To Reproduce
Run the following code
atrunenv = ATRuntimeEnvironment(True)
atrunenv.configure_communicator(serial_port="/dev/ttyUSB2", baud_rate=9600, timeout=5)
atrunenv.open_serial()
while True:
print("Running command")
try:
response = atrunenv.exec("AT+CSQ;;OK;;0;;5;;['AT+CSQ=?{rssi},','AT+CSQ=${rssi},?{ber}']")
print(response.full_response)
except Exception as e:
print("Exception : ", e)
time.sleep(1)
Expected behavior
No exception since the command is correct and a timeout of 5 seconds should be sufficient. The sleep(1) makes sure to not run too many commands.
Desktop:
Hi,
I have an AT command that returns long response (actually a json repr of a LwM2M object).
When I excecute it, I get an error be cause the decoded response is incomplete: the OK line as per expected response, is not catched by the exec.
More precisely, the missed lines are due to this loop:
ATtila/attila/atcommunicator.py
Lines 204 to 215 in 0f8548d
Indeed, debugging shows that it did not wait "enough" for data to be ready i.e polling the condition self._device.in_waiting
.
So I multiplied by 10 the sleeping time in the lines
ATtila/attila/atcommunicator.py
Line 191 in 0f8548d
sleep_time_based_on_baud = 1000 / self.baud_rate # Milliseconds
To my understanding the inverse of baudrate (units in bits/sec) is to be multiplied by 1000 to convert to ms !
@veeso, what do you think ?
This said, I did not have an issue when the response size was small...
Cheers,
Roudy
Describe the bug
Hello! I have a Huawei ME909s modem. I wrote a test script and it works on Windows 11 pretty good, but on Raspbian OS Bullseye it acts weirdly.
To Reproduce
import os
from time import sleep
from attila.atre import ATRuntimeEnvironment
def main():
res = ser.exec('AT^CURC=0')
print(res.full_response)
print(res.execution_time)
res = ser.exec('AT^SYSCFGEX="02",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,,')
print(res.full_response)
print(res.execution_time)
sleep(5)
res = ser.exec('AT^NETSCAN=20,-110,1')
print(res.full_response)
print(res.execution_time)
if os.name == 'nt':
port = 'COM30'
else:
port = "/dev/ttyUSB5"
ser = ATRuntimeEnvironment(abort_on_failure=True)
ser.configure_communicator(port, 128000, 60)
ser.open_serial()
main()
ser.close_serial()
Expected behavior
On Windows this code works as expected, I have answers to all commands from the modem:
['', 'OK']
15
['', 'OK']
14
['', '^NETSCAN: 2987,,,D2,257,02,0,-64,CF296D,2000000000000,52', '^NETSCAN: 10588,,,69,257,01,0,-68,E7AC7,400000,466', '^NETSCAN: 10638,,,69,257,01,0,-68,EA1D7,400000,466', '^NETSCAN: 10613,,,69,257,01,0,-69,E7ACD,400000,466', '^NETSCAN: 10563,,,69,257,01,0,-70,E7ACA,400000,466', '^NETSCAN: 10713,,,D2,257,02,0,-76,CF9B24,400000,384', '^NETSCAN: 10688,,,D2,257,02,0,-76,CF9B21,400000,384', '^NETSCAN: 10663,,,D2,257,02,0,-78,CF2C78,400000,191', '^NETSCAN: 3013,,,69,257,01,0,-80,EC777,2000000000000,209', '^NETSCAN: 10788,,,44C,257,04,0,-82,982DCC,400000,504', '^NETSCAN: 10738,,,D2,257,02,0,-82,CF9B27,400000,384', '^NETSCAN: 10763,,,44C,257,04,0,-82,9830A4,400000,385', '', 'OK']
38510 - this is normal, the modem always takes so long to respond to this command
But on Raspbian the modem answers only on the first command (AT^CURC=0) and then just returns my commands without asnwer:
['', 'OK']
499
['AT^SYSCFGEX="02",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,,']
2
['AT^NETSCAN=20,-110,1,2000000000000']
3
if I run the script immediately again:
['AT^CURC=0']
498
['AT^SYSCFGEX="02",3FFFFFFF,1,2,7FFFFFFFFFFFFFFF,,', '', '^NETSCAN: 10638,,,69,257,01,0,-70,EA1D7,400000,466', '^NETSCAN: 10613,,,69,257,01,0,-71,E7ACD,400000,466', '^NETSCAN: 10713,,,D2,257,02,0,-71,CF9B24,400000,384', '^NETSCAN: 10688,,,D2,257,02,0,-71,CF9B21,400000,384', '^NETSCAN: 10663,,,D2,257,02,0,-74,CF3FE0,400000,384', '^NETSCAN: 10588,,,69,257,01,0,-74,E7AC9,400000,468', '^NETSCAN: 10763,,,44C,257,04,0,-77,982DCA,400000,505', '^NETSCAN: 10563,,,69,257,01,0,-78,E7ACC,400000,468', '', 'OK']
3
['AT^NETSCAN=20,-110,1']
3
then I get a response to the commands from the previous run. It looks like the script is not waiting for a response. I tried to use ATScripts like AT^CURC=0;;OK;;0;;30 to set timeout, but it did not help.
Desktop (please complete the following information):
Hi.
Is it possible to register callbacks for handling Unsolicited Result Codes (URC) issued by the modem ?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.