Embedded on-board platform GPRS network implementation

Source: Internet
Author: User

This article feels good. It is helpful to understand the network data transmission using the GPRS module. I don't know if the 3G module is similar in principle, but it is just a matter of speed, this is because when I develop network programs on my andiroid mobile phone (started from 3G), I use socket-related APIs to communicate with the internet server, which is different from the conclusion, to be confirmed!

Conclusion: 1.
CPUCommunication with GPRS requires RS232 instead of simple TTL.

2. the GRPS module communicates with the AT instruction set, which includes SMS, call (Voice Over GSM, GPRS over GSM), network, and other functions.

3. Using the AT instruction set, GPRS establishes an Internet ServerTCP ConnectionThe data transmitted in the serial port can be directly transmitted to the server, and the CPU does not need to establish a socket. To be confirmed


Embedded on-board platform GPRS network implementation
Wei Yu, HUANG Tao
 
School of Information Engineering, Wuhan University of Technology, Wuhan, Hubei (430070)
E-mail: weikun_0324@126.com
Abstract: This paper uses Samsung's smk2410 chip and Zhou ligong's model as ZWG-22A's GPRS DTU
As a hardware platform and a Linux operating system as a software platform, the GPRS network communication of the embedded on-board platform is realized,
The hardware connection principle diagram and related software programming methods and codes are provided.
Key words: gprs dtu; socket; Serial Communication


1. Introduction
With the development of society and the continuous improvement of people's living standard, cars have gradually entered the ordinary home. As a vehicle
Vehicle-mounted positioning systems, which are an important means of vehicle monitoring, are gaining more and more attention. The on-board positioning system is based on
ARM hardware platform integrates GPRS and GPS to connect to the Internet. GPRS ensures that vehicles are always online.
The location, speed, and other information are uploaded to the monitoring center to help the monitoring center know the vehicle status at any time. Other users
You can also use the Internet to track vehicles, prevent theft, manually/automatically trigger alarms, and query vehicle locations. This system can be used
It has obvious economic and social benefits in different monitoring scenarios and can be widely used in the passenger transportation, banking, public security, and logistics industries.
2. structure and features of GPRS network
2.1 Structure of GPRS network

In Figure 1, the data collection device can be a variety of data collection devices on the industrial site, or a variety of on-board data collection devices
Set devices. DTU through the RS-232 serial port to read data from the user device, and then add control information through DTU, do
After the transparent data protocol is processed and packaged, use the AT command (modem Special Control Command) to control the GPRS module through the GPRS network
Finally, the data is transmitted to the data center to interact with the data center, or the data in the GPRS network is read
After processing, DTU returns the result to the User device through the user-side serial port, and generates control signals to the user-side device.
[1]
(1) Data collection equipment: such as cameras and sensors. For this system, it refers to a Linux-based
As a system platform that integrates data collection node control, using 2410 of Samsung as the main chip.
(2) gprs dtu: gprs dtu mainly includes embedded MCU, GPRS transceiver module, and data collection signal connection.
Port circuit, Watchdog Circuit and power supply module. In this system, the model of Zhou ligong company is ZWG-22A
Gprs dtu.
(3) Data Center: the data center includes network devices, central hosts, RADIUS servers, and database servers. Quantity
Data center functions include network access, receiving and responding to heartbeat packets, receiving and sending data, and data processing.
Management, database maintenance, user identity authentication, and other security management. In this system, the data center is a connection
A control platform that collects on-board information and sends control commands to the on-board system through GPRS network.

