<div dir="ltr"><div>> I'll be back with the patch<br><br></div>Sorry, I made a mistake and created a new thread. The patch is in "<span class="inbox-inbox-eo inbox-inbox-xJNT8d"><span>[PATCH] telit-plugin: ignore QSS when SIM-ME interface is locked"<br><br></span></span></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 24 Jul 2017 at 12:27 Carlo Lobrano <<a href="mailto:c.lobrano@gmail.com">c.lobrano@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That sounds perfect.<div>I'll be back with the patch<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 24 Jul 2017 at 12:16 Aleksander Morgado <<a href="mailto:aleksander@aleksander.es" target="_blank">aleksander@aleksander.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jul 24, 2017 at 12:02 PM, Carlo Lobrano <<a href="mailto:c.lobrano@gmail.com" target="_blank">c.lobrano@gmail.com</a>> wrote:<br>
>> What would happen if you completely disable and enable the handlers > with<br>
>> the method I'm suggesting, and then you just let the #QSS=1 > indication<br>
>> happen? If the modem already had a SIM inserted, an extra > #QSS=1 wouldn't<br>
>> harm, right? Won't it be just ignored when it's<br>
>> processed?<br>
><br>
> You're right, we don't need to process #QSS=1, but we absolutely need to<br>
> wait for it before sending any other SIM command.<br>
><br>
> Since #QSS=1 arrives in a couple of seconds, even a sleep will do, but if<br>
> anything goes wrong we will get stuck in the next command (not sure if it is<br>
> a bug, but it looks like it to me).<br>
><br>
<br>
I see, so yes, we do need to wait for the #QSS.<br>
<br>
> In the meantime I tried the my proposal and I'm not really sure about how to<br>
> wait for the unsolicited. I cannot let the thread go on, otherwise we call<br>
> +CRSM and get stuck, but if I put a simple sleep, we do not process any<br>
> unsolicited...<br>
><br>
<br>
So, you're running an async operation (GSimpleAsyncResult or GTask).<br>
The logic won't go on unless you complete it, and you want to complete<br>
it only after receiving the indication or a give timeout happens.<br>
<br>
You solve this by setting up a timeout, e.g.<br>
g_timeout_add_seconds(3...) that will be triggered if you don't get<br>
the unsolicited indication. If the timeout happens, you complete the<br>
async method (you stored previously the GSimpleAsyncResult or GTask in<br>
private info). If the unsolicited message arrives, you also complete<br>
the async method, but you also cancel the timeout (so you also stored<br>
the timeout id in private info). The difference between a plain<br>
sleep() and a timeout via g_timeout_add_seconds() is that the former<br>
blocks the running thread, while the latter leaves the main loop<br>
running during the timeout (so unsolicited messages are processed).<br>
<br>
--<br>
Aleksander<br>
<a href="https://aleksander.es" rel="noreferrer" target="_blank">https://aleksander.es</a><br>
</blockquote></div></blockquote></div>