CN114629743A - Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium - Google Patents

Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium Download PDF

Info

Publication number
CN114629743A
CN114629743A CN202210061120.7A CN202210061120A CN114629743A CN 114629743 A CN114629743 A CN 114629743A CN 202210061120 A CN202210061120 A CN 202210061120A CN 114629743 A CN114629743 A CN 114629743A
Authority
CN
China
Prior art keywords
current
level
data message
stage
address information
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
CN202210061120.7A
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.)
Shenzhen Tuobang Automation Technology Co ltd
Original Assignee
Shenzhen Topband 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 Shenzhen Topband Co Ltd filed Critical Shenzhen Topband Co Ltd
Priority to CN202210061120.7A priority Critical patent/CN114629743A/en
Publication of CN114629743A publication Critical patent/CN114629743A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/403Bus networks with centralised control, e.g. polling

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention discloses a method, a device, a system, electronic equipment and a storage medium for identifying a serial port of slave equipment, which relate to the technical field of serial port communication, wherein the method for identifying the serial port of the slave equipment comprises the steps of acquiring a data message sent by main equipment, extracting address information from the data message, or acquiring a data message sent by the slave equipment of the previous stage, and extracting the address information from the data message; performing address change operation on the address information to obtain current-level address information corresponding to the current level; packaging the address information of the current level to form a data message of the current level; and sending the current-stage data message to the master equipment for identification. Therefore, the master equipment only needs to send the data message once, and the slave equipment at each level can automatically send the data message corresponding to the level of the slave equipment in sequence, so that the inquiry times of the master equipment are greatly reduced, and the data transmission efficiency is improved; and the complexity of manually setting address information is avoided, address repetition or address setting errors are avoided, and the mounting efficiency and the accuracy of flow work are improved.

