Summary of the invention
In view of the above situation, it is necessary to be directed to the problems of the prior art, providing one kind can be certainly in the reversal connection of 485 communication lines
Dynamic correction and communication bearing calibration, device, readable storage medium storing program for executing and slave at low cost.
A kind of communication bearing calibration is applied in slave, and the slave is connect by 485 communication lines with host, described logical
Believe that bearing calibration includes:
When monitoring a communication data of the host transmission, the performance data in the slave, the performance are obtained
Data are received the data shown after the communication data of the host by the slave;
Judge whether the signal wire of the slave and the host is reversely connected according to the check information of the performance data;
If so, inquire the corresponding amendment data of the performance data in the data mapping tables prestored, and will inquire
Correct practical reception data of the data as the slave, the data mapping tables include multiple reversal connection data and it is each it is described instead
Connect the corresponding amendment data of data.
Further, above-mentioned communication bearing calibration, wherein described according to the check information judgement of the performance data
The step of whether signal wire of slave and the host is reversely connected include:
The performance data in the preset period in the slave are obtained, and verify the performance number in the period
According to whether correct;
If it is not, determining the signal wire reversal connection of the slave and the host.
Further, above-mentioned communication bearing calibration, wherein the whether correct step packet of the verification performance data
It includes:
It is whether correct that the performance data are verified according to CRC check method.
Further, above-mentioned communication bearing calibration, wherein described that the performance number is inquired in the data mapping tables prestored
Include: according to the step of corresponding amendment data
By multiple reversal connection data in the character and the data mapping tables of preset quantity forward in the performance data
Character be successively compared, data are reversely connected with the matched target of determination;
The corresponding amendment data of the target reversal connection data are determined according to the data mapping tables.
Further, above-mentioned communication bearing calibration, wherein before the step of the performance data obtained in the slave
Further include:
Under conditions of the reversal connection of 485 communication lines of the slave and the host, the multiple logical of the host transmission is received
Letter data, and corresponding performance data in the slave are obtained, to obtain multiple reversal connection data;
Mapping relations are established using the communication data as amendment data and the reversal connection data, to generate data mapping
Table, and store the data mapping tables.
Further, above-mentioned communication bearing calibration, wherein the slave is judged according to the check information of the performance data
After the step of whether being reversely connected with the signal wire of the host further include:
When the signal wire for determining the slave and the host is reversely connected, the connection status of the slave is revised as instead
State is connect, and controls corresponding status indicator lamp work on the slave.
The embodiment of the invention also provides a kind of communication means for correctings, are applied in slave, and the slave passes through 485 communications
Line is connect with host, and the communication means for correcting includes:
First obtains module, for obtaining in the slave when monitoring a communication data of the host transmission
Data are showed, the performance data are received the data shown after the communication data of the host by the slave;
Judgment module, for judging the signal wire of the slave and the host according to the check information of the performance data
Whether it is reversely connected;
Enquiry module, for inquiring the corresponding amendment data of the performance data in the data mapping tables prestored, and will
Practical reception data of the amendment data inquired as the slave, the data mapping tables include multiple reversal connection data and every
The corresponding amendment data of a reversal connection data.
Further, above-mentioned communication means for correcting, wherein the judgment module is specifically used for:
The performance data in the preset period in the slave are obtained, and verify the performance number in the period
According to whether correct;
If it is not, determining the signal wire reversal connection of the slave and the host.
Further, above-mentioned communication means for correcting, wherein the whether correct step packet of the verification performance data
It includes:
It is whether correct that the performance data are verified according to CRC check method.
Further, above-mentioned communication means for correcting, wherein the enquiry module is specifically used for:
By multiple reversal connection data in the character and the data mapping tables of preset quantity forward in the performance data
Character be successively compared, data are reversely connected with the matched target of determination;
The corresponding amendment data of the target reversal connection data are determined according to the data mapping tables.
Further, above-mentioned communication means for correcting, further includes:
Second obtains module, under conditions of the reversal connection of 485 communication lines of the slave and the host, described in reception
Multiple communication datas that host is sent, and corresponding performance data in the slave are obtained, to obtain multiple reversal connection data;
Data mapping tables establish module, for reflecting the communication data as amendment data and reversal connection data foundation
Relationship is penetrated, to generate a data mapping tables, and stores the data mapping tables.
Further, above-mentioned communication means for correcting, further includes:
Modified module, for when determine the slave and the host signal wire be reversely connected when, by the company of the slave
Connecing status modifier is reversal connection state, and controls corresponding status indicator lamp work on the slave.
The embodiment of the invention also provides a kind of readable storage medium storing program for executing, are stored thereon with program, described program is by processor
The step of above method is realized when execution.
The embodiment of the invention also provides a kind of slave, including memory, processor and storage are on a memory and can
The step of program run on a processor, the processor realizes the above method when executing described program.
In the embodiment of the present invention, when 485 signal wires of slave and host are reversed, slave passes through in inquiry data mapping tables
Data are corrected to correct the data received from host, to also can guarantee the positive normal open of host and slave in the case where reversal connection
Letter.The present embodiment passes through the correction of 485 communication data of software realization data, and automatic correction procedure is done on slave,
Each slave is subject to the data of host hair and is not necessarily to artificial interference, and do not have to special chip, correction side to correct oneself data
Formula is simple, and at low cost.
Specific embodiment
The embodiment of the present invention is described below in detail, examples of the embodiments are shown in the accompanying drawings, wherein from beginning to end
Same or similar label indicates same or similar element or element with the same or similar functions.Below with reference to attached
The embodiment of figure description is exemplary, and for explaining only the invention, and is not considered as limiting the invention.
Referring to following description and drawings, it will be clear that these and other aspects of the embodiment of the present invention.In these descriptions
In attached drawing, some particular implementations in the embodiment of the present invention are specifically disclosed, to indicate to implement implementation of the invention
Some modes of the principle of example, but it is to be understood that the scope of embodiments of the invention is not limited.On the contrary, of the invention
Embodiment includes all changes, modification and the equivalent fallen within the scope of the spirit and intension of attached claims.
Referring to Fig. 1, this method is applied to any one slave for the communication bearing calibration in first embodiment of the invention
In, which is connect by 485 communication lines with host.The host can be with multiple slaves by 485 communication connections, using host
" poll ", the point-to-point communication mode of slave " response ".The communication bearing calibration includes step S11~S13.
Step S11 obtains the performance data in the slave when monitoring a communication data of the host transmission,
The performance data are received the data shown after the communication data of the host by the slave.
What host sent data is the TXD pin of single-chip microcontroller, that is to say, that shows data on TXD pin.For example,
Data 0x55 is sent, being write as binary system is exactly 0x01010101, successively will embody 1 and 0 with low and high level on TXD pin.
And slave receives data, is single-chip microcontroller pin RXD, that is to say, that show data on RXD pin.Receiving data
In the process, TXD pin is always maintained at high level, and when TXD is high level, RE pin is low level, just improved at
Reception state, then the RO pin (namely connecing the pin of RXD) of 485 chips will react the data that AB is transmitted.
Slave real-time sense bus data obtains slave RXD pin when detecting that host sends communication data to slave
The data of upper performance, i.e. performance data.The data that the performance data and host of slave are sent may be identical, it is also possible to different
's.For example, host sends communication data to any one slave in the case where host connects correct situation with A, B communication line of slave
When, the performance data of communication data and slave that host is sent be it is identical, slave executes accordingly according to the data that receive
Control instruction.And when the connecting line of host and slave is in the case where reversal connection, slave can receive the information of host transmission, but
Be showed on slave be mistake communication data, slave can not execute host transmission instruction.
Step S12, according to the check information of the performance data judge the slave and the host signal wire whether
Reversal connection, if so, thening follow the steps S13.
In data transmission procedure, receive the accuracy of data to improve reciever as far as possible, recipient receive data it
Before need to data carry out error detection, and if only if detection result be it is correct when receive really accept data just now.Detection
There are many modes, common are even-odd check, internet verification and cyclic redundancy check etc..Slave receives the logical of host transmission
When letter data, the performance data in slave are verified, with judge received data whether mistake, therefore, it is determined that host and from
Whether the signal wire of machine is reversely connected.When determining host and slave is reversed, needs the performance data to slave to be corrected, make it
It is consistent with the data that host is sent.When slave and host do not have reversed, then slave normally receives the communication data of host transmission.
Step S13 inquires the corresponding amendment data of the performance data in the data mapping tables prestored, and will inquire
Practical reception data of the amendment data as the slave, the data mapping tables include multiple reversal connection data and each described
It is reversely connected the corresponding amendment data of data.
When host and reversed slave, need to be corrected the received data of slave, when it is implemented, from the number prestored
According to amendment data corresponding to the performance data for inquiring slave in mapping table, and using the amendment data inquired as slave reality
Received data.The data mapping tables are stored in advance in slave, which includes multiple reversal connections under the conditions of reversal connection
The corresponding relationship of data and amendment data.The received data of slave are consistent when the amendment data and normal 485 communications.Slave will be looked into
The amendment data ask execute corresponding order as final reception data, and according to the amendment data, to guarantee host
With the normal communication of slave.
In the present embodiment, when 485 signal wires of slave and host are reversed, slave in inquiry data mapping tables by correcting
Data correct the data received from host, to also can guarantee the normal communication of host and slave in the case where reversal connection.
For the present embodiment by the correction of 485 communication data of software realization data, automatic correction procedure is done on slave, respectively from
Machine is subject to the data of host hair and is not necessarily to artificial interference, and do not have to special chip to correct oneself data, correcting mode letter
It is single and at low cost.
Referring to Fig. 2, for the communication bearing calibration in second embodiment of the invention, including step S21~S27.
Step S21 receives the host and sends under conditions of the reversal connection of 485 communication lines of the slave and the host
Multiple communication datas, and corresponding performance data in the slave are obtained, to obtain multiple reversal connection data.
Step S22 establishes mapping relations for the communication data as amendment data and the reversal connection data, to generate one
Data mapping tables, and store the data mapping tables.
In above-mentioned steps, A, B line of 485 communications of host and slave are reversely connected, start to test.Host sends more to slave
A communication data 0X00-0XFF corresponds to a control instruction to slave, each communication data, and user can need to be implemented according to slave
All instructions, corresponding communication data is set.Slave receives the data that the data after the reversal connection of A, B line are showed as reversal connection number
According to, by the reversal connection data establish with the mapping relations of communication data 0X00-0XFF one by one, generate a data mapping tables, and carry out
Storage.
It should be understood that host can send multiple communication datas to each slave respectively when host connects multiple slaves,
Instruction performed by different slaves is different, and the communication data that host is sent is also different.Each slave is actually received according to connecing
Data and the transmission data of host can establish a data mapping tables.
Step S23 obtains the performance data in the slave when monitoring a communication data of the host transmission.
Slave real-time sense bus data obtains the table in slave when detecting that host sends communication data to slave
Existing data.The data that the performance data and host of slave are sent may be identical, it is also possible to be different.For example, host and from
A, B communication line of machine connect in correct situation, when host sends communication data to any one slave, the communication number of host transmission
Be according to the performance data with slave it is identical, slave executes corresponding control instruction according to the data that receive.And when host and
For the connecting line of slave in the case where reversal connection, slave can receive the information of host transmission, and still, what is showed on slave is
The communication data of mistake, slave can not execute the instruction of host transmission.
Step S24 obtains the performance data in the preset period in the slave, and verifies the institute in the period
State whether performance data are correct data.
Step S25 determines the slave and described when the performance data in the period are not correct data
The signal wire of host is reversely connected.
The communication data that host is sent is generally the character string of continuous number composition, and slave is before the data of receiving host
The communication data that will be sent to host verifies, if the performance data that slave obtains whithin a period of time are after verifying
Mistake, illustrate that 485 communication lines of the slave and host are reversed.
In the present embodiment, verified using CRC (Cyclic Redundancy Check, cyclic redundancy check) method of calibration
Whether the data in slave are correct.CRC check is mainly used to the mistake for detecting or verifying data transmission or be likely to occur after saving
Accidentally.The method of calibration is characterized in that the length of information field and check field can be arbitrarily selected, and therefore, slave can be to a timing
Interior data are continuously verified.Preset time period in above-mentioned steps can be configured according to the actual situation, such as can be set
It is set to 30s, i.e. data in acquisition 30s carry out CRC check.If slave receives data, but data check mistake, and in this way
Certain time (30S), then judgement is that the AB line of 485 communications is reversed.
Step S26 inquires the corresponding amendment data of the performance data in the data mapping tables prestored, and will inquire
Practical reception data of the amendment data as the slave.
The received data of slave are a string of longer character strings in many cases, generally comprise start bit, data bit, effect
Position and stop position.If the character in each character and data mapping tables in the performance data in slave is carried out one by one
Match, if searching same reversal connection data in table, it will increase the operand of slave.And in actual conditions, host
The character of its preceding numerical digit of different two communication data of transmission has shown difference, therefore only needs more former characters
The specific reversal connection data in data mapping tables can be navigated to.Therefore, it in the present embodiment, is inquired in the data mapping tables prestored
The step of performance data in slave corresponding amendment data includes:
By multiple reversal connection data in the character and the data mapping tables of preset quantity forward in the performance data
Character be successively compared, data are reversely connected with the matched target of determination;
The corresponding amendment data of the target reversal connection data are determined according to the data mapping tables.
Wherein, the character of preset quantity can be configured according to the actual situation, such as in the present embodiment, may compare first 3
Character carries out the front three character of each reversal connection data in the front three and data mapping tables of the performance data in slave
Compare, data is reversely connected to find same target, so that it is determined that the corresponding amendment data of the data.
Further, it is further comprised the steps of: later as a kind of enforceable mode above-mentioned steps S25
The connection status of the slave is revised as reversal connection state by step S27, and controls corresponding state on the slave
Indicator light work.
In above-mentioned steps, when the communication line for determining host and slave is reversely connected, the connection status of slave is revised as instead
State is connect, when it is implemented, can be operated by marker bit, is just being connect status indication " 1 ", is reversely connected status indication " 0 ".And according to
Connection status controls corresponding status indicator lamp work, in order to which staff understands the connection status of the slave.
It is illustrated below with a specific embodiment:
In heat pump project, mainboard passes through 485 bus communications as slave, mainboard and display board as host, display board.
When mainboard and display board AB are first reversely connected, mainboard sends multiple 0X00-0XFF data to display board, and display board is received and recorded aobvious
Show the data that plate is showed, to establish an one-to-one mapping table TAB.
In actual engineering, the display board moment monitors 485 bus datas.Display board obtains the data that mainboard is sent, and goes forward side by side
Row verification;When the display data for verifying display board in 30S are the data of mistake, it is determined that A, B line are reversely connected.At this point,
Display board enables correction program, is gone to search corresponding amendment data in data mapping tables with the data received, to obtain just
True data.
Referring to Fig. 3, being applied in slave for the communication means for correcting in third embodiment of the invention, the slave is logical
It crosses 485 communication lines to connect with host, which includes:
First obtains module 100, for obtaining in the slave when monitoring a communication data of the host transmission
Performance data, the performance data receive the data shown after the communication data of the host by the slave;
Judgment module 200, for judging the letter of the slave and the host according to the check information of the performance data
Whether number line is reversely connected;
Enquiry module 300, for inquiring the corresponding amendment data of the performance data in the data mapping tables prestored, and
Using the amendment data inquired as the practical reception data of the slave, the data mapping tables include multiple reversal connection data and
The corresponding amendment data of each reversal connection data.
Further, above-mentioned communication means for correcting, wherein the judgment module 200 is specifically used for:
The performance data in the preset period in the slave are obtained, and verify the performance number in the period
According to whether correct;
If it is not, determining the signal wire reversal connection of the slave and the host.
Further, above-mentioned communication means for correcting, wherein the whether correct step packet of the verification performance data
It includes:
It is whether correct that the performance data are verified according to CRC check method.
Further, above-mentioned communication means for correcting, wherein the enquiry module 300 is specifically used for:
By multiple reversal connection data in the character and the data mapping tables of preset quantity forward in the performance data
Character be successively compared, data are reversely connected with the matched target of determination;
The corresponding amendment data of the target reversal connection data are determined according to the data mapping tables.
Further, above-mentioned communication means for correcting, further includes:
Second obtains module 400, for receiving under conditions of the reversal connection of 485 communication lines of the slave and the host
Multiple communication datas that the host is sent, and corresponding performance data in the slave are obtained, to obtain multiple reversal connection data;
Data mapping tables establish module, for reflecting the communication data as amendment data and reversal connection data foundation
Relationship is penetrated, to generate a data mapping tables, and stores the data mapping tables.
Further, above-mentioned communication means for correcting, further includes:
Modified module 500, for when determine the slave and the host signal wire be reversely connected when, by the slave
Connection status is revised as reversal connection state, and controls corresponding status indicator lamp work on the slave.
The technical effect and preceding method of means for correcting, realization principle and generation are communicated provided by the embodiment of the present invention
Embodiment is identical, and to briefly describe, Installation practice part does not refer to place, can refer in corresponding in preceding method embodiment
Hold.
The present invention also proposes a kind of readable storage medium storing program for executing, is stored thereon with computer program, which is executed by processor
Shi Shixian above-mentioned communication bearing calibration.
This is the embodiment of the invention also provides a kind of slave, including memory, processor and storage are on a memory simultaneously
The step of computer program that can be run on a processor, the processor realizes the above method when executing described program.
Expression or logic and/or step described otherwise above herein in flow charts, for example, being considered use
In the order list for the executable instruction for realizing logic function, may be embodied in any computer-readable medium, for
Instruction execution system, device or equipment (such as computer based system, including the system of processor or other can be held from instruction
The instruction fetch of row system, device or equipment and the system executed instruction) it uses, or combine these instruction execution systems, device or set
It is standby and use.For the purpose of this specification, " computer-readable medium ", which can be, any may include, stores, communicates, propagates or pass
Defeated program is for instruction execution system, device or equipment or the dress used in conjunction with these instruction execution systems, device or equipment
It sets.
The more specific example (non-exhaustive list) of computer-readable medium include the following: there are one or more wirings
Electrical connection section (electronic device), portable computer diskette box (magnetic device), random access memory (RAM), read-only memory
(ROM), erasable edit read-only storage (EPROM or flash memory), fiber device and portable optic disk is read-only deposits
Reservoir (CDROM).In addition, computer-readable medium can even is that the paper that can print described program on it or other are suitable
Medium, because can then be edited, be interpreted or when necessary with it for example by carrying out optical scanner to paper or other media
His suitable method is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each section of the invention can be realized with hardware, software, firmware or their combination.Above-mentioned
In embodiment, software that multiple steps or method can be executed in memory and by suitable instruction execution system with storage
Or firmware is realized.It, and in another embodiment, can be under well known in the art for example, if realized with hardware
Any one of column technology or their combination are realized: having a logic gates for realizing logic function to data-signal
Discrete logic, with suitable combinational logic gate circuit specific integrated circuit, programmable gate array (PGA), scene
Programmable gate array (FPGA) etc..
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show
The description of example " or " some examples " etc. means specific features, structure, material or spy described in conjunction with this embodiment or example
Point is included at least one embodiment or example of the invention.In the present specification, schematic expression of the above terms are not
Centainly refer to identical embodiment or example.Moreover, particular features, structures, materials, or characteristics described can be any
One or more embodiment or examples in can be combined in any suitable manner.
The embodiments described above only express several embodiments of the present invention, and the description thereof is more specific and detailed, but simultaneously
Limitations on the scope of the patent of the present invention therefore cannot be interpreted as.It should be pointed out that for those of ordinary skill in the art
For, without departing from the inventive concept of the premise, various modifications and improvements can be made, these belong to guarantor of the invention
Protect range.Therefore, the scope of protection of the patent of the invention shall be subject to the appended claims.