ATC命令

时间:2022-07-27 18:47:00 阅读: 最新文章 文档下载
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。
词法分析

词法分析的正则表达式:telink7619\ms-ds-src\at\atc\parser\text \Atc.lex文件) [^\n]+ RAW_STRING [0-9*+#]+ FAX_STRING

[^\n] BEGIN( EXTENDED ); CHARACTER [[:xdigit:]]+ BEGIN( EXTENDED ) LCON [dD][tT]*\*98[^#]*[#] ATD98_STRING [dD][tT]*\*99[^#]*[#] ATD99_STRING [dD][lL];? ATC_ATDL [dD]>\"[^\"]*\".* |

[dD]>[a-zA-Z]*[0-9]*.* ATC_ATDPBK [dD][tT]?[^,\n].* | ^[dD].* ATC_ATD [[:alpha:]]+[[:digit:]]* | &[[:alpha:]]+[[:digit:]]* | \\[[:alpha:]]+[[:digit:]]* BEGIN( INITIAL ) nToken "+"xnad[^\n]* ATC_XNAD "+"[[:alpha:]][[:alnum:]]* keyword( nTE, 1, yytext ) "%"[[:alpha:]][[:alnum:]]* keyword( nTE, 3, yytext ) [0-9] BEGIN( EXTENDED ) yytext[0] [-]?[0-9][0-9]* LCON "2\.0" LCON [-]?[[:digit:]]+\.[[:digit:]]+ DOUBLE \"[^\"]*\" STRING "=?" TSTCMD "," BEGIN( EXTENDED ); COMMA "=" ASSIGN "?" QUERY ";" SEMI \n EOL \r ATC_PDU_INFO <> YY_NULL . CHARACTER

例如:AT+XAPP=apSV.01\n 可以分析如下:

+XAPP 符合"+"[[:alpha:]][[:alnum:]]*规则,调用keyword( nTE, 1, yytext ) 返回ATC_XAPP

= 返回 ASSIGN apSV.01 返回STRING \n 返回 EOL

因此该命令符合如下语法:ATC_XAPP ASSIGN string cmndend


语法分析

语法文件在telink7619\ms-ds-src\at\atc\parser\text目录下:

atc.y 语法分析的主体文件,包含一下所有的*.y文件,提供普通命令的解析功能 atc_app.y atc_btc.y BluetoothControl相关 atc_cc.y Call Control相关 atc_cust1.y atc_fax.y FAX Control相关 atc_gprs.y GPRS Control相关 atc_lcs.y Location Service相关 atc_ns.y Network Service相关 atc_pbk.y Phone Book相关 atc_pmi.y Driver Access atc_sim.y SIM Access 相关 atc_sms.y Short Message Services相关 atc_stk.y SIM Toolkit相关 atc_sys.y System Control相关 atc_term.y Terminal Control相关 atc_test.y Test Function相关

便telink7619\system-build\HW\XMM6180_REV_5.0\MODEM_DEBUG\src\at\ atc.py 件的合并,方便查找。以词法分析出的“ATC_XAPP ASSIGN string cmndend”为例,在文件中查找到了如下代码:

| ATC_XAPP ASSIGN string cmndend {

T_AT_APP_MSG_XAPP m;

m.hRequest = MAKEREQHANDLE( (unsigned)nTE, AT_TID_TERM, 0); m.pszSocketString = $3; m.nTid = -1; m.pszResponseString = NULL;

osxPostMessage( (unsigned)nTE, AT_TID_APP, E_AT_APP_MID_XAPP, &m, sizeof( m ) ); }

可见该命令向APP模块发送了一个E_AT_APP_MID_XAPP 消息

AT的功能模块

模块名称 app

描述




bt cc csc fax gprs lcs ns pbk pmi sim sms stk sys term test

Bluetooth Control Call Control Custom Control FAX Control GPRS Control Location Service Network Service Phone Book Driver Access SIM Access

Short Message Services SIM Toolkit System Control Terminal Control Test Function



LPCSTR const osxTaskNameStrings[] = {

"Cc", "Gprs", "Ns", "Pbk", "Pmi", "Sim", "Sms", "Stk", "Sys", "Term", "Lcs", "Test", "BT", "App", "Fax",

#if defined ( NFW_CUST1_CONTROLLER ) "Cust1", #endif

#if defined( NFW_SAMPLE_CONTROLLER ) "Sample", #endif

#if defined ( NFW_CSC_CONTROLLER ) "Csc", #endif

"???", // Corresponds to an invalid or unknown task id,


// provided for debug output NULL };

功能模块注册函数:

int atcRegisterController( unsigned nTaskId, // 模块ID unsigned nFlags, POSX_DISPATCH_ENTRY

pDispatchTable, // dispatch table unsigned nDispatchTableSize, POSX_DISPATCH_ENTRY

pBcDispatchTable, // broadcast dispatch table unsigned nBcDispatchTableSize,

PCRSP_ITEM pRspItemTable, // response table unsigned nRspItemTableSize,

ATC_ABORT_HANDLER pfnAbortHandler, // abort handler unsigned nExtensionSize, PVOID *ppExtension, unsigned nEndpointDataSize );

int atcRegisterControllerEx( unsigned nTaskId, unsigned nFlags, POSX_DISPATCH_ENTRY

pDispatchTable, unsigned nDispatchTableSize, POSX_DISPATCH_ENTRY

pBcDispatchTable, unsigned nBcDispatchTableSize, PCRSP_ITEM pRspItemTable, unsigned nRspItemTableSize, ATC_EVENT_HANDLER pfnEventHandler, unsigned nEventMask, unsigned nExtensionSize, PVOID *ppExtension, unsigned nEndpointDataSize,

void (* pfnEndpointDataInit)( unsigned nTE, PVOID pvEndpointData, BOOL boCommand ) );


EndpointData 可以理解为供两个进程交换数据的共享内存

消息处理和返回

osxPostMessage( (unsigned)nTE, AT_TID_APP, E_AT_APP_MID_XAPP, &m, sizeof( m ) ); E_AT_APP_MID_XAPP 消息定义在telink7619\ms-ds-src\at\atc\ctrl_app\text\ atc_app_msg.h_T_AppMessageIds枚举类型中: enum _T_AppMessageIds {

E_AT_APP_MID_XAPP,

E_AT_APP_MID_XAPP_TST, E_AT_APP_MID_MMI_AT_CMD, E_AT_APP_MID_XTOS, E_AT_APP_MID_XTOS_RD,

#if defined( ATC_ENABLE_ROUTING_MMI_AT_CMDS ) && (defined( PS_PF_NX1 ) || defined( SDTENV ))

E_AT_APP_MID_SYNCML, #endif

E_AT_APP_MID_NUMIDS };

at\atc\ctrl_\text\ atc_.c中有DispatchTable组:

FAR_DECL static OSX_DISPATCH_ENTRY appDispatchTable[] = {

/** XAPP=[...] */

ODE_FLAGS_CMD_ABORTABLE, (OSX_MSG_HANDLER) appOnSocketStart, ODE_FLAGS_NO_RESTRICTIONS| ODE_FLAGS_IMMEDIATE_RSP, (OSX_MSG_HANDLER) appOnSocketTst, ODE_FLAGS_NO_RESTRICTIONS| ODE_FLAGS_IMMEDIATE_RSP, (OSX_MSG_HANDLER) appOnMmiCommand,

/** XTOS=[...] */

ODE_FLAGS_NO_RESTRICTIONS, (OSX_MSG_HANDLER) appOnXtos, ODE_FLAGS_NO_RESTRICTIONS, (OSX_MSG_HANDLER) appOnXtosRd

#if defined( ATC_ENABLE_ROUTING_MMI_AT_CMDS ) && (defined( PS_PF_NX1 ) || defined( SDTENV ))

/** SYNCML[...] */

,ODE_FLAGS_CMD_ABORTABLE, (OSX_MSG_HANDLER) appOnSyncml #endif };

E_AT_APP_MID_XAPP对应的消息处理函数为appOnSocketStart,且该函数可以被abort




返回处理取决于:m.hRequest = MAKEREQHANDLE( (unsigned)nTE, AT_TID_TERM, 0); 的最后一个参数,这里0,表示没有特殊的返回值

| ATC_XAPP TSTCMD cmndend {

yyParam.hRequest = MAKEREQHANDLE( (unsigned)nTE, AT_TID_TERM, E_AT_APP_RID_XAPP_TST ); osxPostMessage( (unsigned)nTE, AT_TID_APP, E_AT_APP_MID_XAPP_TST, &yyParam.hRequest, sizeof( yyParam.hRequest ) ); }

IDE_AT_APP_RID_XAPP_TSTat\atc\ctrl_\text\ atc__rsp.h文件中的_E_ResponseIds枚举中有定义, at\atc\ctrl_\text\ atc__rsp.c中有AppRspItemTable

const RSP_ITEM AppRspItemTable[E_AT_APP_RID_MAX] = {

RSP_ITEM_TYPE_FORMAT_STRING, "+XAPP:%s", RSP_ITEM_TYPE_FORMAT_FUNCTION,

(PVOID)rspOnAppMmiCommand, // MMI Command response

RSP_ITEM_TYPE_FORMAT_STRING, "+XTOS: %d, \"%s\"" };

因此其应该返回字符串"+XAPP:%s"


本文来源:https://www.wddqw.com/doc/9482ebe9d6bbfd0a79563c1ec5da50e2524dd13f.html