Description

Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of serial port communication, in particular to a method, a device and a system for identifying a serial port of slave equipment, electronic equipment and a storage medium.
Background
The serial bus is widely applied to electronic industry products, and generally, one master device and a plurality of slave devices are hung on the bus, and the master device stores the number of the slave devices and the address of each slave device. When the system works, the master device acquires the information of the slave device in a polling mode by virtue of the slave device address, and then the master device collects the information.
In the working mode of the serial port bus, all slave devices can receive messages sent by the master device; meanwhile, the master device can also receive messages sent back by all the slave devices. Therefore, all devices hanging on the bus must be configured with a unique address to be correctly identified. Configuring these addresses often causes extra workload for the constructors and is prone to errors, such as address duplication, setting errors, and the like. In actual work, the method is very troublesome.
Disclosure of Invention
The invention aims to provide a method, a device, a system, an electronic device and a storage medium for identifying a serial port of a slave device without manually configuring an address and avoiding address errors.
The technical scheme adopted by the invention for solving the technical problems is as follows:
in one aspect, the present invention provides a method for identifying a serial port of a slave device, including:
acquiring a data message sent by a master device, and extracting address information from the data message, or acquiring a data message sent by a slave device at a previous stage, and extracting address information from the data message;
executing address change operation on the address information to obtain current level address information corresponding to the current level;
packaging the current-stage address information to form a current-stage data message;
and sending the current-stage data message to the main equipment for identification.
In some embodiments, after performing the address change operation on the address information and obtaining the current-level address information corresponding to the current level, the method further includes:
acquiring a preset polling end identifier;
assigning the polling end identifier according to a level signal sent by the next-level slave device;
and packaging the current-stage address information and the polling end identifier to form a current-stage data message.
In some embodiments, the assigning the polling end identifier according to the level signal sent by the slave device at the next stage includes:
and setting 1 operation on the preset polling end identifier according to a high-level signal sent by the next-level slave device, or setting 0 operation on the polling end identifier according to a high-level signal sent by the next-level slave device.
In some embodiments, after performing the assignment operation on the polling end identifier according to the level signal sent by the slave device at the next stage, the method further includes:
acquiring preset delay time corresponding to the current level;
delaying by a preset delay time corresponding to the current level;
and sending out the current-stage data message.
In some embodiments, the obtaining the preset delay time includes:
extracting preset delay time corresponding to the current level from the data message, delaying by using the preset delay time corresponding to the current level, and delaying by using default delay time if the preset delay time corresponding to the current level in the data message is vacant;
acquiring the preset delay time corresponding to the next-stage slave equipment;
and packaging the preset delay time corresponding to the next-level slave equipment, the current-level address information and the polling end identifier to form the current-level data message.
In some embodiments, after obtaining the preset delay time corresponding to the next-stage slave device, the method further includes:
and if the preset delay time corresponding to the next-level slave equipment is vacant, the preset delay time is vacant, and the current-level address information and the polling ending identifier are packaged to form the current-level data message.
In some embodiments, the obtaining the preset delay time corresponding to the next-stage slave device includes:
and obtaining the preset delay time corresponding to the next-level slave equipment according to the data operation amount, the data transmission amount, the operation speed and the transmission speed of the current-level slave equipment.
In a second aspect, the present invention further provides an apparatus for identifying a serial port of a slave device, including:
the acquisition module is used for acquiring a data message sent by the master equipment and extracting address information from the data message, or acquiring a data message sent by the slave equipment at the previous stage and extracting the address information from the data message;
the change module is used for executing address change operation on the address information to obtain current level address information corresponding to the current level;
the packaging module is used for packaging the address information of the current stage to form a data message of the current stage;
and the sending module is used for sending the current-stage data message to the main equipment for identification.
In a third aspect, the present invention further provides a system for identifying a serial port of a slave device, including: the system comprises a master device and n slave devices, wherein n is a positive integer greater than or equal to 1;
the master device is configured to send a data packet to the slave device of station 1, where the data packet includes address information;
the slave device is used for acquiring a data message sent by the master device and extracting address information from the data message, or acquiring a data message sent by the slave device at the previous stage and extracting address information from the data message; executing address change operation on the address information to obtain current level address information corresponding to the current level; packaging the current-stage address information to form a current-stage data message; and sending the current-stage data message to the main equipment for identification.
In some embodiments, the slave device is further configured to:
acquiring a polling end identifier;
assigning the polling end identifier according to a level signal sent by the next-level slave device;
and packaging the polling end identifier and the current-stage address information to form the current-stage data message.
In some embodiments, the master device is further to:
judging whether the current-stage slave equipment is the last-stage slave equipment or not according to the polling end identifier;
and after the data message sent by the last-stage slave equipment is received, judging whether to send a next polling data message to the 1 st slave equipment according to a polling initiating condition, wherein the next polling data message contains address information.
In some embodiments, the slave device is further configured to:
acquiring preset delay time corresponding to the slave equipment of the current level;
delaying by a preset delay time corresponding to the current level;
and sending out the current-level data message.
In some embodiments, the master device is further to:
acquiring preset delay time of the current-stage slave equipment from a data message sent by the previous-stage slave equipment;
obtaining the waiting receiving time of the current level corresponding to the slave equipment of the current level according to the preset delay time corresponding to the slave equipment of the current level;
and generating a fault message corresponding to the current-level slave equipment according to whether the current-level data message sent by the current-level slave equipment is received within the current-level waiting receiving time, wherein the fault message contains the address information of the current-level slave equipment.
In a fourth aspect, the present invention also provides an electronic device, comprising:
a processor; and
a memory having executable code stored thereon, which when executed by the processor, causes the processor to perform any of the above-described methods of identifying a serial port of a slave device.
In a fifth aspect, the present invention also provides a computer-readable storage medium having stored thereon executable code, which, when executed by a processor of an electronic device, causes the processor to execute any one of the above-mentioned methods for identifying a serial port of a slave device.
The method, the device, the system, the electronic equipment and the storage medium for identifying the serial port of the slave equipment have at least the following beneficial effects:
according to the method, the device, the system, the electronic equipment and the storage medium for identifying the serial port of the slave equipment, the slave equipment receives the data message of the slave equipment or the master equipment of the previous stage, generates the current stage data message after the address information is changed, and sends the current stage data message to the master equipment; therefore, the master equipment only needs to send the data message once, and the slave equipment at each level can automatically send the data message corresponding to the level of the slave equipment in sequence, so that the inquiry times of the master equipment are greatly reduced, and the data transmission efficiency is improved; meanwhile, the complexity of manually setting address information is avoided, address repetition or address setting errors are avoided, and the installation efficiency and the accuracy of flow work are improved.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flow chart of a method of identifying a serial port of a slave device in a preferred embodiment of the present invention;
FIG. 2 is a flow chart of a method for identifying a serial port of a slave device in accordance with another preferred embodiment of the present invention;
FIG. 3 is a block diagram of a system for identifying serial ports of slave devices in accordance with a preferred embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for identifying a serial port of a slave device in a preferred embodiment of the present invention.
Detailed Description
For a more clear understanding of the technical features, objects and effects of the present invention, embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
Fig. 1 illustrates a method of identifying a serial port of a slave device in some preferred embodiments of the invention, including:
acquiring a data message sent by a master device, and extracting address information from the data message, or acquiring a data message sent by a slave device at a previous stage, and extracting the address information from the data message;
it can be understood that a polling start mark may be inserted in a data message sent by the master device, and after the primary slave device recognizes the polling start mark, the primary slave device starts to generate address information corresponding to the primary slave device; certainly, a polling start mark may not be inserted into a data packet sent by the master device, and the first-stage slave device starts to execute the predetermined step after receiving the data packet;
starting from the second-level slave device, the slave device comprises the second-level slave device, and each level of slave device acquires the address information of the slave device of the previous level from the data message sent by the slave device of the previous level; for example, the nth level slave device will obtain address information from the nth-1 level slave device, where N is a natural number greater than or equal to 2.
Performing address change operation on the address information to obtain current-level address information corresponding to the current level;
it can be understood that, in the data message acquired by the primary slave device from the master device, the data message may be configured to contain address data information related to the master device, or may be configured to be blank address information, and the primary slave device changes the address information into data information corresponding to the primary slave device after acquiring the address information;
of course, the data packet sent by the master device may also default to carry address information corresponding to the primary slave device, so that the address information is not changed in the address information change operation performed by the primary slave device, and the address information is directly used to perform subsequent steps. The data messages received by the secondary slave equipment and the data messages received by the secondary slave equipment contain address information corresponding to the previous secondary slave equipment, and address information corresponding to the secondary slave equipment level is obtained after address change is carried out on the address information.
Packaging the current-level address information to form a current-level data message;
it is understood that the current-level data message may also contain various other types of information that need to be received or processed by the master device, such as time, times, or priority information.
It can also be understood that each data packet received by the master device carries address information corresponding to the slave device level of the data source, and the master device can know, through the address information, which slave device sent the data packet. When each level of slave equipment sends the current level of data message corresponding to its own level to the master equipment, if the next level of slave equipment exists, the current level of address information in the current level of data message is acquired by the next level of slave equipment.
As shown in fig. 1 and fig. 2, in some embodiments, after performing an address change operation on the address information and obtaining current-level address information corresponding to a current level, the method further includes:
acquiring a preset polling end identifier;
it is to be understood that the polling end identifier obtained by the current-stage slave device may be obtained from a data packet sent by the previous-stage slave device, may be a value preset in the slave device, or may be a blank value.
Assigning a value to the polling end identifier according to a level signal sent by the next-stage slave equipment;
it is to be understood that, when the current-stage slave device and the next-stage slave device are transmitted through a dedicated level signal transmission line, the determining process may be configured such that, when the current-stage slave device receives a high-level or ground-level signal sent by the next-stage slave device, the polling end identifier is assigned with a value recognizable by the master device, so that the master device may determine whether the current-stage slave device is the last-stage slave device and whether it needs to receive a data packet of the next-stage slave device according to the value.
And packaging the current-level address information and the polling end identifier to form a current-level data message.
It can be understood that, when the current-stage slave device packages the assigned polling end identifier and the current-stage address information corresponding to the current stage after the change to form a current-stage data packet, and the next-stage slave device also obtains required information and data from the data packet in the process of sending the data packet to the master device.
As shown in fig. 2, in some embodiments, the assigning the polling end identifier according to the level signal sent by the slave device at the next stage may include:
and setting 1 operation on the preset polling end identifier according to a high-level signal sent by the slave equipment of the next level, or setting 0 operation on the polling end identifier according to a high-level signal sent by the slave equipment of the next level.
It should be understood that the preset polling end identifier may be a default value preset in the current slave device, and of course, may also be a polling end identifier in a data packet sent from the superior slave device as the preset polling end identifier of the current slave device;
the determining process may be configured to: if the next-stage slave equipment exists, the next-stage slave equipment can fixedly output a high-level signal to the current-stage slave equipment, and the preset polling end identifier is set to be 1 when the current-stage slave equipment receives the high-level signal;
if the next-stage slave equipment does not exist, the level signal acquired by the current-stage slave equipment is at a low level, and the preset polling ending identifier is set to be 0 when the current-stage slave equipment receives the low level signal;
of course, if the next-stage slave device is configured not to send the data packet in the current polling, the next-stage slave device will send a low-level signal to the current-stage slave device, and the current-stage slave device, receiving the low-level signal, will set the polling end identifier to 0 as well;
the polling end identifier set to 0 or 1 is packaged into a current level data message and sent to the master device.
It is also understood that the above-mentioned determining process may be further configured such that when the current slave device receives a high signal, the polling end identifier is set to 0, and when the slave device receives a low signal, the polling end identifier is set to 1; specifically, the master device may distinguish whether it needs to receive the data packet of the next-level slave device.
In some embodiments, after performing the assignment operation on the polling end identifier according to the level signal sent by the slave device at the next stage, the method further includes:
acquiring preset delay time corresponding to the current level;
it can be understood that, after the data packet is sent from the previous-stage slave device by any one-stage slave device, the preset delay time may be obtained from the previous-stage data packet, and of course, the preset delay time may also be obtained from the current-stage slave device.
Delaying by a preset delay time corresponding to the current level;
it can be understood that the length of the preset delay time may be a time condition, or may be other conditions, and the subsequent steps are executed after the corresponding conditions are met.
And sending out the current-stage data message.
It can be understood that, after the current-stage slave device obtains the preset delay time, the current-stage slave device delays the preset delay time and then sends out the current-stage data packet. In the delay process, the current-stage slave device can synchronously execute data value acquisition and execute corresponding operation, so that time is saved, and the polling efficiency is improved.
In this embodiment, the data packets sent by the slave devices of different levels are prevented from colliding with each other by delaying, and the data packet sent by the slave device of the current level is delayed to provide necessary time for the data packet of the slave device of the previous level. In addition, after the first-level slave device acquires the data message sent by the slave device, the first-level slave device can directly package and send the data message corresponding to the first-level slave device without delay.
In some embodiments, obtaining the preset delay time may include:
extracting preset delay time corresponding to the current level from the data message, delaying by using the preset delay time corresponding to the current level, and delaying by using default delay time if the preset delay time corresponding to the current level in the data message is vacant;
it can be understood that the current-stage slave device obtains the preset delay time from the data packet sent by the previous-stage slave device, and sends the current-stage data packet to the master device after delaying according to the preset delay time. If the data message sent by the previous-stage slave equipment does not contain the preset delay time corresponding to the current-stage slave equipment, the current-stage data message is sent out after the delay is carried out by default delay time. The default delay time may be that the previous-stage slave device packages into the previous-stage data message, or may be preset in the current-stage slave device.
Acquiring preset delay time corresponding to the next-stage slave equipment;
it can be understood that the preset delay time corresponding to the next-stage slave device may be set according to the data packet generation time and transmission time of the current-stage slave device, or may be the delay time preset in the next-stage slave device in the current-stage slave device.
And packaging the preset delay time corresponding to the next-level slave equipment, the current-level address information and the polling ending identifier to form a current-level data message.
It can be understood that after the delay is performed by the preset delay time or the default delay time, the current-stage slave device will send the current-stage data message formed by packaging to the master device, and after sending, the next-stage slave device will also obtain the corresponding preset delay time, and in the delay process, the next-stage slave device may perform operations such as address change, polling identifier acquisition, and the like, so as to fully utilize the delay time, ensure the continuity in the polling process, and improve the data transmission efficiency.
In some embodiments, after obtaining the preset delay time corresponding to the slave device of the next stage, the method further includes:
and if the preset delay time corresponding to the next-stage slave equipment is vacant, the preset delay time is vacant, and the current-stage address information and the polling ending identifier are packaged to form the current-stage data message.
It can be understood that the delay time used by each level of slave device after receiving the data packet sent by the previous level of slave device may be the same or different; optionally, the current-stage slave device may choose to idle the preset delay time of the next-stage slave device, so that the next-stage slave device performs delay by using the default delay time.
It can also be understood that the default delay time adopted by each level of slave devices after obtaining the data message may be changed in a later stage by modifying the corresponding parameter value; for example, the default delay time preset in each level of slave device may be modified through the cloud, the data packet sent to the first level of slave device by the master device may be gradually transmitted to each level of slave device to update the default delay time, and the data packet may be modified and updated in other manners capable of modifying parameters of the data in the slave device in the prior art.
In some embodiments, obtaining the preset delay time corresponding to the next-stage slave device includes:
and obtaining the preset delay time corresponding to the next-level slave equipment according to the data operation amount, the data transmission amount, the operation speed and the transmission speed of the current-level slave equipment.
It can be understood that the preset delay time of the next-stage slave device needs to yield the data packet generation time and the data packet transmission time of the current-stage slave device, so as to avoid that the next-stage slave device sends out the data packet before the current-stage slave device, and also avoid that the next-stage slave device sends out the data packet during the transmission process of the current-stage slave device, thereby preventing data collision.
Preferably, the data operand may be a remaining required operand of the slave device of the current stage, so that the slave device of the next stage may send out the data packet immediately after the slave device of the current stage completes data transmission, especially in a case where the operand of the slave device of the next stage is smaller and generation of the data packet is already completed.
It can be understood that, by the above further preferred embodiment, the vacuum period of data operation or data transmission between two adjacent stages of slave devices can be further avoided, and the polling efficiency is improved.
Fig. 3 shows an apparatus 100 for identifying a serial port of a slave device in some preferred embodiments of the present invention, which includes an obtaining module 110, a changing module 120, a packaging module 130, and a sending module 140. Wherein:
the obtaining module 110 is configured to obtain a data packet sent by a master device, and extract address information from the data packet, or obtain a data packet sent by a slave device at a previous stage, and extract address information from the data packet.
It is understood that after the obtaining module extracts the address information, the address information is sent to the changing module.
The changing module 120 is configured to perform an address changing operation on the address information to obtain current-level address information corresponding to the current level.
It can be understood that the corresponding address change operating program or address change program may be preset in the change module directly, and the change module may input the address information into the corresponding program or operation step, so as to obtain the current-level address information corresponding to the current-level slave device level.
The packing module 130 is configured to pack the current-level address information into a current-level data packet.
It is to be understood that the packing module may also pack other data to be packed together into the current-stage data message, for example, various operation results, detection data or abnormal data of the current-stage slave device may be optionally packed into the current-stage data message.
The sending module 140 is configured to send the current-level data packet to the host device for identification.
It will be appreciated that the sending module functions as a data transfer.
Further, the apparatus for identifying a serial port of a slave device may further include a delay module 150, where the delay module is configured to delay the sending of the current-stage data message. It can be understood that the obtaining module may be further configured to obtain a delay time of the current-stage slave device, and the sending module sends the current-stage data packet after the delay module uses the delay time to perform delay.
Fig. 4 illustrates a system 200 for identifying serial ports of slave devices in some preferred embodiments of the invention, comprising: the master device 210 and n slave devices 220, where n is a positive integer greater than or equal to 1;
the master device 210 is configured to send a data packet to the 1 st slave device, where the data packet includes address information;
it is understood that the data packet sent by the master device may directly contain address information of the primary slave device, or directly contain data capable of assigning and defining address information of the primary slave device, or contain blank address information.
The slave device 220 is configured to obtain a data packet sent by the master device and extract address information from the data packet, or obtain a data packet sent by a higher-level slave device and extract address information from the data packet; performing address change operation on the address information to obtain current-level address information corresponding to the current level; packaging the address information of the current level to form a data message of the current level; and sending the current-stage data message to the main equipment for identification.
It can be understood that, if the current-stage slave device is the first-stage slave device, the first-stage slave device will extract address information from the data packet sent by the master device; if the current-stage slave device is the rest slave devices, the current-stage slave device extracts the address information from the data message sent by the previous-stage slave device.
As shown in fig. 4, in the system for identifying a serial port of a slave device of some embodiments, the slave device is further configured to:
acquiring a polling end identifier;
performing assignment operation on the polling end identifier according to a level signal sent by the next-level slave equipment;
and packaging the polling end identifier and the current-level address information to form a current-level data message.
It is to be understood that the polling end identifier obtained by the current-stage slave device may be obtained from a data packet sent by the previous-stage slave device, may be a value preset in the slave device, or may be a blank value. After receiving the current-level data message, the master device judges whether a next-level slave device exists according to the numerical value of the polling end identifier, so as to judge whether polling is ended.
As shown in fig. 4, in the system for identifying a serial port of a slave device according to some embodiments, the master device is further configured to:
judging whether the current-stage slave equipment is the last-stage slave equipment or not according to the polling end identifier;
and after the data message sent by the last-stage slave equipment is received, judging whether to send the next polling data message to the 1 st slave equipment according to the polling initiating condition, wherein the next polling data message contains address information.
It can be understood that the master device obtains and identifies the polling end identifier, and determines whether the next-level slave device exists according to the polling end identifier, so as to determine whether the data packet of the next-level slave device needs to be received after the data packet sent by the current-level slave device is received, and if the next-level slave device does not exist, the current polling is ended.
It can also be understood that after the data packet sent by the last-stage slave device is received, and after the current polling is completed, the master device obtains the corresponding data information according to the polling initiation condition, and determines whether to initiate a new round of polling. For example: whether the time interval data from the last polling initiation meets a preset polling period or not, whether the current time meets the preset polling initiation time or not, or whether a new round of polling needs to be initiated or not is judged according to information in data messages sent by slave devices at all levels.
As shown in fig. 4, in the system for identifying a serial port of a slave device of some embodiments, the slave device is further configured to:
acquiring preset delay time corresponding to slave equipment of the current level;
delaying by a preset delay time corresponding to the current level;
and sending out the current-stage data message.
It can be understood that, after the delay of the preset delay time, the current-stage slave device will send out the current-stage data message; in the time period of the preset delay time, the slave equipment synchronously generates data messages, so that the operation and polling efficiency are ensured; secondly, even if the generation of the current-stage data message is completed within the time period of the preset delay time, the slave device will send out the current-stage data message under the condition that the preset delay time condition is met.
As shown in fig. 4, in the system for identifying a serial port of a slave device according to some embodiments, the master device is further configured to:
acquiring preset delay time of the current-stage slave equipment from a data message sent by the previous-stage slave equipment;
obtaining the waiting receiving time of the current level corresponding to the slave equipment of the current level according to the preset delay time corresponding to the slave equipment of the current level;
and generating a fault message corresponding to the slave equipment of the current level according to whether the data message of the current level sent by the slave equipment of the current level is received within the waiting receiving time of the current level, wherein the fault message contains the address information of the slave equipment of the current level.
It can be understood that, after receiving the data packet of the previous level slave device, the master device obtains the preset delay sending time of the current level slave device from the previous level data packet, and may appropriately extend the time length on the basis of the preset delay sending time to obtain the current level waiting receiving time corresponding to the current level slave device, and of course, the preset delay sending time may also be directly used as the current level waiting receiving time;
for this reason, it should be noted that the delay sending time of each level of slave device needs to be set according to the operation amount and sending time length that the previous level of slave device needs to execute, and the like, so as to avoid the problems of data collision or data distortion and the like caused by mutual interference of data messages sent by two slave devices. Correspondingly, if the data message sent by the previous-stage slave equipment does not contain the preset delay time of the current-stage slave equipment, the current-stage slave equipment delays according to the default time and then sends the data message, and the master equipment waits for receiving the data message sent by the current-stage slave equipment according to the receiving waiting time corresponding to the default delay time.
If the master device does not receive the data message of the slave device of the current level after the waiting receiving time of the current level is exceeded, the address information of the slave device of the current level is generated according to the data message sent by the slave device of the previous level, and the address information of the current level is packaged to form a fault message; therefore, the user can quickly determine the fault occurrence address according to the fault message, and the maintenance efficiency is improved.
An electronic device in some preferred embodiments of the invention, comprising:
a processor; and
a memory having executable code stored thereon, the executable code, when executed by the processor, causing the processor to perform a method of identifying a serial port of a slave device as in any of the above embodiments.
It will be appreciated that the processor may be any of a variety of processors capable of performing data processing in the art. The memory can be a component with a certain memory function in the prior art. In the actual use process of the electronic equipment, the execution code in the memory is executed by the processor, so that each step in the method for identifying the serial port of the slave equipment in each embodiment can be completed, the identification of the serial port of the slave equipment is automatically completed, the complexity of manually configuring the address is avoided, and errors such as address repetition are also avoided.
The computer readable storage medium in some embodiments of the present invention has stored thereon executable code, which when executed by a processor of an electronic device, causes the processor to perform the method for identifying a serial port of a slave device in any of the above embodiments.
It can be understood that the computer-readable storage medium provided in this embodiment may be further written into a predetermined electronic device through remote transmission, socket direct transmission, or cloud transmission, or may be directly assembled into a corresponding electronic device; when the electronic equipment is in operation, a processor in the electronic equipment can automatically execute each step in the method for identifying the serial port of the slave equipment. Therefore, the trouble of manually configuring the address information is avoided, and errors such as address repetition are avoided.
The method, the device, the system, the electronic equipment and the storage medium for identifying the serial port of the slave equipment have at least the following beneficial effects:
according to the method, the device, the system, the electronic equipment and the storage medium for identifying the serial port of the slave equipment, the slave equipment receives the data message of the slave equipment or the master equipment of the previous stage, generates the current stage data message after the address information is changed, and sends the current stage data message to the master equipment; therefore, the master equipment only needs to send the data message once, and the slave equipment at each level can automatically send the data message corresponding to the level of the slave equipment in sequence, so that the inquiry times of the master equipment are greatly reduced, and the data transmission efficiency is improved; meanwhile, the complexity of manually setting address information is avoided, address repetition or address setting errors are avoided, and the installation efficiency and the accuracy of flow work are improved.
The above embodiments are merely illustrative of the technical ideas and features of the present invention, and are intended to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the scope of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the claims of the present invention.

