I've successfully built the SMS sample project came with the D211 SDK.
But when I ran it,the D211Ctl Panic with Illegal Operation & shut down immediately.Why?
It executed without anyerror until it trying to send the sms using Req_Sms_Send.
If there is something wrong with the parameter , it should return with error only without causing the panic by the D211Ctl & coz it shutting down!
The err code return by the Req_Sms_Send is 50397204.
The code of the sample is as below,
int main(int argc, char* argv[])
{
HANDLE hIpc;
DWORD dwStatus;
// Reads the first SMS
_tprintf(TEXT("3. Read the first SMS...\n");
PSMS pSms;
if (IPC_STATUS_SUCCESS != (dwStatus = Req_Sms_Read(hIpc, 0, &pSms)))
{
WriteError(TEXT("Req_Sms_Read()", dwStatus);
} else
{
// Shows some info of the SMS
_tprintf(TEXT("\tStatus:\t\t");
if (pSms->Status & SMS_EMPTY)
{
_tprintf(TEXT("empty.");
}
if (pSms->Status & SMS_NEW)
{
_tprintf(TEXT("new.");
}
if (pSms->Status & SMS_DELETED)
{
_tprintf(TEXT("deleted.");
}
if (pSms->Status & SMS_PROCESSED)
{
_tprintf(TEXT("processed.");
}
if (pSms->Status & 0xffff<<4)
{
_tprintf(TEXT("<UnknownBits>.");
}
_tprintf(TEXT("\n");
_tprintf(TEXT("\tType:\t\t");
switch (pSms->Type)
{
case SMS_UNICODE:
_tprintf(TEXT("unicode\n");
break;
case SMS_BINARY:
_tprintf(TEXT("binary\n");
break;
case SMS_PROFILE:
_tprintf(TEXT("profile\n");
break;
case SMS_PICTURE:
_tprintf(TEXT("picture\n");
break;
case SMS_7BITASCII:
_tprintf(TEXT("7bitASCII\n");
break;
case SMS_VCARD:
_tprintf(TEXT("vcard\n");
break;
case SMS_STATUSREPORT:
_tprintf(TEXT("statusreport: ");
switch (pSms->DeliveryStatus)
{
case SMS_STATUS_PENDING:
_tprintf(TEXT("pending\n");
break;
case SMS_STATUS_DELIVERED:
_tprintf(TEXT("delivered\n");
break;
case SMS_STATUS_FAILED:
_tprintf(TEXT("failed\n");
break;
default:
_tprintf(TEXT("unknown\n");
break;
}
break;
default:
_tprintf(TEXT("invalid/unknown\n");
}
_tprintf(TEXT("\tSMS center:\t%s\n", pSms->ScAddr);
_tprintf(TEXT("\tSender:\t\t%s\n", pSms->SenderAddr);
_tprintf(TEXT("\tSMS length:\t%d\n", pSms->Length);
}
// Frees up the allocated buffer for SMS
delete pSms;
// Set first SMS processed
_tprintf(TEXT("4. Set first SMS processed...\n");
if (IPC_STATUS_SUCCESS != (dwStatus = Req_Sms_Processed(hIpc, 0)))
{
WriteError(TEXT("Req_Sms_Processed()", dwStatus);
}
// The error point is the line below !!!
if (IPC_STATUS_SUCCESS != (dwStatus = Req_Sms_Send (hIpc, FALSE, FALSE,
FALSE, szTargetPerson, pSms, NULL)))
{
WriteError(TEXT("Req_Sms_Send()", dwStatus);
}
delete pSms;
// Closes the IPC
_tprintf(TEXT("8. Closes the IPC...\n");
// Destroy IPC
if (IPC_STATUS_SUCCESS != (dwStatus = IPCCloseHandle (hIpc)))
{
WriteError(TEXT("IPCCloseHandle()", dwStatus);
}
} else
{
WriteError(TEXT("IPCCreateNamedPipe()", dwStatus);
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
//
// Function: WriteError()
//
// Details: Shows an error message.
// Platforms: ALL
//
// Parameters: IN LPCTSTR szTxt - text to write out
// IN ULONG ulCode - errorcode
//
// Returns: -
//
///////////////////////////////////////////////////////////////////////////////
void WriteError(IN LPCTSTR szTxt, IN ULONG ulCode)
{
_tprintf(TEXT("\n#Error: %s. Code:%d\n\n", szTxt, ulCode);
}
RE: D211Ctl perform illegal operation when trying to send sms by Req_Sms_Send
2002-07-23, 14:39#2