# ed\_SendMail with ED\_ERR\_STACK\_BUSY

**URL:** <https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468>\
**Category:** Open AT\
**Created:** [May 23, 2006, 9:30am UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468 "2006-05-23T09:30:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![veranith](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@veranith](https://forum.sierrawireless.com/u/veranith)\
**Post date:** [May 23, 2006, 9:30am UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468/1 "2006-05-23T09:30:08Z")

</div>

Hello,

I’m sorry my issue should be quite simple and I might have been able to find answers in the forum. But I am completely new in the Open AT world and I have an issue that I must solve rapidly.

I use the ed\_SendMail function to send an email and systematicly get the ED\_ERR\_STACK\_BUSY error.

my smtp parameters are correct and here is what I do when sending a mail :

```auto
scannerParams.email.Id = 1;
wm_strcpy(scannerParams.email.CcRec, "");
wm_strcpy(scannerParams.email.Subj, "");
wm_strcpy(scannerParams.email.Body, Rsp);
result = ed_EmailSetConfig(&scannerParams.email);
TRACE((8, "Scan (mail): ed_EmailSetConfig() == %d", result));
resultEmail = ed_SendMail(1, ResponseCbkScanner);
TRACE((8, "Scan (mail): ed_SendMail() == %d", resultEmail));
if ((result != 0) ||(resultEmail != 0))
	{
		if ((result == ED_ERR_PHY_NOT_ACTIVATED) ||(resultEmail == ED_ERR_PHY_NOT_ACTIVATED))
		{
			/* Attach to GPRS */
			adl_atCmdCreate("AT+CGATT=1", FALSE, adl_atRspHandler_t)Cgatt_handler,"*", NULL);
			TRACE ((8, "SendData: sent AT+CGATT=1"));
		}
...
```

I found the meaning of this error : “another IP connectivity librar application is already running” but this is not really helping me as I am new.

Could someone help me ?

thanks

Veranith

---

<div class="post-metadata">

**Author:** ![OpenAT\_Fan](https://avatars.discourse-cdn.com/v4/letter/o/f07891/32.png) [@OpenAT\_Fan](https://forum.sierrawireless.com/u/OpenAT_Fan)\
**Post date:** [May 25, 2006, 7:26am UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468/2 "2006-05-25T07:26:34Z")

</div>

Hi Veranith,  
Please check out the following points to be able to send e-mail from your Open-AT application:

1. Wait for ADL\_SIM\_EVENT\_FULL\_INIT. You can do this by subscribing to SIM service and when this event is received in the SIM handler function. Proceed to the next point 2.
2. Attach to the GPRS network. THis can be done using adl\_atCmdCreate () API and the command to give is AT+CGATT=1.
3. If your GPRS attach is successful, then you set the GPRS parameters (i.e APN, username, password). You should use ed\_GprsSetConfig () API to set these parameters.
4. Use ed\_DialupConnectionStart () API. When ED\_INFO\_GPRS\_SESSION\_SET is received in the handler function provided for ed\_DialupConnectionStart (). Proceed next.
5. Set the SMTP parameters (using ed\_SMTPSetConfig () API). Make sure to provide all the parameters correctly.
6. Set the email parameters (using ed\_emailSetConfig () API). Make sure to provide all the parameters correctly (i.e. CCRec, Rec etc).
7. Check out the return value of all the APIs that you use.
8. Also make sure that there is no invalid pointer operation (i.e. all of your pointers have enough memory allocated for the values that you assign).
9. Now you call ed\_SendMail () function to send the mail.

Follow all the above points and still you are not able to send the mail (i.e. all the pointer operations are correct, parameters are correct.

In case, you are trying to execute the application in debug mode, please delete the contents of /project\_workspace/rte/objects folder. Sometimes, incorrect contents of this folder (where all the flash parameters are stored by eDlib) lead to similar errors.  
You should also try to execute the application in target mode and check out if the problem occurs.

Best Regards,  
Open AT Fan.

---

<div class="post-metadata">

**Author:** ![veranith](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@veranith](https://forum.sierrawireless.com/u/veranith)\
**Post date:** [May 26, 2006, 11:53am UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468/3 "2006-05-26T11:53:16Z")

</div>

Hi OpenAT Fan,

Thank you for your answer.

I did all or your steps :  
1/ wait for ADL\_SIM\_EVENT\_FULL\_INIT  
2/ I am attached to the GPRS network with the right parameters (apn…)  
3/ my smtp parameters are correct :  
4/ all the API’s return 0.

Now I know a TCP socket is already opened when I try to send my email. can there be a conflict with it ?  
should I close all TCP sockets before sending an email ? if so, How can I close a TCP Socket ?

thanks a lot.

Veranith

---

<div class="post-metadata">

**Author:** ![OpenAT\_Fan](https://avatars.discourse-cdn.com/v4/letter/o/f07891/32.png) [@OpenAT\_Fan](https://forum.sierrawireless.com/u/OpenAT_Fan)\
**Post date:** [May 26, 2006, 2:22pm UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468/4 "2006-05-26T14:22:35Z")

</div>

Hello veranith,  
You are correct in understanding that if your TCP socket is active, you will not be able to send mail. You can use only one service at a time (for example, you can use either TCP or UDP or SMTP or POP3). You cannot use any of the services simultaneously.

To close the established socket, you have to call ed\_SendDataExt () API with the third parameter set to TRUE. This will indicate to eDLib that you want to close the active socket connection.

In case, you have opened a listening server which has not been connected with any client, you can use ed\_SocketLTCPStop () API to close the listening server.

However, once the server is contacted by a client, you have to use ed\_SendDataExt () with third parameter set to TRUE to close the socket. The same holds true for a client socket also. Hence you can use  
ed\_SendDataExt (NULL,0,TRUE,ED\_ID\_TCPSOCKET\_1);  
This will close the client/active server socket (i.e. server socket with which a client is connected).

After you receive an event in the TCP (ED\_OK\_TCP\_CLOSED), you can start your SMTP session using ed\_SendMail () or ed\_PutMail () API.

You should follow the steps 5 to 9 as specified in my previous post after receiving this event.

Hope this helps.

Best Regards,  
Open AT Fan.

---

<div class="post-metadata">

**Author:** ![veranith](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@veranith](https://forum.sierrawireless.com/u/veranith)\
**Post date:** [May 26, 2006, 4:31pm UTC](https://forum.sierrawireless.com/t/ed-sendmail-with-ed-err-stack-busy/468/5 "2006-05-26T16:31:24Z")

</div>

Hi Open AT Fan,

I did end all active services before sending an email with ed\_SendDataExt as you told me. now the email has been correctly sent !!!  
Your answers were really accurate and efficient !!! You saved me a lot of time .  
Thanks again

Veranith