2.2 characteristics of GPRS network
1. Make full use of existing resources-China Mobile's nationwide telecom network-GSM, which is convenient, fast, and low construction cost.
Deploy Remote Access Networks for user data terminals. [2]
2. The transmission speed is high. The actual transmission speed of GPRS data can reach 50 KBS.
115kbs -- 170kbs, which can fully meet the needs of your applications;
3. Short access time, short waiting time for GPRS access, and fast connection establishment;
4. The real-time online function "alwaysonline" is provided. Users will always be connected and online, which will enable the Access Service
It becomes very simple and fast;
5. Pay by traffic. GPRS users only occupy resources during data transmission or reception, and no data traffic is transmitted.
Users are not charged even if they are online.
The GPRS Service features fast access, always online, fast transmission rate, and paybytraffic.
Data real-time transmission has incomparable advantages, especially suitable for real-time transmission with frequent small data volumes.
[3]
3. connection between the data collection device and GPRS DTU
In the on-board network system, the data collection device is a set of various data collection and control CPU,
The relationship between the limited length does not detail the specific working principle of the system, but only focuses on the relationship with gprs dtu (GPRS data transmission unit)
The interconnection part. This system uses Samsung's 2410 chip as the CPU of the data collection device.
3.1 serial communication hardware connection
The data acquisition device is connected to the gprs dtu through the RS232 level conversion chip. This is because the gprs dtu Interface
DB9 is used as the interface, and DB9 interface signal flat table needle is in line with RS232 level standard (± 12 V), cannot be direct
Connect the TTL level. Otherwise, the device may be damaged. Figure 2 shows the hardware used to connect the data collection device to the gprs dtu.
Component schematic.

3.2 Implementation of serial communication software for data collection devices
Gprs dtu designs the serial port as a "transparent conversion" method. Therefore, after completing the hardware connection
For data collection devices, the baud rate and data format of their serial devices must match the configurations in DTU. Yes
You need to program the serial port of the chip to adapt to the serial port transmission rate of gprs dtu.
The software platform used in this system is Linux. in Linux, the serial port device is accessed through the serial port terminal device file.
To complete serial communication programming, follow these steps:
[4]
1. Open the serial port
Opening a serial port is similar to opening a file, and the open function is also used.
FD = open ("/dev/ttys0", o_rdwr | o_noctty );
2. Set serial communication parameters
Serial Communication parameters refer to the baud rate, data bit, parity bit, and stop bit, mainly involving the termios struct,
The specific implementation code is as follows:
Struct termios OPT;/* defines the pointer to the termios structure type opt */
Tcgetattr (FD, & OPT);/* Get the pointer from the serial port to the termios structure */
Cfsetispeed (& OPT, b115200);/* specify the input baud rate, 115200bps */
Cfsetospeed (& OPT, b115200);/* specify the output baud rate, 115200bps */
Opt. c_cflag & =-csize;/* block other flag */
Opt. c_cflag | = cs8;/* change the data bit to 8bit */
Opt. c_cflag & = ~ Parenb;/* specify the parity check */
Opt. c_cflag & = ~ Parodd;
Opt. c_cflag & = ~ Crtscts;/* specify as the hardware traffic control bit */
Tcsetattr (FD, tcanow, & OPT);/* set the modified termios data to the serial port */
3. read/write serial port
The read/write serial port is implemented by using the Read and Write functions. In Linux, the reading and writing of devices is similar
Read/write.
S_len = write (FD, sbuf, send_len);/* sbuf is the sending buffer, send_len is the number of bytes to be sent, s_len is the actual
Number of sent bytes */
R_len = read (FD, rbuf, read_len);/* rbuf is the receiving buffer, read_len is the number of pre-received bytes, and r_len is the actual
Number of nodes x */
4. Close the serial port
After reading and writing a device file, call the close function to close the file descriptor: Close (FD );
4. structure characteristics and working principle of GPRS DTU
4.1 structure and features of gprs dtu:
The system gprs dtu structure 3 is shown below:

