CN113064733A - LINUX message queue-based multi-application shared serial port communication method - Google Patents

LINUX message queue-based multi-application shared serial port communication method Download PDF

Info

Publication number
CN113064733A
CN113064733A CN202010715519.3A CN202010715519A CN113064733A CN 113064733 A CN113064733 A CN 113064733A CN 202010715519 A CN202010715519 A CN 202010715519A CN 113064733 A CN113064733 A CN 113064733A
Authority
CN
China
Prior art keywords
serial port
data
message queue
linux
serial
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010715519.3A
Other languages
Chinese (zh)
Inventor
蒋世挺
陈思有
朱瑞
张国成
魏明林
胡建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Huayun Information Technology Co Ltd
Original Assignee
Zhejiang Huayun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Huayun Information Technology Co Ltd filed Critical Zhejiang Huayun Information Technology Co Ltd
Priority to CN202010715519.3A priority Critical patent/CN113064733A/en
Publication of CN113064733A publication Critical patent/CN113064733A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The embodiment of the application provides a LINUX message queue-based multi-application serial port sharing communication method, which is applied to an ARM core-based serial port communication board and comprises the steps of controlling an application program needing to call serial port operation to select a serial port number in the serial port communication board according to a preset configuration file, and taking the selected serial port number as a characteristic symbol; and calling a message queue API operation function provided by the LINUX system to perform data transceiving operation in combination with the characteristic symbol. The problem that the number of available serial ports of the intelligent terminal based on the ARM chip LINUX system is small is solved through software functions and peripheral board cards; meanwhile, the number of external serial ports can be increased through simple copying, and the expandability of the serial ports is met.

Description

