12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "includes.h"
- #include "bsp.h"
- #define VIR_WAIT_FOREVER (-1U)
- LSAPI_OSI_Pipe_t *at_rx_pipe = NULL;
- LSAPI_OSI_Pipe_t *at_tx_pipe = NULL;
- void vir_at_process(char *buf,unsigned int len)
- {
-
- if(sutApp.gtTMode==1)MSG_INFO(1,"vir_at--->%s",buf);
-
- // if(msgCmp(buf, "SV")) {
- // strcpy(sutApp.modemVer, buf);
- // sutApp.modemVer[strlen(buf)-2]=0;
- // }
-
- pocCmdHandler(buf,len);//
- }
- //模块应答
- static void prvVirtAtRespCallback(void *param, unsigned event)
- {
- LSAPI_OSI_Pipe_t *pipe = (LSAPI_OSI_Pipe_t *)param;
- char buf[256];
-
- for (;;)
- {
- int bytes = LSAPI_OSI_PipeRead(pipe, buf, sizeof(buf)-1);
- if (bytes <= 0)
- break;
- buf[bytes] = '\0';
- // MSG_INFO(1,"VAT1:%d,%s",bytes,buf);
- vir_at_process(buf,bytes);
- }
- //MSG_INFO(1,"prvVirtAtRespCallback");
- }
- void makeupsample(void *param){
- at_rx_pipe = LSAPI_OSI_PipeCreate(1024);
- at_tx_pipe = LSAPI_OSI_PipeCreate(1024);
- LSAPI_OSI_PipeSetReaderCallback(at_tx_pipe, LSAPI_PIPE_EVENT_RX_ARRIVED,
- prvVirtAtRespCallback, at_tx_pipe);
- LSAPI_Device_AtVirtConfig_t cfg = {
- .name = LSAPI_MAKE_TAG('V', 'A', 'T', '1'),
- .rx_pipe = at_rx_pipe,
- .tx_pipe = at_tx_pipe,
- };
- LSAPI_Device_t *device = LSAPI_Device_AtVirtCreate(&cfg);
- LSAPI_Device_AtDispatch_t *dispatch = LSAPI_Device_AtDispatchCreate(device);
- LSAPI_Device_AtSetDispatch(device, dispatch);
- LSAPI_Device_Open(device);
- LSAPI_OSI_ThreadExit();
- }
- void CreateSerialAtThead()
- {
- if(NULL==LSAPI_OSI_ThreadCreate("virat", makeupsample, NULL, LSAPI_OSI_PRIORITY_NORMAL, 1024, 4))
- MSG_INFO(1,"virat thread create err");
- LSAPI_OSI_ThreadSleep(500);
- }
- /*
- innerInfo
- 发送数据到内部(module)API
- */
- void innerInfo(unsigned char *info, unsigned int len){
- if(len>0){
- if(0>LSAPI_OSI_PipeWriteAll(at_rx_pipe, info, len, VIR_WAIT_FOREVER))
- MSG_INFO(1,"LSAPI_OSI_PipeWriteAll write failed");
- }
- }
- void ModemSendAt(char *p)
- {
- int len;
- len=strlen(p);
- innerInfo(p,len);
- }
|