The main functions of each hardware part are as follows:
1 CPU main functions:
CPU is the core component of the entire gprs dtu, and it is an embedded high-speed processor. PPP is encapsulated internally.
The dial-up protocol and TCP/IP protocol stack have an embedded operating system.
2 GPRS module, antenna interface, SIM card interface
These three parts are combined to realize the communication function of the GPRS network, mainly to implement signal modulation and decoding, as well as external
The signal conversion between the RF signal and the internal baseband processor registers the dynamic IP address and SIM card number to the data center.
3 flash and SDRAM
These two parts are combined into a storage system for storing and reading various system parameters, as well as various parameters of protocol parameters,
Gprs dtu saves the IP address and port number of the data center, the baud rate of the serial port, and so on in the internal permanent memory.
Internal (usually flash or EEPROM ). Once powered on, the system automatically works according to the set parameters.
4 power processing and watchdog
These two parts are combined into a power control system
[5]
Used to control power supply interruption to achieve automatic heartbeat persistence
Long online. One of the features of the GPRS communication network is that it supports permanent online connection of GPRS terminal devices, which requires that DTU includes
Automatic dial-up upon power-on. The heartbeat packet is always online and supports automatic reconnection and automatic dial-up. Watchdog
The circuit is mainly used to prevent the terminal system from crashing. Once the system crashes, the software is not working properly, and the Watchdog Circuit can enable the system
Automatic restart.
5. Serial Interface
The serial interface provides two-way conversion of serial data. The gprs dtu provides a serial communication interface, and the GPRS
In the design of DTU, the serial port is designed as a "transparent conversion" method, that is, the gprs dtu can
Data is converted to TCP/IP data packets for transmission, without changing the original data communication content.
Working principle of 4.2 GPRS DTU
Gprs dtu process description:
1) After the gprs dtu is powered on, read the working parameters stored in the Internal flash (including the GPRS dialing parameters,
The serial port baud rate and data center IP address have been configured in advance ).
2) log on to the GSM network using gprs dtu and perform gprs ppp dialing. After successful dialing, gprs dtu will receive
An internal IP address randomly assigned by the mobile device. Gprs dtu is a mobile internal LAN device.
To communicate with the Internet.
3) The Public IP address or domain name of the data center is stored in the gprs dtu as a parameter, so that once the GPRS DTU
After successful power-on dialing, You can actively connect to the data center. Gprs dtu initiates TCP or UDP Communication to the data center
Request. After obtaining the response from the center, the gprs dtu considers that the handshake with the center is successful, and the TCP/UDP communication connection has
After the establishment, two-way data communication can be performed.
4) Once the user's serial port data is received, DTU immediately encapsulates the serial port data in a TCP/UDP packet and sends
To the data center for information collection. When DTU receives a TCP/UDP packet from the data center,
Extract the data from the data and immediately send it to the User device through the serial port to control the User device.
4.3 gprs dtu configuration method
Now the typical DTU can work normally only by making some settings on the PC. You can use a serial port
The debugging tool directly uses the configuration command to operate DTU. You can also use graphical configuration and dedicated configuration tools (software and Production
Product Support). You can use the configuration tool to issue and parse all commands. You can also write your own configuration tools.
The system uses the configuration software that comes with gprs dtu. The software is used to set communication parameters and services.
Center IP address.
5. Data Center Software Design
Figure 1 shows that the data center is the central part of the entire control and is stored as a GPRS Remote Control Server.
In, this part of hardware is implemented by PC and other network hardware devices. Because the GPRS module is embedded in DTU
In a client, the Socket network program of the client is embedded into the MCU by gprs dtu.
Network Service Program. Therefore, we use socket applications based on TCP protocol to implement the software design of the service center.
During work, the socket application at the server end specifies a certain port.
Then, call the listen method to listen to the port and respond to the client connection requirements at any time.
[6]
Working Process of the server end interface
As follows: the server is started first, and a set of interfaces is created by calling socket (). Then, BIND () is called
The network address is associated with each other. Call listen () to prepare the set of interfaces for listening and specify the length of its request queue.
5. Wait for the customer request to arrive at the port, and then call accept () to receive the connection. After the data terminal establishes a set of interfaces
You can call connect () to establish a connection with the server. Once a connection is established, the data terminal can communicate with the server,
You can call close () to close the set of interfaces. The TCP-based socket application process can be expressed as 4
Some code on the server is entered:
Listen_fd = socket (pf_inet, sock_stream, 0);/* Create a socket for server listening
*/
Ret = BIND (listen_fd, (struct sockaddr *) & srv_addr, sizeof (srv_addr);/* bind the port */
Ret = listen (listen_fd, 5);/* Start listening */
Com_fd = accept (listen_fd, (struct sockaddr *) & clt_addr, & Len);/* accept the client request
Connect */
Len = read (listen_fd, * readbuf, read_len);/* receives data from the client to the buffer */
Len = write (listen_fd, * writebuf, write_len);/* Send the control command to the client */
Close (listen_fd);/* close the connection */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.