Claims (15)

1. A method for identifying a serial port of a slave device is characterized by comprising the following steps:
acquiring a data message sent by a master device, and extracting address information from the data message, or acquiring a data message sent by a slave device at a previous stage, and extracting address information from the data message;
executing address change operation on the address information to obtain current level address information corresponding to the current level;
packaging the current-stage address information to form a current-stage data message;
and sending the current-stage data message to the main equipment for identification.
2. The method according to claim 1, wherein after performing an address change operation on the address information to obtain current-level address information corresponding to a current level, the method further comprises:
acquiring a preset polling end identifier;
assigning the polling end identifier according to a level signal sent by the next-level slave equipment;
and packaging the current-stage address information and the polling end identifier to form a current-stage data message.
3. The method for identifying the serial port of the slave device according to claim 2, wherein the assigning the polling end identifier according to the level signal sent by the slave device of the next stage comprises:
and setting 1 operation on the preset polling end identifier according to a high-level signal sent by the next-level slave device, or setting 0 operation on the polling end identifier according to a high-level signal sent by the next-level slave device.
4. The method for identifying the serial port of the slave device according to claim 2, wherein after the assigning operation is performed on the polling end identifier according to the level signal sent by the slave device of the next stage, the method further comprises:
acquiring preset delay time corresponding to the current level;
delaying by a preset delay time corresponding to the current level;
and sending out the current-stage data message.
5. The method for identifying the serial port of the slave device according to claim 4, wherein the obtaining the preset delay time comprises:
extracting preset delay time corresponding to the current level from the data message, delaying by using the preset delay time corresponding to the current level, and delaying by using default delay time if the preset delay time corresponding to the current level in the data message is vacant;
acquiring the preset delay time corresponding to the next-stage slave equipment;
and packaging the preset delay time corresponding to the next-level slave equipment, the current-level address information and the polling end identifier to form the current-level data message.
6. The method for identifying a serial port of a slave device according to claim 5, wherein after the obtaining of the preset delay time corresponding to the slave device of the next stage, the method further comprises:
and if the preset delay time corresponding to the next-level slave equipment is vacant, the preset delay time is vacant, and the current-level address information and the polling ending identifier are packaged to form the current-level data message.
7. The method for identifying the serial port of the slave device according to claim 5, wherein the obtaining the preset delay time corresponding to the slave device of the next stage comprises:
and obtaining the preset delay time corresponding to the next-level slave equipment according to the data operation amount, the data transmission amount, the operation speed and the transmission speed of the current-level slave equipment.
8. An apparatus for identifying a serial port of a slave device, comprising:
the acquisition module is used for acquiring a data message sent by the master equipment and extracting address information from the data message, or acquiring a data message sent by the slave equipment at the previous stage and extracting the address information from the data message;
the change module is used for executing address change operation on the address information to obtain current level address information corresponding to the current level;
the packaging module is used for packaging the address information of the current stage to form a data message of the current stage;
and the sending module is used for sending the current-stage data message to the main equipment for identification.
9. A system for identifying a serial port of a slave device, comprising: the system comprises a master device and n slave devices, wherein n is a positive integer greater than or equal to 1;
the master device is configured to send a data packet to the slave device of station 1, where the data packet includes address information;
the slave device is used for acquiring a data message sent by the master device and extracting address information from the data message, or acquiring a data message sent by a superior slave device and extracting address information from the data message; executing address change operation on the address information to obtain current level address information corresponding to the current level; packaging the current-stage address information to form a current-stage data message; and sending the current-stage data message to the main equipment for identification.
10. The system for identifying a serial port of a slave device according to claim 9, wherein the slave device is further configured to:
acquiring a polling end identifier;
assigning the polling end identifier according to a level signal sent by the next-level slave equipment;
and packaging the polling end identifier and the current-stage address information to form the current-stage data message.
11. The system for identifying a serial port of a slave device according to claim 10, wherein the master device is further configured to:
judging whether the current-stage slave equipment is the last-stage slave equipment or not according to the polling end identifier;
and after the data message sent by the last-stage slave equipment is received, judging whether to send a next polling data message to the 1 st slave equipment according to a polling initiating condition, wherein the next polling data message contains address information.
12. The system for identifying a serial port of a slave device according to claim 9, wherein the slave device is further configured to:
acquiring preset delay time corresponding to the slave equipment of the current level;
delaying by a preset delay time corresponding to the current level;
and sending out the current-stage data message.
13. The system for identifying a serial port of a slave device according to claim 12, wherein the master device is further configured to:
acquiring preset delay time of the current-stage slave equipment from a data message sent by the previous-stage slave equipment;
obtaining the waiting receiving time of the current level corresponding to the slave equipment of the current level according to the preset delay time corresponding to the slave equipment of the current level;
and generating a fault message corresponding to the current-level slave equipment according to whether the current-level data message sent by the current-level slave equipment is received within the current-level waiting receiving time, wherein the fault message contains the address information of the current-level slave equipment.
14. An electronic device, comprising:
a processor; and
a memory having executable code stored thereon, which when executed by the processor, causes the processor to perform the method of any one of claims 1 to 7.
15. A computer readable storage medium having stored thereon executable code which, when executed by a processor of an electronic device, causes the processor to perform the method of any of claims 1 to 7.
CN202210061120.7A 2022-01-19 2022-01-19 Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium Pending CN114629743A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210061120.7A CN114629743A (en) 2022-01-19 2022-01-19 Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210061120.7A CN114629743A (en) 2022-01-19 2022-01-19 Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114629743A true CN114629743A (en) 2022-06-14

