bsp.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "includes.h"
  2. #include "bsp.h"
  3. #define VIR_WAIT_FOREVER (-1U)
  4. LSAPI_OSI_Pipe_t *at_rx_pipe = NULL;
  5. LSAPI_OSI_Pipe_t *at_tx_pipe = NULL;
  6. void vir_at_process(char *buf,unsigned int len)
  7. {
  8. if(sutApp.gtTMode==1)MSG_INFO(1,"vir_at--->%s",buf);
  9. // if(msgCmp(buf, "SV")) {
  10. // strcpy(sutApp.modemVer, buf);
  11. // sutApp.modemVer[strlen(buf)-2]=0;
  12. // }
  13. pocCmdHandler(buf,len);//
  14. }
  15. //模块应答
  16. static void prvVirtAtRespCallback(void *param, unsigned event)
  17. {
  18. LSAPI_OSI_Pipe_t *pipe = (LSAPI_OSI_Pipe_t *)param;
  19. char buf[256];
  20. for (;;)
  21. {
  22. int bytes = LSAPI_OSI_PipeRead(pipe, buf, sizeof(buf)-1);
  23. if (bytes <= 0)
  24. break;
  25. buf[bytes] = '\0';
  26. // MSG_INFO(1,"VAT1:%d,%s",bytes,buf);
  27. vir_at_process(buf,bytes);
  28. }
  29. //MSG_INFO(1,"prvVirtAtRespCallback");
  30. }
  31. void makeupsample(void *param){
  32. at_rx_pipe = LSAPI_OSI_PipeCreate(1024);
  33. at_tx_pipe = LSAPI_OSI_PipeCreate(1024);
  34. LSAPI_OSI_PipeSetReaderCallback(at_tx_pipe, LSAPI_PIPE_EVENT_RX_ARRIVED,
  35. prvVirtAtRespCallback, at_tx_pipe);
  36. LSAPI_Device_AtVirtConfig_t cfg = {
  37. .name = LSAPI_MAKE_TAG('V', 'A', 'T', '1'),
  38. .rx_pipe = at_rx_pipe,
  39. .tx_pipe = at_tx_pipe,
  40. };
  41. LSAPI_Device_t *device = LSAPI_Device_AtVirtCreate(&cfg);
  42. LSAPI_Device_AtDispatch_t *dispatch = LSAPI_Device_AtDispatchCreate(device);
  43. LSAPI_Device_AtSetDispatch(device, dispatch);
  44. LSAPI_Device_Open(device);
  45. LSAPI_OSI_ThreadExit();
  46. }
  47. void CreateSerialAtThead()
  48. {
  49. if(NULL==LSAPI_OSI_ThreadCreate("virat", makeupsample, NULL, LSAPI_OSI_PRIORITY_NORMAL, 1024, 4))
  50. MSG_INFO(1,"virat thread create err");
  51. LSAPI_OSI_ThreadSleep(500);
  52. }
  53. /*
  54. innerInfo
  55. 发送数据到内部(module)API
  56. */
  57. void innerInfo(unsigned char *info, unsigned int len){
  58. if(len>0){
  59. if(0>LSAPI_OSI_PipeWriteAll(at_rx_pipe, info, len, VIR_WAIT_FOREVER))
  60. MSG_INFO(1,"LSAPI_OSI_PipeWriteAll write failed");
  61. }
  62. }
  63. void ModemSendAt(char *p)
  64. {
  65. int len;
  66. len=strlen(p);
  67. innerInfo(p,len);
  68. }