LINUX message queue-based multi-application shared serial port communication method
Technical Field
The invention relates to the technical field of computers, in particular to a LINUX message queue-based multi-application shared serial port communication method.
Background
With the development of social economy, smart grid and distribution internet of things, a plurality of intelligent acquisition devices are widely applied to each link of electric power data information collection and transmission, because of requirements on service expansion and safety and reliability, a plurality of intelligent terminals begin to adopt an embedded LINUX system platform based on an ARM chip, but the ARM chip which is mainly applied at present has limited serial port channels directly supported by the ARM chip, and cannot meet the access requirements of a large number of intelligent acquisition terminal serial port devices. If the ARM chip bus is used for directly expanding the number of the serial ports, firstly, circuits and development drivers of a CPU core board need to be redesigned, and the number of the second expanded serial ports is limited, so that the expandability is poor along with the development of subsequent services.
Disclosure of Invention
In order to solve the defects in the prior art, the invention provides a LINUX message queue-based multi-application serial port sharing communication method, and solves the problem that the available serial ports of an intelligent terminal based on an ARM chip LINUX system are few by means of software functions and peripheral boards.
Specifically, the LINUX message queue-based multi-application serial port sharing communication method provided by the embodiment of the application is applied to an ARM core-based serial port communication board, and the communication method includes:
controlling an application program needing to call serial port operation to select a serial port number in a serial port communication board according to a preset configuration file, and taking the selected serial port number as a characteristic symbol;
and calling a message queue API operation function provided by the LINUX system to perform data transceiving operation in combination with the characteristic symbol.
Optionally, the serial port communication board based on the ARM core includes:
a serial port of ARM core plate and a main serial port of STM32 serial port board are connected, and other five RS-485 serial ports of STM32 serial port board can be removed to the data transceiver of this serial port of application program through sharing ARM core plate.
Optionally, the controlling an application program that needs to invoke a serial port operation selects a serial port number in the serial port communication board according to a preset configuration file, and takes the selected serial port number as a feature, including:
and controlling an application program needing to operate the serial port to select the serial port number according to the configuration file from the serial port number expanded by the STM32 serial port card.
Optionally, the invoking a message queue API operating function provided by the LINUX system performs data transceiving operation in combination with the feature, including:
the message queue API operating functions provided by the LINUX system can enable data to be enqueued and dequeued by carrying the characteristic symbol through the parameter, and the application program can conveniently receive only own data according to the characteristic symbol.
Optionally, the communication method further includes:
the LINUX system running on the ARM core board comprises a serial communication program, and a data receiving and sending message queue is established after the serial communication program is started;
data sent to the serial port by the application program enters a message sending queue.
Optionally, the communication method further includes:
after controlling serial port communication program to read data from the message queue, sending the data to the main serial port of the STM32 serial port board through the self serial port:
and monitoring the main serial port, and judging whether data reply of the STM32 serial port board communication applet exists.
Optionally, the communication method further includes:
if the reply data exists, the complete frame is analyzed, the queue of the received message is enqueued according to the serial port characteristic symbol, and the application program can receive the data belonging to the application program through the queue of the received message.
Optionally, the communication method further includes:
if the reply data is not received, continuing to monitor whether the sending message queue has data of the application program to be sent, and forming a program cycle of data sending and receiving.
Optionally, the communication method further includes:
the communication applet in STM32 listens to the master serial port for data from the ARM core board.
Optionally, the data is a parameter command for setting 5 serial ports in an STM32 serial port board, or actual data that needs 5 serial ports to forward.
The technical scheme provided by the invention has the beneficial effects that:
the problem that the number of available serial ports of the intelligent terminal based on the ARM chip LINUX system is small is solved through software functions and peripheral board cards; meanwhile, the number of external serial ports can be increased through simple copying, and the expandability of the serial ports is met.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a LINUX message queue-based multi-application serial port sharing communication method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a hardware schematic proposed in an embodiment of the present application;
FIG. 3 is a diagram illustrating a software architecture according to an embodiment of the present application;
fig. 4 is a schematic diagram of a software communication flow according to an embodiment of the present application.
Detailed Description
To make the structure and advantages of the present invention clearer, the structure of the present invention will be further described with reference to the accompanying drawings.
Example one
Specifically, as shown in fig. 1, the LINUX message queue-based multi-application serial port sharing communication method provided in the embodiment of the present application is applied to an ARM core-based serial port communication board, and the communication method includes:
11. controlling an application program needing to call serial port operation to select a serial port number in a serial port communication board according to a preset configuration file, and taking the selected serial port number as a characteristic symbol;
12. and calling a message queue API operation function provided by the LINUX system to perform data transceiving operation in combination with the characteristic symbol.
In implementation, a serial port communication program is developed under the LINUX system to uniformly manage data receiving and transmitting of a plurality of serial ports of an ARM core board, a static library program which encapsulates serial port operations is developed and provided for other application programs to call, and the static library realizes data interaction between the serial port communication program and other application programs by using a message queue of the LINUX system. A peripheral integrated circuit board is developed to the STM32 chip again, the integrated circuit board can be from taking 6 serial ports, one of them main serial port and ARM core board's serial ports are connected, develop a communication applet on this integrated circuit board and be responsible for the data communication of main serial port and ARM core board, and dispatch and distribute received data toward other 5 serial ports, the data that 5 serial ports received simultaneously also can unified the forwarding to ARM core board, so these 5 serial ports just can provide the access of all kinds of serial communication equipment.
Through the steps, various application programs running under the LINUX system of the ARM core board can share serial port communication on the ARM core board through the message queue, and therefore the purpose of accessing equipment by using the extended serial port on the STM32 is achieved.
As shown in fig. 2: a serial port of ARM core plate and a main serial port of STM32 serial port board are connected, and other five RS-485 serial ports of STM32 serial port board can be removed to the data transceiver of this serial port of application program through sharing ARM core plate. The scheduling and distribution of serial port data are mainly realized through the functions of software.
As shown in fig. 3: each application program needs to operate a serial port, a serial port number expanded by a certain STM32 serial port card can be selected according to a configuration file, then a serial port operation function of a serial port encapsulation static library is called, the function in the static library is responsible for registering a message queue and can send and receive data to the message queue according to the serial port number as a characteristic symbol, and the functions can enable the characteristic symbol on a data band to carry out enqueue and dequeue operations through parameters according to the message queue API operation function provided by the LINUX system, and the application programs can conveniently receive the data only belonging to the application programs according to the characteristic symbol.
As shown in fig. 4: the serial port communication program running under the ARM core board LINUX system is responsible for establishing a data receiving and sending message queue after being started, and data sent to the serial port by the application program can enter the sending message queue, wherein the data can be parameter commands for setting 5 sub-serial ports in the STM32 serial port board or actual data needing 5 sub-serial ports to forward. After reading data from the message queue, the serial port communication program sends the data to a main serial port of an STM32 serial port board through a self serial port, then monitors the serial port, judges whether data reply of an STM32 serial port board communication small program exists, if the data reply exists, analyzes a complete frame, and enqueues a received message queue according to serial port characteristic symbols, and an application program can receive data belonging to the application program through the received message queue; if no reply data is received, the method continues to monitor whether the sending message queue has data of the application program to be sent, thereby forming a program cycle of data sending and receiving. Similarly, the communication applet in the STM32 monitors whether the main serial port has data sent by the ARM core board, if so, judges whether the command is a command for setting parameters of 5 sub-serial ports, if so, sets the serial port, and replies a successful setting message; if the command is not the command, the actual data which needs to be forwarded by the 5 sub-serial ports is sent out from one serial port according to the serial port number, the sending is switched to monitor whether the 5 sub-serial ports receive the data or not, if so, a layer of message parameters are packaged according to the serial port number, the message parameters are forwarded to the ARM core board through the main serial port, and then whether the data of the ARM core board arrives or not is continuously monitored through the main serial port, so that the STM32 communication applet also enters a program cycle of data transceiving.
Through the steps, various application programs running under the LINUX system of the ARM core board can share serial port communication on the ARM core board through the message queue, and therefore the purpose of accessing equipment by using the extended serial port on the STM32 is achieved.
The sequence numbers in the above embodiments are merely for description, and do not represent the sequence of the assembly or the use of the components.
The above description is only exemplary of the present invention and should not be taken as limiting the invention, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A communication method based on a LINUX message queue multi-application shared serial port is applied to a serial port communication board based on an ARM core, and is characterized by comprising the following steps:
controlling an application program needing to call serial port operation to select a serial port number in a serial port communication board according to a preset configuration file, and taking the selected serial port number as a characteristic symbol;
and calling a message queue API operation function provided by the LINUX system to perform data transceiving operation in combination with the characteristic symbol.
2. The LINUX message queue-based multi-application serial port sharing communication method of claim 1, wherein the ARM core-based serial port communication board comprises:
a serial port of ARM core plate and a main serial port of STM32 serial port board are connected, and other five RS-485 serial ports of STM32 serial port board can be removed to the data transceiver of this serial port of application program through sharing ARM core plate.
3. The LINUX message queue-based multi-application shared serial port communication method of claim 2, wherein the controlling the application program that needs to invoke the serial port operation selects the serial port number in the serial port communication board according to a preset configuration file, and the selected serial port number is used as a feature, comprising:
and controlling an application program needing to operate the serial port to select the serial port number according to the configuration file from the serial port number expanded by the STM32 serial port card.
4. The LINUX-based message queue multi-application shared serial port communication method of claim 2, wherein calling a message queue API operation function provided by a LINUX system in combination with a feature to perform data transceiving operation comprises:
the message queue API operating functions provided by the LINUX system can enable data to be enqueued and dequeued by carrying the characteristic symbol through the parameter, and the application program can conveniently receive only own data according to the characteristic symbol.
5. The LINUX message queue-based multi-application shared serial port communication method of claim 1, further comprising:
the LINUX system running on the ARM core board comprises a serial communication program, and a data receiving and sending message queue is established after the serial communication program is started;
data sent to the serial port by the application program enters a message sending queue.
6. The LINUX message queue-based multi-application shared serial port communication method of claim 5, further comprising:
after controlling serial port communication program to read data from the message queue, sending the data to the main serial port of the STM32 serial port board through the self serial port:
and monitoring the main serial port, and judging whether data reply of the STM32 serial port board communication applet exists.
7. The LINUX message queue-based multi-application shared serial port communication method of claim 6, further comprising:
if the reply data exists, the complete frame is analyzed, the queue of the received message is enqueued according to the serial port characteristic symbol, and the application program can receive the data belonging to the application program through the queue of the received message.
8. The LINUX message queue-based multi-application shared serial port communication method of claim 6, further comprising:
if the reply data is not received, continuing to monitor whether the sending message queue has data of the application program to be sent, and forming a program cycle of data sending and receiving.
9. The LINUX message queue-based multi-application shared serial port communication method of claim 6, further comprising:
the communication applet in STM32 listens to the master serial port for data from the ARM core board.
10. The LINUX message queue-based multi-application shared serial port communication method according to claim 5, wherein the data is a parameter command for setting 5 sub-serial ports in an STM32 serial port board, or actual data which needs to be forwarded by the 5 sub-serial ports.
CN202010715519.3A 2020-07-23 2020-07-23 LINUX message queue-based multi-application shared serial port communication method Pending CN113064733A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010715519.3A CN113064733A (en) 2020-07-23 2020-07-23 LINUX message queue-based multi-application shared serial port communication method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010715519.3A CN113064733A (en) 2020-07-23 2020-07-23 LINUX message queue-based multi-application shared serial port communication method