Family

ID=81897633

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210061120.7A Pending CN114629743A (en) 2022-01-19 2022-01-19 Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114629743A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101309306A (en) * 2008-07-16 2008-11-19 哈尔滨工业大学 Method for allocating addresses from node device in Modbus communication network
EP3016334A1 (en) * 2014-10-28 2016-05-04 Insys Microelectronics GmbH Modular router system and method for the modification of a hardware-based router configuration
CN108270883A (en) * 2018-02-02 2018-07-10 深圳曼顿科技有限公司 Can automatic dispensing device address code method, breaker and storage medium
CN111865745A (en) * 2020-06-12 2020-10-30 深圳拓邦股份有限公司 Non-delay polling method and system for automatically identifying slave equipment
CN112905508A (en) * 2021-02-01 2021-06-04 浙江中拓合控科技有限公司 Address allocation method, communication device and storage medium for serial communication equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101309306A (en) * 2008-07-16 2008-11-19 哈尔滨工业大学 Method for allocating addresses from node device in Modbus communication network
EP3016334A1 (en) * 2014-10-28 2016-05-04 Insys Microelectronics GmbH Modular router system and method for the modification of a hardware-based router configuration
CN108270883A (en) * 2018-02-02 2018-07-10 深圳曼顿科技有限公司 Can automatic dispensing device address code method, breaker and storage medium
CN111865745A (en) * 2020-06-12 2020-10-30 深圳拓邦股份有限公司 Non-delay polling method and system for automatically identifying slave equipment
CN112905508A (en) * 2021-02-01 2021-06-04 浙江中拓合控科技有限公司 Address allocation method, communication device and storage medium for serial communication equipment

