I would like to do 2 things.

  1. Recognize when someone is calling - In terminal will appear RING and to answer I have to send command ATA. But How can I recognize it when I am doing something else. Should I use new thread and read port until send RING? Is there any beter solution?
  2. What is a symbol of end of response? I'm reading char using for(), but I do not know number of signs. Example below doesn't work properly

      while(readCharUART()!=10) {};
    
      while(readCharUART()!=13)
      {  
          getchar() = ..  
      }
    
有帮助吗?

解决方案

You are on the right track.

For RING then yes, the correct way to do it is to have one thread just read modem responses until you get the Unsolicited result code RING. If you from time to time want to run AT commands (say ATA), then you should let this thread do that as well, e.g. you have one thread that takes care of both issuing AT commands and monitor for UR codes.

Regarding formatting of responses from the modem, this is well described in chapter 5.7.1 Responses in the ITU V.250 standard. Short summary (reading the spec is highly recommended!):

<header>RING<trailer>

where header and trailer is both "\r\n" (unless the modem is configured strangely).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top