Publications (1)

Publication Number Publication Date
CN113064733A true CN113064733A (en) 2021-07-02

Family

ID=76558525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010715519.3A Pending CN113064733A (en) 2020-07-23 2020-07-23 LINUX message queue-based multi-application shared serial port communication method

Country Status (1)

Country Link
CN (1) CN113064733A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020147853A1 (en) * 2001-02-16 2002-10-10 Microsoft Corporation System and method for managing a serial port
KR20040043683A (en) * 2002-11-19 2004-05-24 엘지전자 주식회사 Apparatus and method for scheduling in shared bus system
EA006307B1 (en) * 2004-12-10 2005-10-27 Закрытое Акционерное Общество "Микротест-Инвест" System, method and devices for integration of distributed application
US20120246366A1 (en) * 2011-03-21 2012-09-27 Hon Hai Precision Industry Co., Ltd. Serial port remote control circuit
CN103647728A (en) * 2013-12-07 2014-03-19 成都亿盟恒信科技有限公司 STM32 single chip microcomputer and Linux system high-speed series port anti-interference communication method
CN207594870U (en) * 2017-11-17 2018-07-10 上海酷驾智能技术有限公司 Intelligent HUD systems based on STM32
CN209388294U (en) * 2018-12-04 2019-09-13 广州中国科学院先进技术研究所 A kind of embedded serial port HUB

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020147853A1 (en) * 2001-02-16 2002-10-10 Microsoft Corporation System and method for managing a serial port
KR20040043683A (en) * 2002-11-19 2004-05-24 엘지전자 주식회사 Apparatus and method for scheduling in shared bus system
EA006307B1 (en) * 2004-12-10 2005-10-27 Закрытое Акционерное Общество "Микротест-Инвест" System, method and devices for integration of distributed application
US20120246366A1 (en) * 2011-03-21 2012-09-27 Hon Hai Precision Industry Co., Ltd. Serial port remote control circuit
CN103647728A (en) * 2013-12-07 2014-03-19 成都亿盟恒信科技有限公司 STM32 single chip microcomputer and Linux system high-speed series port anti-interference communication method
CN207594870U (en) * 2017-11-17 2018-07-10 上海酷驾智能技术有限公司 Intelligent HUD systems based on STM32
CN209388294U (en) * 2018-12-04 2019-09-13 广州中国科学院先进技术研究所 A kind of embedded serial port HUB

