CN115878551B - Method and system for communication between main device and sub device - Google Patents
Method and system for communication between main device and sub device Download PDFInfo
- Publication number
- CN115878551B CN115878551B CN202211721115.0A CN202211721115A CN115878551B CN 115878551 B CN115878551 B CN 115878551B CN 202211721115 A CN202211721115 A CN 202211721115A CN 115878551 B CN115878551 B CN 115878551B
- Authority
- CN
- China
- Prior art keywords
- instruction
- sub
- equipment
- machine
- response
- 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.)
- Active
Links
- 238000004891 communication Methods 0.000 title claims abstract description 21
- 238000000034 method Methods 0.000 title claims abstract description 16
- 230000004044 response Effects 0.000 claims abstract description 58
- 238000010586 diagram Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/02—Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]
Landscapes
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a communication method and a communication system for main equipment and sub equipment. The method comprises the following steps: s1, starting timing by the sub-equipment, and waiting for receiving an instruction sent by the main equipment; s2, if the sub-equipment receives the instruction, judging whether the instruction exists in an instruction table of the sub-equipment; s3, if the instruction exists in the instruction table, the instruction frequency value is increased by one bit, response instruction data are obtained from a cache area of the instruction, and the response instruction data are sent to the main equipment; s4, if the instruction does not exist in the instruction table, adding the instruction into the instruction table, assigning a value of 1 to the frequency number of the instruction and a value of 1 to the weight of the instruction, forwarding the instruction to a machine, and sending response instruction data of the machine to a main device; and S5, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing. The invention reduces the time for the sub-equipment to forward the instruction to the machine and the time for the machine to answer the instruction to the sub-equipment, and improves the response instruction speed.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and a system for communicating between a master device and a slave device.
Background
Generally, as shown in fig. 1, the communication system topology between devices of the internet of things mainly comprises a main device 101, one or more sub-devices 102, one or more machines 103 matched with the sub-devices, and instructions thereof. Wherein the higher the machine complexity, the more instructions. The communication medium between the main device 101 and the sub device 102 may be zigbee, wiFi or RS485, and the communication medium between the sub device and the machine may be RS232, TTL or RS485. When the slave device 102 obtains the data of the machine, the master device 101 needs to send a machine instruction to the slave device 102, the slave device 102 forwards the machine instruction to the machine, the machine responds to the machine instruction, then sends a response instruction to the slave device 102, and the slave device 102 forwards the response instruction to the gateway after receiving the response instruction of the machine.
In the existing communication system between the devices of the Internet of things, the sub-devices adopt a forwarding function, so that the diversity of machines can be met. However, when the data volume of the machine is relatively large, the time delay of the main equipment for acquiring the data of the machine is relatively large; time when the master gets machine data = send instruction to child device time t1 (104) +child device forward instruction to machine time t2 (105) +machine reply instruction to child device time t3 (106) +child device forward reply instruction to master time t4 (107).
Based on the above shortcomings of the communication methods, it is necessary to provide a method and a system for communication between a main device and a sub device.
Disclosure of Invention
The invention aims to provide a method and a system for communication between main equipment and sub equipment, which are used for overcoming the defects in the prior art.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
a method of communication between a master device and a slave device, comprising the steps of:
s1, starting timing by the sub-equipment, and waiting for receiving an instruction sent by the main equipment;
s2, if the sub-equipment receives the instruction, judging whether the instruction exists in an instruction table of the sub-equipment;
s3, if the instruction exists in the instruction table, the instruction frequency value is increased by one bit, response instruction data are obtained from a cache area of the instruction, and the response instruction data are sent to the main equipment;
s4, if the instruction does not exist in the instruction table, adding the instruction into the instruction table, assigning a value of 1 to the frequency number of the instruction and a value of 1 to the weight of the instruction, forwarding the instruction to a machine, and sending response instruction data of the machine to a main device;
and S5, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing.
Further, the step of determining whether the instruction exists in the instruction table of the sub-device in the step S2 is:
assigning a base value of 0;
starting traversing the instruction table for the first time, acquiring a first instruction of the instruction table, if the weight of the instruction is larger than the base value, sending the instruction to a machine, waiting for receiving a response instruction message of the machine, and storing the response instruction message of the machine in a response data area corresponding to the instruction table after receiving the response instruction message of the machine; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
Further, after the first time of traversing the instruction table is finished, the base number value becomes 1, the second time of traversing the instruction table is started, a first instruction of the instruction table is obtained, if the weight value of the instruction is larger than the base number value, the instruction is sent to a machine, a response instruction message of the machine is waited to be received, and after the response instruction message of the machine is received, the response instruction message of the machine is stored in a corresponding response data area in the instruction table; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
The invention also provides a system for the communication method of the main equipment and the sub equipment, which comprises the following steps:
the timing module is used for starting timing by the sub-equipment, waiting for receiving the instruction sent by the main equipment, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing;
the judging module is used for judging whether the instruction exists in the instruction table of the sub-equipment or not if the sub-equipment receives the instruction;
the acquisition module is used for adding one bit to the instruction frequency value if the instruction exists in the instruction table, acquiring response instruction data from a cache area of the instruction and sending the response instruction data to the main equipment;
and the sending module is used for adding the instruction into the instruction table, assigning 1 to the frequency value of the instruction and 1 to the weight value of the instruction if the instruction does not exist in the instruction table, forwarding the instruction to the machine, and sending response instruction data of the machine to the main equipment.
Compared with the prior art, the invention has the advantages that: according to the invention, by adding a frequency algorithm to the sub-equipment, the machine instruction is pre-judged to be received, the response instruction data of the machine instruction is obtained in advance, the machine instruction transmitted by the main equipment is to be received, the response instruction data of the instruction is directly returned, the time t2 for the sub-equipment to forward the instruction to the machine and the time t3 for the machine response instruction to the sub-equipment are reduced, and the response instruction speed is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a topology diagram of a communication system between devices of a general internet of things.
Fig. 2 is a flow chart of an implementation of the present invention.
FIG. 3 is a flow chart of the present invention for determining whether an instruction exists in the instruction table of a child device.
Fig. 4 is a schematic diagram of a master and slave communication system of the present invention.
Detailed Description
The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making clear and defining the scope of the present invention.
Referring to fig. 1-3, the present invention provides a method for communication between a main device and a sub device, comprising the following steps:
step S1, starting timing by the sub-equipment, and waiting for receiving an instruction sent by the main equipment;
and S2, if the sub-equipment receives the instruction, judging whether the instruction exists in an instruction table of the sub-equipment.
Judging whether the instruction exists in an instruction table of the sub-equipment or not: the base number +1 is compared with the base number by traversing the instruction table once each time, and the period for sending the instruction to the machine is determined, which comprises the following steps:
assigning a base value of 0; starting traversing the instruction table for the first time, acquiring a first instruction of the instruction table, if the weight of the instruction is larger than the base value, sending the instruction to a machine, waiting for receiving a response instruction message of the machine, and storing the response instruction message of the machine in a response data area corresponding to the instruction table after receiving the response instruction message of the machine; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
After the first time of traversing the instruction table is finished, the base number value becomes +1 (the value becomes 1), the second time of traversing the instruction table is started, a first instruction of the instruction table is obtained, if the weight value of the instruction is larger than the base number value, the instruction is sent to a machine, a response instruction message of the machine is waited to be received, and after the response instruction message of the machine is received, the response data area corresponding to the instruction table is stored; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
And (3) circulating until all instruction weights are smaller than the base value, assigning the base value to be 0, and repeating the step of traversing the instruction table for the first time to restart traversing the instruction table.
Step S3, if the instruction exists in the instruction table, the instruction frequency value is increased by one bit, response instruction data are obtained from a cache area of the instruction, and the response instruction data are sent to the main equipment;
step S4, if the instruction does not exist in the instruction table, adding the instruction into the instruction table, assigning a value of 1 to the frequency number of the instruction and a value of 1 to the weight of the instruction, forwarding the instruction to a machine, and sending response instruction data of the machine to a main device;
and S5, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing.
The response flow of the sub-equipment comprises the following steps: after the sub-device processes the instruction sent by the main device, according to whether the instruction table has the instruction, the sub-device determines whether to use the response data of the response data area of the instruction table to return to the main device.
Referring to fig. 4, the present invention further provides a system according to the above method for communication between a master device and a slave device, including: the timing module 1 is used for starting timing by the sub-equipment, waiting for receiving the instruction sent by the main equipment, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing; the judging module 2 is used for judging whether the instruction exists in the instruction table of the sub-equipment or not if the sub-equipment receives the instruction; the obtaining module 3 is configured to increase the instruction frequency value by one bit if the instruction exists in the instruction table, obtain response instruction data from the cache area of the instruction, and send the response instruction data to the master device; and the sending module 4 is used for adding the instruction into the instruction table, assigning 1 to the frequency value of the instruction and 1 to the weight value of the instruction if the instruction does not exist in the instruction table, forwarding the instruction to the machine, and sending response instruction data of the machine to the main equipment.
According to the invention, by adding a frequency algorithm to the sub-equipment, the machine instruction is pre-judged to be received, the response instruction data of the machine instruction is obtained in advance, the machine instruction transmitted by the main equipment is to be received, the response instruction data of the instruction is directly returned, the time t2 for the sub-equipment to forward the instruction to the machine and the time t3 for the machine response instruction to the sub-equipment are reduced, and the response instruction speed is improved.
Although the embodiments of the present invention have been described with reference to the accompanying drawings, the patentees may make various modifications or alterations within the scope of the appended claims, and are intended to be within the scope of the invention as described in the claims.
Claims (3)
1. The communication method between the main device and the sub device is characterized by comprising the following steps:
s1, starting timing by the sub-equipment, and waiting for receiving an instruction sent by the main equipment;
s2, if the sub-equipment receives the instruction, judging whether the instruction exists in an instruction table of the sub-equipment;
s3, if the instruction exists in the instruction table, the instruction frequency value is increased by one bit, response instruction data are obtained from a cache area of the instruction, and the response instruction data are sent to the main equipment;
s4, if the instruction does not exist in the instruction table, adding the instruction into the instruction table, assigning a value of 1 to the frequency number of the instruction and a value of 1 to the weight of the instruction, forwarding the instruction to a machine, and sending response instruction data of the machine to a main device;
s5, after the timing of the sub-equipment is finished, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting the timing;
the step of judging whether the instruction exists in the instruction table of the sub-equipment in the step S2 is as follows:
assigning a base value of 0;
starting traversing the instruction table for the first time, acquiring a first instruction of the instruction table, if the weight of the instruction is larger than the base value, sending the instruction to a machine, waiting for receiving a response instruction message of the machine, and storing the response instruction message of the machine in a response data area corresponding to the instruction table after receiving the response instruction message of the machine; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
2. The method for communication between a main device and a sub device according to claim 1, wherein after the first time of traversing the instruction table is finished, the base value becomes 1, the second time of traversing the instruction table is started, the first instruction of the instruction table is obtained, if the weight of the instruction is greater than the base value, the instruction is sent to the machine, the response instruction message of the machine is waited to be received, and after the response instruction message of the machine is received, the response data area corresponding to the instruction table is stored; and acquiring a second instruction of the instruction table until traversing the whole instruction table is finished.
3. A system for a method of communication between a master device and a slave device according to claim 1 or 2,
the timing module is used for starting timing by the sub-equipment, waiting for receiving the instruction sent by the main equipment, finishing timing by the sub-equipment, assigning the frequency value of each instruction to the corresponding instruction weight value, and restarting timing;
the judging module is used for judging whether the instruction exists in the instruction table of the sub-equipment or not if the sub-equipment receives the instruction;
the acquisition module is used for adding one bit to the instruction frequency value if the instruction exists in the instruction table, acquiring response instruction data from a cache area of the instruction and sending the response instruction data to the main equipment;
and the sending module is used for adding the instruction into the instruction table, assigning 1 to the frequency value of the instruction and 1 to the weight value of the instruction if the instruction does not exist in the instruction table, forwarding the instruction to the machine, and sending response instruction data of the machine to the main equipment.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211721115.0A CN115878551B (en) | 2022-12-30 | 2022-12-30 | Method and system for communication between main device and sub device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211721115.0A CN115878551B (en) | 2022-12-30 | 2022-12-30 | Method and system for communication between main device and sub device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115878551A CN115878551A (en) | 2023-03-31 |
CN115878551B true CN115878551B (en) | 2023-08-08 |
Family
ID=85757466
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211721115.0A Active CN115878551B (en) | 2022-12-30 | 2022-12-30 | Method and system for communication between main device and sub device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115878551B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090077187A1 (en) * | 2007-09-14 | 2009-03-19 | Yoshikazu Azuma | Method and apparatus for communications |
CN103713608A (en) * | 2013-12-27 | 2014-04-09 | 广东康宝电器有限公司 | Hierarchical network architecture of wireless Internet-of-Things home system and networking communication method thereof |
CN104836737A (en) * | 2015-03-27 | 2015-08-12 | 北京邮电大学 | Internet of things communication method taking named data as center |
WO2015129664A1 (en) * | 2014-02-27 | 2015-09-03 | オムロン株式会社 | Wireless communication system, wireless communication device, wireless communication method, and program |
CN115065700A (en) * | 2022-06-09 | 2022-09-16 | 施耐德智能技术有限公司 | Electronic equipment and thing networking communication module thereof |
-
2022
- 2022-12-30 CN CN202211721115.0A patent/CN115878551B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090077187A1 (en) * | 2007-09-14 | 2009-03-19 | Yoshikazu Azuma | Method and apparatus for communications |
CN103713608A (en) * | 2013-12-27 | 2014-04-09 | 广东康宝电器有限公司 | Hierarchical network architecture of wireless Internet-of-Things home system and networking communication method thereof |
WO2015129664A1 (en) * | 2014-02-27 | 2015-09-03 | オムロン株式会社 | Wireless communication system, wireless communication device, wireless communication method, and program |
CN104836737A (en) * | 2015-03-27 | 2015-08-12 | 北京邮电大学 | Internet of things communication method taking named data as center |
CN115065700A (en) * | 2022-06-09 | 2022-09-16 | 施耐德智能技术有限公司 | Electronic equipment and thing networking communication module thereof |
Also Published As
Publication number | Publication date |
---|---|
CN115878551A (en) | 2023-03-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110661870B (en) | HPLC communication networking method, device, storage medium and electronic equipment | |
CN1716894B (en) | Power saving method in wireless LAN system | |
US20190116223A1 (en) | Responding to a ranging request from a peer device in a wireless network | |
JPH0620203B2 (en) | Data communication method and communication system | |
CN116546442B (en) | Communication method and device based on non-simultaneous transceiving multilink equipment | |
CN105264931A (en) | Data transmission method, user equipment, base station, and system | |
CN109257133B (en) | Whole-network clock synchronization method and device applied to LTE (Long term evolution) rail transit network | |
CN112565349B (en) | Wireless communication method based on central range hood and related equipment | |
CN115878551B (en) | Method and system for communication between main device and sub device | |
CN111328134B (en) | Synchronization method and device, network element and computer storage medium | |
CN104243110B (en) | A kind of radio sensing network data transmission method based on non real-time acknowledgement mechanism | |
CN112751703A (en) | Communication network establishing method and device, electronic equipment and storage medium | |
KR100424753B1 (en) | Communication terminal accommodating apparatus and communication terminal accommodating method | |
CN111614442B (en) | Network communication method, device, electronic equipment and storage medium | |
CN109495389A (en) | A kind of double-channel mixed logic dynamic algorithm based on water heater intelligent control application | |
CN104507175B (en) | A kind of method of WIA PA network hand-holds equipment Network with Random Multiple Access System | |
JP5276461B2 (en) | Network system | |
CN107819831A (en) | A kind of universal message system based on metaq and mns | |
JP2003348636A (en) | Random access communication system, wireless communication apparatus, and wireless communication system | |
CN107635228B (en) | Equipment networking method based on PMK | |
CN104796997A (en) | Node priority based conflict resolving method in wireless sensor network | |
CN110505676A (en) | Uplink access method and its website, storage device | |
US7249200B2 (en) | Process, communication device and communication module for determining communication identifiers | |
WO2014127672A1 (en) | Method and device for enhancing preamble detection processing capability of wcdma system | |
JP2010171578A (en) | Power line carrier communication system and power line carrier communication device |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address |
Address after: 510000, No. 2, 4, 6, 8, 10, and 12 Donghua Huaye Road, Renhe Town, Baiyun District, Guangzhou City, Guangdong Province (Airport Baiyun) Patentee after: GUANGZHOU FELICITY SOLAR TECHNOLOGY Co.,Ltd. Country or region after: China Address before: No.23, Donghua Xingfu street, Renhe Town, Baiyun District, Guangzhou, Guangdong 510000 Patentee before: GUANGZHOU FELICITY SOLAR TECHNOLOGY Co.,Ltd. Country or region before: China |
|
CP03 | Change of name, title or address |