title: A good C library for speeding up AT commands with a GSM module in embedded linux?
body: <p>I used to work with GM862-QUAD-PY module from Telit (link here: <a href="http://www.telit.com/en/products.php?p_ac=show&amp;p=4" rel="nofollow">http://www.telit.com/en/products.php?p_ac=show&amp;p=4</a>). This module has a built-in Python interpreter. For a long time, I use it as a single module GSM/GPRS solution. I basically write Python scripts that sends and receive AT commands to the GSM part of the module itself. Using Python, I can also reach its GPIO pins, UART, bitbanging SPI and I2C buses.</p>
  
  <p>However, this python interpreter has strong limitations. It is only good for small projects. There is no support for threads or any type of interrupts or signals. So python programs written must feature a big super loop. In my application, the GM862 module reads incomming data from UART and process it and upload them to a GPRS server. Meanwhile, it also reads commands sent from SMS or the GPRS server. As more users use my system (which means more data at UART and more SMS commands to the system), the super loops gets slower and slower. Optimizing the python program doesn't help much and even obfuscates my code.</p>
  
  <p>Finally, I decided to switch to an embedded linux platform. Telit has GE863-PRO which is a embedded linux version of GSM/GPRS module but its development kits are difficult to obtain. Now I am looking at Beaglebone. I will be using GM862-QUAD-PY the normal AT-command way. However, AT commands are slow to deal with. Certain commands can take as much as 15 seconds to complete. In the original Python code, I simply wait until there is an AT response. After that, I do something else which doesn't involve AT commands.</p>
  
  <p>Since I am in linux now and have Pthreads to play with, I want to make full utilization of the GSM module and increase its throughput. Here is my initial idea. I make a AT command pending queue. Each element in queue consists of the AT command itself and a callback function. I create a thread that takes AT commands from that queue and sends out via UART and the thread polls for responses. When there is response, the thread will call the callback function.</p>
  
  <p>Because I am new to embedded linux and Pthreads, I want to know if this is the best way to achieve high utilization of the GSM/GPRS module and if there is any good existing libraries I could take advantage of.</p>
  
  <p>Thanks in advance.</p>