Similar Documents

Publication Publication Date Title
CN107087303B (en) Base station hardware virtualization method and device and base station
CN102790776A (en) Heartbeat connection normalizing processing method, terminal, server and communication system
CN107133109B (en) Method and device for communication between modules and computing equipment
CN109684073A (en) Electronic device, cloud service resource allocation methods and storage medium
AU2019256257A1 (en) Processor core scheduling method and apparatus, terminal, and storage medium
CN111666145A (en) Message processing method and system of message queue and computer equipment
CN110297722A (en) Thread task communication method and Related product
CN116243853A (en) Data transmission method and device, electronic equipment and nonvolatile storage medium
CN113518431B (en) Communication processing method, terminal, device and storage medium
CN113064733A (en) LINUX message queue-based multi-application shared serial port communication method
CN116800616A (en) Management method and related device of virtualized network equipment
CN112148506A (en) Message processing method, device, platform and storage medium
CN104951373A (en) Message queue processing method of scheduling system
CN110971696B (en) System and method for realizing virtual electronic card communication
CN112367362B (en) Data processing method, device, equipment and computer storage medium
CN101800695A (en) Method for realizing synchronous communication and asynchronous communication by software
CN107466018A (en) The data transferring method and terminal device of a kind of terminal device
CN110008033B (en) Method for communicating with client and electronic equipment
CN109460291A (en) Electronic device, the method for controller perturbation server cluster and storage medium
CN111240867A (en) Information communication system and method
CN107783722B (en) Data transmission method and data forwarding device
CN112187698B (en) Communication method, service system, electronic equipment and host MCU (micro control Unit) of electronic equipment
CN112087373B (en) Message sending method and service device
CN115981924B (en) Device control method, electronic device and storage medium
CN100515121C (en) Realizing method and system of testing service performance for calling center

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination