bsp.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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+2,len-2);// bnd有回车换行 +2
  14. //cmdsProcess(buf+2,len-2);
  15. }
  16. //妯″潡搴旂瓟
  17. static void prvVirtAtRespCallback(void *param, unsigned event)
  18. {
  19. LSAPI_OSI_Pipe_t *pipe = (LSAPI_OSI_Pipe_t *)param;
  20. char buf[256];
  21. for (;;)
  22. {
  23. int bytes = LSAPI_OSI_PipeRead(pipe, buf, sizeof(buf)-1);
  24. if (bytes <= 0)
  25. break;
  26. buf[bytes] = '\0';
  27. // MSG_INFO(1,"VAT1:%d,%s",bytes,buf);
  28. vir_at_process(buf,bytes);
  29. }
  30. //MSG_INFO(1,"prvVirtAtRespCallback");
  31. }
  32. void makeupsample(void *param){
  33. at_rx_pipe = LSAPI_OSI_PipeCreate(1024);
  34. at_tx_pipe = LSAPI_OSI_PipeCreate(1024);
  35. LSAPI_OSI_PipeSetReaderCallback(at_tx_pipe, LSAPI_PIPE_EVENT_RX_ARRIVED,
  36. prvVirtAtRespCallback, at_tx_pipe);
  37. LSAPI_Device_AtVirtConfig_t cfg = {
  38. .name = LSAPI_MAKE_TAG('V', 'A', 'T', '1'),
  39. .rx_pipe = at_rx_pipe,
  40. .tx_pipe = at_tx_pipe,
  41. };
  42. LSAPI_Device_t *device = LSAPI_Device_AtVirtCreate(&cfg);
  43. LSAPI_Device_AtDispatch_t *dispatch = LSAPI_Device_AtDispatchCreate(device);
  44. LSAPI_Device_AtSetDispatch(device, dispatch);
  45. LSAPI_Device_Open(device);
  46. LSAPI_OSI_ThreadExit();
  47. }
  48. void CreateSerialAtThead()
  49. {
  50. if(NULL==LSAPI_OSI_ThreadCreate("virat", makeupsample, NULL, LSAPI_OSI_PRIORITY_NORMAL, 1024, 4))
  51. MSG_INFO(1,"virat thread create err");
  52. //涓嬮潰鐨勫欢鏃舵槸涓€瀹氳�鐨勶紝鍚﹀垯VAT1鐨勫洖璋冩棤娉曡繘鍏?
  53. //鎯呭喌鏄?濡傛灉涓嶅姞涓嬮潰鐨勫欢鏃讹紝鍙��鎵ц�bspStartNotice寰€涓插彛杈撳嚭鏁版嵁锛孷AT1灏辨棤娉曞洖璋冧簡
  54. LSAPI_OSI_ThreadSleep(500);
  55. }
  56. /*
  57. innerInfo
  58. 鍙戦€佹暟鎹�埌鍐呴儴(module)API
  59. */
  60. void innerInfo(unsigned char *info, unsigned int len){
  61. if(len>0){
  62. if(0>LSAPI_OSI_PipeWriteAll(at_rx_pipe, info, len, VIR_WAIT_FOREVER))
  63. MSG_INFO(1,"LSAPI_OSI_PipeWriteAll write failed");
  64. }
  65. }
  66. void msgToModem(char *p)
  67. {
  68. int len;
  69. len=strlen(p);
  70. innerInfo(p,len);
  71. }