Recently, I made a software program for a cost company, which requires the integration of the traffic system. The rest is not feasible because the seller did not provide the dynamic link library interface, you have to write the code to implement the operations related to the hardware interaction. First, let's take a look at what we use.
1. At command
Second: serial communication, I use C #, which has class support
Among them, the AT command is the most troublesome. If the details are not good, It is very troublesome. Therefore, a good debugger is needed.
As we all know, XP comes with a Super Terminal. By the way, it is the start-> Program-> attachment-> communication-> Super Terminal.
The usage is very simple. Create the corresponding connection to the COM port and then enter the command.
If you don't want to talk about anything else, let's talk about the notes of the at command.
1. When executing the command,/R is required.
2. When sending text messages, pud supports the best Chinese characters, so it is generally sent in pud mode. The text message format is as follows:
At + cmgs = [number of strings in pud format]
& Gt; 23232 ^ Z
Many Control + Z on the Internet are ^ Z, but I am not correct in C #. Finally, I cannot find the corresponding ascall code value based on the internal code, and then replace it with a char type, in this way. The statement is: Convert. tochar (26). put it at the end. Of course, a line feed/R is required.
It is best to debug all the commands that require functionality on the Super Terminal and then put them in the code.
As for the code, note that for general commands, such as getting the SMS brand and setting the text message type [text, pud], thread sleep (1000) is usually used) then get the returned value. If you send a text message, you 'd better sleep (3000) to get the returned value.
My solution is to scan the cache area continuously after sending messages until there is a normal value, because there may also be problems with mobile or Unicom service provider signals, resulting in a long time to send text messages. However, it is not flexible to obtain data at the specified time.
Let's look at the class. We only need to use two classes to complete this function. One is the operation at command class, and the other is the pud generation class. [This is provided by others, thank you for saving me from the complicated pud format. Haha, hahahahahaha] pud is the most convenient. If you are lucky enough to see the trouble of pud generation, you will feel this way. It can generate the pud string sent based on the SMS center number, accept the number, and content. You can add the terminator convert. tochar (26) And/R to the end. Congratulations, you can send a text message.
In the future, I will post the relevant code and the usage of the Super Terminal. But you need to wait until the project is completed...
Just put it up, the design of this software is really spam, of course I designed it, And the maintainability is negative. Haha...