Similar Documents

Publication Publication Date Title
CN110177013B (en) FPGA-based EtherCAT master-slave station design and implementation method
US10802960B2 (en) Flash medium access method and controller
JP6355275B2 (en) Realization method of broadband bus setting management in industrial Internet site
CN109495215B (en) Communication method, system and device of half-duplex bus and readable storage medium
WO2020259551A1 (en) Method and apparatus for handling network connection fault
CN111245776A (en) Vehicle-mounted data transmission method, device, equipment and storage medium
CN115242689B (en) Vehicle-mounted gateway testing method, system and computer readable storage medium
EP2618544A1 (en) Ethernet communication system and method based on mmc/sd interface
CN109062834B (en) DMA-based SPI communication method, electronic equipment, storage medium and device
CN113660191A (en) Communication method for bridging MIL-STD-1553 and GJB1188B protocols through FC-AE-1553 protocol
CN111587560A (en) Master-slave bus system and method for operating a bus system
CN109995548B (en) Device management method and system, data transmission method and system and terminal device
CN114629743A (en) Method, device and system for identifying serial port of slave equipment, electronic equipment and storage medium
CN109800202B (en) PCIE (peripheral component interface express) -based data transmission system, method and device
CN111400214A (en) Method for realizing dual-core shared network port, intelligent terminal and storage medium
CN115334041A (en) Method for automatically allocating addresses to communication equipment of master station and slave station, master station, slave station and system
CN113612668B (en) Communication method for bridging three protocols
CN113074595B (en) Data writing method and system of electronic detonator, electronic detonator and initiator
CN104615573A (en) Communication method and device
CN113132468A (en) Communication method, communication device, communication system and storage medium based on ModbusTCP protocol
CN102013918B (en) Method, system and device for transmitting data
CN112799104A (en) Management method, test equipment and test system of test instruction
CN111638905A (en) Version number generation method and device, electronic equipment and readable storage medium
US11979908B2 (en) Method, device, terminal and system for transmitting data
CN112000503B (en) Server fault debugging method and system and remote server

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
TA01 Transfer of patent application right

Effective date of registration: 20221108

Address after: 518000 floor 7, Kangrong Industrial Park, weitangtou Avenue, Shixin residence, Langxin community, Shiyan street, Bao'an District, Shenzhen, Guangdong

Applicant after: SHENZHEN TUOBANG AUTOMATION TECHNOLOGY Co.,Ltd.

Address before: Room 413, block B, Tsinghua University Research Institute, high tech Industrial Park, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN TOPBAND Co.,Ltd.

TA01 Transfer of patent application right