CN103001734A - Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling - Google Patents
Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling Download PDFInfo
- Publication number
- CN103001734A CN103001734A CN2012103943982A CN201210394398A CN103001734A CN 103001734 A CN103001734 A CN 103001734A CN 2012103943982 A CN2012103943982 A CN 2012103943982A CN 201210394398 A CN201210394398 A CN 201210394398A CN 103001734 A CN103001734 A CN 103001734A
- Authority
- CN
- China
- Prior art keywords
- data
- asynchronous serial
- serial communication
- bit
- bits
- 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.)
- Granted
Links
Images
Abstract
The invention belongs to the technical field of digital communication, and particularly relates to a method for automatically detecting asynchronous serial port communication protocol on the basis of level sampling. The method includes firstly sampling level signals of asynchronous serial port communication, and detecting asynchronous serial port communication Baud rate according to the relation of the asynchronous serial port communication Baud rate and average time span of a single low level of the sampled signals; secondly, determining data frame bit digits and data frame positions of target signals which are the detected level signals by Baud rate by means of stop bit correlation matching algorithm; thirdly, analyzing in-frame data and inter-frame bit distance to determine data bit digits, checking manners and stop bit digits of the target signals; and finally determining a data coding manner of the target signals by Bayes policy method on the basis of the minimum error rate. The method can be applicable to communication protocol detection of communication and data transmission equipment utilizing the asynchronous serial port communication protocol.
Description
Technical field
The invention belongs to digital communication technology field, a kind of automatic detection method of the asynchronous serial communication agreement based on level sampling specifically can be used for various application asynchronous serial communication agreements and communicates communication protocol detection with the equipment of transfer of data.
Technical background
The asynchronous serial communication agreement is a kind of take the agreement of Frame as the communication unit data information, and agreement has been stipulated in speed (being baud rate) that Frame is transmitted, the Frame and the load mode of interframe structure and data, as shown in Figure 1.The figure place of the binary data that transmits in the unit interval during baud rate represents to communicate by letter, unit is " bps (bps) ", one bit is called a bit (bit), according to the regulation of asynchronous serial communication agreement, the legal value set of communication baud rate is { 50,100,120,150,300,600,1200,1800,2400,4800,7200,9600,14400,19200,28800,38400,57600,115200,128000,256000 }.The asynchronous serial communication agreement becomes several Frames to the Data Segmentation that needs send, and the structure of Frame is specified by concrete asynchronous serial communication agreement.A Frame begins with a bit low level, as the start bit of frame.The start bit back is data bit, and according to the regulation of asynchronous serial communication agreement, all legal values of data bit number of bits are: one of 5 bits, 6 bits, 7 bits, 8 bits.It is check digit after the data bit, regulation according to the asynchronous serial communication agreement, if check digit is arranged, check digit accounts for 1 bit, and all legal verification modes are: one of odd (ODD), even parity check (EVEN), high verification (MARK), low verification (SPACE) four; If there is not verification, then do not establish check digit.Position of rest (if not having and then last bit data position of check digit position of rest) after the check digit, regulation according to the asynchronous serial communication agreement, position of rest is high level, and all legal values of its number of bits are: 1 bit, 1.5 bits, 2 bit thrins.Position of rest is the ending of frame inner structure, and any number of bits (comprising 0 bit) spare bits can be arranged between frame and the frame, and spare bits is high level, is the start bit of next frame after the spare bits.According to the regulation of asynchronous serial communication agreement, the load mode of communication data can transmit or the transmission of 16 system numbers for ASC II code.
Asynchronous serial communication needs to appoint mutually the protocol parameter of communication use before communication, be exactly specifically: baud rate, data bit number of bits, verification mode, position of rest number of bits, data encoding mode.In the military import equipment that is equipped with serial ports take some under the occasion of representative, usually because the reason such as maintain secrecy can't equipment supporting specification, thereby do not know the asynchronous serial communication agreement used on the equipment.Chinese invention patent " based on the baud rate adaptation method of single-chip microcomputer input capture function " (application number: CN201110221090.3) proposed a kind ofly with machine the asynchronous serial communication level to be sampled, calculated the method for the baud rate of communication by seeking the minimum level of sampled point quantity.But there is not the ready-made automatic detection method for baud rate, data bit number of bits, verification mode, position of rest number of bits, this entire set of parameters of data encoding mode.
In sum, design a kind of detecting algorithm that can automatically finish asynchronous serial communication agreement baud rate, data bit number of bits, verification mode, position of rest number of bits, data encoding mode, certain innovative value is not only arranged, obvious realistic meaning is also arranged.
Summary of the invention
Deficiency for background technology, the present invention proposes and a kind of signal is carried out level sampling, by the new method of the single low level average length of time Auto-Sensing communication baud rate of calculating sampling signal, and the automatic detection method of data bit number of bits, verification mode, position of rest number of bits, data encoding mode has been proposed on the basis that baud rate is detected.
Technical scheme of the present invention is: a kind of asynchronous serial communication agreement automatic detection method based on level sampling is characterized in that: comprise the steps:
Single low level average length of time calculates in step 2, the sampled data;
The mathematical relationship of step 3, asynchronous serial communication baud rate and single low level average length of time is derived;
Step 5, in conjunction with the asynchronous serial communication agreement, estimate that by the asynchronous serial communication baud rate span determines the asynchronous serial communication baud rate;
Step 6, based on asynchronous serial communication protocol data frame number of bits and the Frame position detecting of position of rest relevant matches;
Step 7, asynchronous serial communication protocol data verification mode and the detecting of data bit number of bits;
Step 9, based on the asynchronous serial communication protocol data coded system detecting of minimal error rate Bayes decision-making.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the concrete grammar that the level signal of described step 1 asynchronous serial communication is sampled is: the sampled result of high level is " 1 ", low level sampled result is " 0 ", and sample frequency is the integral multiple of the maximum baud rate of the integral multiple of the maximum baud rate that need to be detected or asynchronous serial communication agreement defined.Its beneficial effect is: the communication data of effectively sampling, and for example: need the detecting baud rate less than or equal to the baud rate of the asynchronous serial port signal of 38400bps, sample frequency is got 4 times of 38400bps, is 153.6KHz; Sample frequency also can directly be taken as the integral multiple of the maximum baud rate of asynchronous serial communication agreement defined, and for example: sample frequency is got 2 times of 256000bps, is 512KHz.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the single low level average length of time computational methods of described step 2 are: the sum of low level sum and low level sampled point in the statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, again with low level total time length obtain single low level average length of time divided by low level sum:
In the formula
Represent single low level average length of time, n represents the low level total number of sample points, and m represents the low level sum,
The expression sample frequency.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the relationship of described step 3 asynchronous serial communication baud rate and single low level average length of time is:
In the formula
Expression asynchronous serial communication baud rate,
Contained frame number in the expression sampled data,
The sampling error rate that represents every frame.Its beneficial effect is: the inevitable actual conditions of sample-based error, through mathematical analysis, derive under asynchronous serial communication frame structure framework the mathematical relationship of single low level average length of time and asynchronous serial communication baud rate.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling is characterized in that: described step 4 asynchronous serial communication baud rate is estimated being calculated as of span: the asynchronous serial communication baud rate that the single low level average length of time value of the sampled data of utilizing statistical computation to obtain and mathematical derivation go out and the relational expression of single low level average length of time calculate the estimation span of asynchronous serial communication baud rate:
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the concrete steps of described step 5 are: according to the regulation of asynchronous serial communication agreement, the legal value set of communication baud rate is for { 50,100,120,150,300,600,1200,1800,2400,4800,7200,9600,14400,19200,28800,38400,57600,115200,128000,256000 }, in the set of the legal value of baud rate, search falls into the estimation span of baud rate or is the baud rate of asynchronous serial communication with the immediate baud rate value of the estimation span of baud rate.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the specific implementation of described step 6 is: the level signal of having been detected take baud rate is as the target signal, virtual 5 matching stencils, the feature of described masterplate comprises following five aspects:
Feature 1: the masterplate baud rate equals the baud rate of target signal;
Feature 2: first of masterplate is 1 bit low level start bit;
Feature 3: last position of masterplate is 1 bit high level position of rest;
The distance of feature 4:5 masterplate start bit and position of rest is respectively 5,6,7,8,9 bits;
Feature 5: the bit between masterplate start bit and the position of rest is without any the level feature;
The coupling step of described position of rest relevant matches is:
Step a: overlap with a low level that in the start bit of template and the target signal might be a start of frame bits and to aim at, carry out same exclusive disjunction, the record operation values with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position;
Step b: first low level is aimed at after seeking the masterplate position of rest;
Step c: repeating step a, step b is until all level of traversal target signal are calculated and finished relevant matches one time;
Steps d: calculate the not correlation of homogeneous coupling of 5 masterplates with relevance function, relevance function is defined as:
In the formula
Be the level value of the target signal bit position of mating,
Be the level value of template position of rest, N is total bit number of participation coupling,
Expression accords with exclusive disjunction, and s is the number of bits of masterplate frame,
Be the coupling sequence number;
Step e: with the masterplate number of bits of that time coupling of relevance function value maximum as frame Nepit figure place, with each start bit aligned position of that time coupling of relevance function value maximum original position as each Frame.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the specific implementation of described step 7 is: by position and the length of step 1 established data frame, extract every intraframe data, intraframe data is advanced 4 kinds of " particular kind of relationship " statistics in school;
The bit number of 1: one interior high level of frame of particular kind of relationship is even number, and the even parity check statistic adds 1;
The bit number of 2: one interior high level of frame of particular kind of relationship is odd number, and the odd statistic adds 1;
3: one interior last bits of frame of particular kind of relationship are high level, and high verification statistic adds 1;
4: one interior last bits of frame of particular kind of relationship are low level, and low verification statistic adds 1;
Ratio according to statistic and frame sum compares with " verification statistics threshold value ", the ratio that 4 kinds of any statistics of statistic account for the data totalframes has exceeded " verification statistics threshold value ", just judge that verification mode corresponding to the sort of statistic is the verification mode of target signal data, otherwise judge target signal data no parity check, determine that according to experiment " verification statistics threshold value " preferably is set as 95%
In the situation of no parity check, the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 2, is having in the situation of verification, and the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 3.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the specific implementation of described step 8 is: be to determine the position of every frame data in the target signal by step 6, step 7, bit distance between statistics frame and the frame searches out the shortest bit distance from the interframe bit distance statistic that is not less than totalframes 10% quantity
:
(IV) other situations think that then the position of rest number of bits is 1 bit.
Aforesaid asynchronous serial communication agreement automatic detection method based on level sampling, it is characterized in that: the specific implementation of described step 9 is: pass through step 6, the determined Frame number of bits of step 7 and data check mode, take out the intraframe data that does not contain check digit, intraframe data total amount and the legal data volume of ASC II coded system decoding value that statistics is taken out, using the Bayes decision-making calculated data coded system based on minimal error rate is the posterior probability of ASC II code, whether the posterior probability of ASC II code judges that greater than " semantic decision gate limit value " coded system of asynchronous serial communication data is ASC II code or 16 system numbers in the data encoding mode, determine that according to experiment " semantic decision gate limit value " preferably is set as 95%, based on the Bayes decision-making computational methods of minimal error rate be:
In the formula
The expression data are ASC II code;
The expression data are 16 system numbers;
Be data error rate;
It is the probability that data can be interpreted as ASC II code;
Be event:
In the individual data, have
Individual data can be translated into ASC II code;
Be respectively
Event under the condition
Test probability before occuring,
The posterior probability of ASC II code for the data encoding mode.
Innovative point of the present invention: the present invention proposes from the starting with of asynchronous serial communication low level average length of time, by the mathematical relationship of asynchronous serial communication baud rate and single low level average length of time, the new method of detecting asynchronous serial communication baud rate; Proposed the virtual matching stencil of a kind of usefulness the target signal has been carried out relevant matches, the new method of specified data frame number of bits and Frame position; And the method for detecting of asynchronous serial communication protocol data position number of bits, verification mode, position of rest number of bits, data encoding mode proposed on this basis.
Description of drawings
Fig. 1 is asynchronous serial communication frame structure schematic diagram;
Fig. 2 is method flow diagram of the invention process;
Fig. 3 is the method flow diagram that baud rate detecting of the present invention is implemented;
Fig. 4 schematic diagram that to be the present invention take out the spare bits of the start bit of asynchronous serial communication signal level data frame and position of rest and interframe in the level;
Fig. 5 is the schematic diagram that the present invention calculates single low level different bit length probability;
To be the present invention put back to schematic diagram in the random data to the spare bits of the start bit of each frame of asynchronous serial communication frame that takes out and position of rest and interframe to Fig. 6;
Fig. 7 is virtual matching stencil schematic diagram of the present invention;
Fig. 8 is the position of rest relevant matches schematic diagram that the present invention proposes;
Fig. 9 is asynchronous serial communication protocol data verification mode of the present invention and data bit number of bits detecting flow chart;
Figure 10 the present invention is based on frame pitch from the flow chart of the asynchronous serial communication agreement position of rest number of bits detecting that detects;
Figure 11 is the flow chart that the present invention is based on the asynchronous serial communication protocol data coded system detecting of minimal error rate Bayes decision-making;
Figure 12 is an embodiment figure of the present invention;
Embodiment:
The invention will be further described below in conjunction with accompanying drawing.
With reference to Fig. 2, it is implementing procedure figure of the present invention.At first the baud rate of signal is detected, on the basis that communication baud rate has been detected, virtual a series of matching stencil, with these masterplates the Different matching point of target signal is carried out the position of rest relevant matches, correlation with the each coupling of relevance function tolerance, with that time matching stencil number of bits of relevance function value maximum as frame Nepit figure place, with each start bit aligned position of that time coupling of relevance function value maximum original position as each Frame.According to position and the number of bits of Frame, extract every intraframe data again, carry out the check of verification mode.Extract simultaneously frame pitch from, with the shortest interframe distance estimations position of rest number of bits.Take out at last the intraframe data that does not contain check digit, employing judges that with the posteriority decision probability of ASC II coded system decoding the coded system of asynchronous serial communication data is ASC II code or 16 system numbers according to intraframe data based on the Bayes decision-making technique of minimal error rate.
With reference to Fig. 3, it is baud rate detecting implementation method flow chart of the present invention.At first the level signal of asynchronous serial communication is sampled, the sampled result of high level is " 1 ", low level sampled result is " 0 ", sample frequency can be taken as the integral multiple of the maximum baud rate that need to be detected, for example: need the detecting baud rate less than or equal to the baud rate of the asynchronous serial port signal of 38400bps, sample frequency is got 4 times of 38400bps, is 153.6KHz; Sample frequency also can directly be taken as the integral multiple of the maximum baud rate of asynchronous serial communication agreement defined, and for example: sample frequency is got 2 times of 256000bps, is 512KHz.Then the sum of low level sum and low level sampled point in the statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, again with low level total time length obtain single low level average length of time divided by low level sum.Calculate again the estimation span of asynchronous serial communication baud rate in conjunction with the relationship of the asynchronous serial communication baud rate of deriving and single low level average length of time.Search in the legal value set of the communication baud rate of the regulation of asynchronous serial communication agreement with the estimation span of the communication baud rate that calculates at last, get the estimation span that falls into baud rate or be defined as the communication baud rate of the asynchronous serial port level of sampling with the legal value of the immediate baud rate of estimation span of baud rate.
With reference to Fig. 4 to Fig. 6, they have showed the derivation of the mathematical relationship of asynchronous serial communication baud rate and single low level average length of time.
With reference to Fig. 4, suppose the start bit of each frame of asynchronous serial communication signal level data frame and the spare bits of position of rest and interframe are all taken out in level, can think that remaining data are random data of communications.
With reference to Fig. 5, it has been showed under errorless code-bar spare, the derivation thinking of single low level average specific bit length in the random data.Because each bit of random data is separate, the probability that low level is high level in next bit saltus step is 1/2.Single low level bit length is
The probability of bit
For:
Being provided with one section comprises
The level signal of individual Frame.After taking out the spare bits of the start bit of each frame and position of rest and interframe, the low level number is m in the level signal, so the total bit length of low level is estimated as 2m, the probability of high-low level equates in a frame random data signals, so the total bit length of level is estimated as 4m in the frame.Because the bit length of a frame is 5 ~ 9 bits in the serial ports frame format, then can derive
With the pass of m be:
With reference to Fig. 6, the start bit of each frame of asynchronous serial communication frame that takes out and the spare bits of position of rest and interframe to be put back in the random data, the level of putting into the position has 4 kinds of possibilities, in Fig. 6: 1. high level trailing edge, 2. high level, 3. low level rising edge, 4. low level.Because data are at random, 4 kinds may equiprobability.Only be placed on and 1. locate so that the low level quantity of whole data sequence is constant, the low level quantity that is placed on its excess-three position data sequence increases 1.And every execution is once put into operation low level total bit length and is increased equal 1.After then putting into the spare bits of the start bit of each frame and position of rest and interframe, the total bit length of low level is estimated as:
, the low level number is estimated as:
Consider error code, the frame sampling error rate of establishing data is again
Error code occurs in the high-low level with equiprobability, so error code does not affect the total bit length of low level.No matter error code occurs in high level makes the high level at error code place be sampled into low level, still occurs in low level and makes the low level at error code place be sampled into high level, all causes the low level number to increase 1.Consider that the total bit length of low level behind the error code is estimated as:
, the low level number is estimated as:
Bit length has just obtained time span divided by baud rate, exists the single low level time length of sampled data of error code to be contemplated to be:
The single low level time length of sampled data can by sampled data is added up, obtain by following formula:
N represents the low level total number of sample points in the formula, and m represents the low level sum,
The expression sample frequency.
Can be derived the estimation span of asynchronous serial communication baud rate by above three formulas:
Because the error rate
Much smaller than 1, calculate when estimating span and can ignore
, directly be written as:
The estimation span of above-mentioned baud rate interval smaller, and the legal value set of baud rate is for { 50,100,120,150,300,600,1200,1800,2400,4800,7200,9600,14400,19200,28800,38400,57600,115200,128000,256000 }, the difference value of adjacent baud rate is very large in the legal value set, in the legal value set of the communication baud rate of the regulation of asynchronous serial communication agreement, search for, get the estimation span that falls into baud rate or be defined as the communication baud rate of the asynchronous serial port level of sampling with the legal value of the immediate baud rate of estimation span of baud rate.
With reference to Fig. 7, it is virtual matching stencil schematic diagram of the present invention, altogether can virtual 5 templates, and the feature of these matching stencils is:
1.. the masterplate baud rate equals the baud rate of target signal;
2.. first of masterplate is 1 bit low level start bit;
3.. last position of masterplate is 1 bit high level position of rest;
5.. the bit between masterplate start bit and the position of rest is without any the level feature;
With reference to Fig. 8, it is the position of rest relevant matches schematic diagram that the present invention proposes.The implementation step of position of rest relevant matches is:
Step 1: choose the matching template of the number of bits s=5 between start bit and position of rest, first low level bit of alignment targets signal.Record simultaneously the number m of the low level bit that is covered by matching template s position bit in the target signal, each capped low level all will as the initial alignment point in subsequent step, be carried out relevant matches one time;
Step 2: carry out same exclusive disjunction with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position, the record operation result;
Step 3: the follow-up level of scanning target signal to low level occurs, with first low level bit of start bit alignment targets signal of masterplate, repeating step 2, until all level of traversal target signal are calculated and finished relevant matches one time;
Step 4: mate correlation for the first time with relevance function calculating
Step 5: respectively take m low level bit being covered by matching stencil in mating for the first time as the initial alignment point, repeating step 2-step 4 obtains other correlation of mating for m time
Step 6: if the number of bits s between the start bit of matching stencil and position of rest<9, then s increases 1, repeating step 1-step 5;
Step 7: the maximum of selecting all coupling correlations
, the r value then as frame Nepit figure place, is mated the matching stencil that by length is r v low level being covered for the first time as the start bit of the first frame data of target signal,
Each start bit aligned position of corresponding that time coupling is as the start bit position of each Frame of target signal.
With reference to Fig. 9, it is asynchronous serial communication protocol data verification mode of the present invention and data bit number of bits detecting flow chart.Extract every intraframe data, the frame number of intraframe data satisfied " particular kind of relationship " is added up, compare according to the ratio of statistic and frame sum and " the verification statistics threshold value " of setting.The ratio that 4 kinds of any statistics of statistic account for the data totalframes has exceeded " verification statistics threshold value ", just judges that verification mode corresponding to the sort of statistic is the verification mode of target signal data, otherwise judges target signal data no parity check.Determine that according to experiment " verification statistics threshold value " is set as 95%, the statistics that described " particular kind of relationship " carried out comprises:
The bit number of high level is even number in (I) frame, and the even parity check statistic adds 1;
The bit number of high level is odd number in (II) frame, and the odd statistic adds 1;
Last bit is high level in (III) frame, and high verification statistic adds 1;
Last bit is low level in (IV) frame, and low verification statistic adds 1;
In the situation of judging no parity check, the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 2, is being determined with in the situation of verification, and the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 3.
With reference to Figure 10, it is to the present invention is based on frame pitch from the flow chart of the asynchronous serial communication agreement position of rest number of bits detecting that detects.At first the bit distance information between every frame is extracted, from the interframe bit distance statistic that is not less than totalframes 10% quantity, search out the shortest bit distance again
Judge the position of rest number of bits:
If there is other situations, illustrate between the most of Frames of target signal always to have spare bits that think that position of rest is 1 bit this moment.Because position of rest is connected with spare bits and the two is high level in asynchronous serial communication, so surpass the position of rest and spare bits equivalence of 1 bit, think that position of rest is 1 bit, does not affect normally carrying out of asynchronous serial communication.
With reference to Figure 11, it is the flow chart that the present invention is based on the asynchronous serial communication protocol data coded system detecting of minimal error rate Bayes decision-making.Asynchronous serial communication intraframe data position number of bits must just can be carried out the transmission of ASC II code more than or equal to 7, and the ASC II code of asynchronous serial communication transmission is character visible, and namely No. 32 in the ASC II code table are to 127 sign characters.If a data value is not between [32,127], then these data can not be interpreted as ASC II code.If asynchronous serial communication intraframe data position number of bits is 7 or 8, then needs to carry out the data encoding mode and judge.At first extract the intraframe data that does not contain check digit, statistics total quantity and the data bulk that can be interpreted as ASC II code.Then use the posterior probability of calculating the coded system ASC II code of all data based on the Bayes decision-making technique of minimal error rate.This posterior probability judges then that greater than " semantic decision gate limit value " coded system of asynchronous serial communication data is ASC II codes, otherwise the decision data coded system is 16 system numbers.Determine that according to experiment " semantic decision gate limit value " is set as 95%, based on the Bayes decision-making computational methods of minimal error rate be:
In the formula
The expression data are ASC II code;
The expression data are 16 system numbers;
Be data error rate;
It is the probability that data can be interpreted as ASC II code;
Be event:
In the individual data, have
Individual data can be translated into ASC II code;
Be respectively
Event under the condition
Test probability before occuring,
The posterior probability of ASC II code for the data encoding mode.
With reference to Figure 12, it is an embodiment figure of the present invention.The asynchronous serial communication agreement automatic detection method based on level sampling that the present invention is proposed is compiled into computer program, input a string asynchronous serial port signal from computer volume com interface, the communication protocol of this signal is: baud rate: 9600bps, data bit number of bits: 7, check digit: nothing, the position of rest number of bits: 2, data encoding mode: ASC II code.Fig. 8 has shown agreement detecting result and has partly detected process data.Need to prove, shown in " data word length " hurdle among the figure that the matching stencil of different frame Nepit figure place carries out the maximum correlation functional value of relevant matches to the target signal, wherein " 7 " are identical with the maximum of the relevance function of the matching stencil of " 8 " frame Nepit figure place, reason is that the position of rest number of bits of target signal is 2, two kinds of the first bit and second bits that each match point of matching stencil just in time is target signal position of rest, algorithm judges that based on the randomness of intraframe data frame Nepit figure place is 7.
Below by reference to the accompanying drawings the specific embodiment of the present invention is described; but these explanations can not be understood to limit scope of the present invention; protection scope of the present invention is limited by the claims of enclosing, and any change of carrying out on claim of the present invention basis and polishing all belong to protection scope of the present invention.
Claims (10)
1. the asynchronous serial communication agreement automatic detection method based on level sampling is characterized in that: comprise the steps:
Step 1, the sampling of asynchronous serial communication level signal;
Single low level average length of time calculates in step 2, the sampled data;
The mathematical relationship of step 3, asynchronous serial communication baud rate and single low level average length of time is derived;
Step 4, asynchronous serial communication baud rate are estimated span calculating;
Step 5, in conjunction with the asynchronous serial communication agreement, estimate that by the asynchronous serial communication baud rate span determines the asynchronous serial communication baud rate;
Step 6, based on asynchronous serial communication protocol data frame number of bits and the Frame position detecting of position of rest relevant matches;
Step 7, asynchronous serial communication protocol data verification mode and the detecting of data bit number of bits;
Step 8, based on frame pitch from the asynchronous serial communication agreement position of rest number of bits detecting that detects;
Step 9, based on the asynchronous serial communication protocol data coded system detecting of minimal error rate Bayes decision-making.
2. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the concrete grammar that the level signal of described step 1 asynchronous serial communication is sampled is: the sampled result of high level is " 1 ", low level sampled result is " 0 ", and sample frequency is the integral multiple of the maximum baud rate of the integral multiple of the maximum baud rate that need to be detected or asynchronous serial communication agreement defined.
3. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the single low level average length of time computational methods of described step 2 are: the sum of low level sum and low level sampled point in the statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, again with low level total time length obtain single low level average length of time divided by low level sum:
4. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the relationship of described step 3 asynchronous serial communication baud rate and single low level average length of time is:
5. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1 is characterized in that: described step 4 asynchronous serial communication baud rate is estimated being calculated as of span: the asynchronous serial communication baud rate that the single low level average length of time value of the sampled data of utilizing statistical computation to obtain and mathematical derivation go out and the relational expression of single low level average length of time calculate the estimation span of asynchronous serial communication baud rate:
6. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the concrete steps of described step 5 are: according to the regulation of asynchronous serial communication agreement, the legal value set of communication baud rate is for { 50,100,120,150,300,600,1200,1800,2400,4800,7200,9600,14400,19200,28800,38400,57600,115200,128000,256000 }, in the set of the legal value of baud rate, search falls into the estimation span of baud rate or is the baud rate of asynchronous serial communication with the immediate baud rate value of the estimation span of baud rate.
7. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the specific implementation of described step 6 is: the level signal of having been detected take baud rate is as the target signal, virtual 5 matching stencils, the feature of described masterplate comprises following five aspects:
Feature 1: the masterplate baud rate equals the baud rate of target signal;
Feature 2: first of masterplate is 1 bit low level start bit;
Feature 3: last position of masterplate is 1 bit high level position of rest;
The distance of feature 4:5 masterplate start bit and position of rest is respectively 5,6,7,8,9 bits;
Feature 5: the bit between masterplate start bit and the position of rest is without any the level feature;
The coupling step of described position of rest relevant matches is:
Step a: overlap with a low level that in the start bit of template and the target signal might be a start of frame bits and to aim at, carry out same exclusive disjunction, the record operation values with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position;
Step b: first low level is aimed at after seeking the masterplate position of rest;
Step c: repeating step a, step b is until all level of traversal target signal are calculated and finished relevant matches one time;
Steps d: calculate the not correlation of homogeneous coupling of 5 masterplates with relevance function, relevance function is defined as:
In the formula
Be the level value of the target signal bit position of mating,
Be the level value of template position of rest, N is total bit number of participation coupling,
Expression accords with exclusive disjunction, and s is the number of bits of masterplate frame,
Be the coupling sequence number;
Step e: with the masterplate number of bits of that time coupling of relevance function value maximum as frame Nepit figure place, with each start bit aligned position of that time coupling of relevance function value maximum original position as each Frame.
8. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the specific implementation of described step 7 is: by position and the length of step 1 established data frame, extract every intraframe data, intraframe data is advanced 4 kinds of " particular kind of relationship " statistics in school;
The bit number of 1: one interior high level of frame of particular kind of relationship is even number, and the even parity check statistic adds 1;
The bit number of 2: one interior high level of frame of particular kind of relationship is odd number, and the odd statistic adds 1;
3: one interior last bits of frame of particular kind of relationship are high level, and high verification statistic adds 1;
4: one interior last bits of frame of particular kind of relationship are low level, and low verification statistic adds 1;
Ratio according to statistic and frame sum compares with " verification statistics threshold value ", the ratio that 4 kinds of any statistics of statistic account for the data totalframes has exceeded " verification statistics threshold value ", just judge that verification mode corresponding to the sort of statistic is the verification mode of target signal data, otherwise judge target signal data no parity check; Determine that according to experiment " verification statistics threshold value " is set as 95%,
In the situation of no parity check, the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 2, is having in the situation of verification, and the data bit number of bits equals the determined Frame number of bits of step 6 and subtracts 3.
9. the asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the specific implementation of described step 8 is: be to determine the position of every frame data in the target signal by step 6, step 7, bit distance between statistics frame and the frame searches out the shortest bit distance from the interframe bit distance statistic that is not less than totalframes 10% quantity
:
(IV) other situations think that then the position of rest number of bits is 1 bit.
10. described asynchronous serial communication agreement automatic detection method based on level sampling as claimed in claim 1, it is characterized in that: the specific implementation of described step 9 is: pass through step 6, the determined Frame number of bits of step 7 and data check mode, take out the intraframe data that does not contain check digit, intraframe data total amount and the legal data volume of ASC II coded system decoding value that statistics is taken out, using the Bayes decision-making calculated data coded system based on minimal error rate is the posterior probability of ASC II code, whether the posterior probability of ASC II code judges that greater than " semantic decision gate limit value " coded system of asynchronous serial communication data is ASC II code or 16 system numbers in the data encoding mode, determine that according to experiment " semantic decision gate limit value " preferably is set as 95%, based on the Bayes decision-making computational methods of minimal error rate be:
In the formula
The expression data are ASC II code;
The expression data are 16 system numbers;
Be data error rate;
It is the probability that data can be interpreted as ASC II code;
Be event:
In the individual data, have
Individual data can be translated into ASC II code;
Be respectively
Event under the condition
Test probability before occuring,
The posterior probability of ASC II code for the data encoding mode.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210394398.2A CN103001734B (en) | 2012-10-17 | 2012-10-17 | Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210394398.2A CN103001734B (en) | 2012-10-17 | 2012-10-17 | Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103001734A true CN103001734A (en) | 2013-03-27 |
CN103001734B CN103001734B (en) | 2015-05-06 |
Family
ID=47929907
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210394398.2A Expired - Fee Related CN103001734B (en) | 2012-10-17 | 2012-10-17 | Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103001734B (en) |
Cited By (16)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103389960A (en) * | 2013-07-26 | 2013-11-13 | 山东康威通信技术股份有限公司 | Method and device for self-adapting of Baud rate in field of power monitoring |
CN103618588A (en) * | 2013-11-26 | 2014-03-05 | 中国科学院嘉兴微电子与系统工程中心 | Automatic Baud rate detection method and detection module |
CN104486034A (en) * | 2014-12-08 | 2015-04-01 | 江西洪都航空工业集团有限责任公司 | RS422/485 serial port communication data packaging method |
CN104660369A (en) * | 2013-11-25 | 2015-05-27 | 北京卓越信通电子股份有限公司 | Method for velocity self-adaption of industrial serial port optical fiber transceiver |
CN105959093A (en) * | 2016-04-25 | 2016-09-21 | 成都大学 | Serial communication baud rate real-time self-adaption method |
CN106326156A (en) * | 2016-08-30 | 2017-01-11 | 西安翔腾微电子科技有限公司 | Single port communication processing circuit based on self-adaptive baud rate and method thereof |
CN110875911A (en) * | 2018-09-03 | 2020-03-10 | 厦门奇力微电子有限公司 | Communication protocol and communication method for supporting automatic identification of single data packet data bit number |
CN111400229A (en) * | 2020-03-10 | 2020-07-10 | 南京沁恒微电子股份有限公司 | Baud rate self-adaptive serial communication system and serial communication method |
CN111737182A (en) * | 2020-06-29 | 2020-10-02 | 山东管理学院 | Automatic configuration method and system for serial communication parameters |
CN112463696A (en) * | 2020-08-11 | 2021-03-09 | 上海麦腾物联网技术有限公司 | Serial port baud rate self-adaption method |
CN112532321A (en) * | 2020-11-22 | 2021-03-19 | 湖北久之洋红外系统股份有限公司 | Large dynamic range data communication method of portable laser communication equipment |
CN112994927A (en) * | 2021-02-04 | 2021-06-18 | 海光信息技术股份有限公司 | Retrieval method and retrieval device for daisy chain topology |
CN113032320A (en) * | 2021-04-09 | 2021-06-25 | 山东大学 | Asynchronous serial port communication baud rate self-adaption method |
CN114490487A (en) * | 2022-02-16 | 2022-05-13 | 瀚云科技有限公司 | Serial port information acquisition method, device, equipment and storage medium |
CN117155782A (en) * | 2023-09-15 | 2023-12-01 | 江苏舒茨测控设备股份有限公司 | Method for automatically analyzing communication parameters |
CN117389851A (en) * | 2023-10-20 | 2024-01-12 | 江苏普达迪泰科技有限公司 | Method for monitoring communication data abnormality of drive measurement calibration serial port |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1293852A (en) * | 1998-03-16 | 2001-05-02 | 艾利森公司 | Automatic speed detection for asynchronous serial communications |
EP1696576A1 (en) * | 2005-02-23 | 2006-08-30 | Casio Hitachi Mobile Communications Co., Ltd. | System and method of network-linked digital terrestrial television broadcasting using bit error rate detection and stopping of transmission. |
CN102306136A (en) * | 2011-08-03 | 2012-01-04 | 宁波三星电气股份有限公司 | Baud rate self-adaption method based on input capture function of singlechip |
-
2012
- 2012-10-17 CN CN201210394398.2A patent/CN103001734B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1293852A (en) * | 1998-03-16 | 2001-05-02 | 艾利森公司 | Automatic speed detection for asynchronous serial communications |
EP1696576A1 (en) * | 2005-02-23 | 2006-08-30 | Casio Hitachi Mobile Communications Co., Ltd. | System and method of network-linked digital terrestrial television broadcasting using bit error rate detection and stopping of transmission. |
CN102306136A (en) * | 2011-08-03 | 2012-01-04 | 宁波三星电气股份有限公司 | Baud rate self-adaption method based on input capture function of singlechip |
Cited By (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103389960A (en) * | 2013-07-26 | 2013-11-13 | 山东康威通信技术股份有限公司 | Method and device for self-adapting of Baud rate in field of power monitoring |
CN103389960B (en) * | 2013-07-26 | 2016-08-10 | 山东康威通信技术股份有限公司 | Power monitoring field realizes the method and device of baud rate self-adapting |
CN104660369A (en) * | 2013-11-25 | 2015-05-27 | 北京卓越信通电子股份有限公司 | Method for velocity self-adaption of industrial serial port optical fiber transceiver |
CN103618588B (en) * | 2013-11-26 | 2016-10-05 | 中国科学院嘉兴微电子与系统工程中心 | A kind of auto-baud-detect method and detection module |
CN103618588A (en) * | 2013-11-26 | 2014-03-05 | 中国科学院嘉兴微电子与系统工程中心 | Automatic Baud rate detection method and detection module |
CN104486034A (en) * | 2014-12-08 | 2015-04-01 | 江西洪都航空工业集团有限责任公司 | RS422/485 serial port communication data packaging method |
CN104486034B (en) * | 2014-12-08 | 2017-12-01 | 江西洪都航空工业集团有限责任公司 | A kind of RS422/485 serial port communication datas group bag method |
CN105959093A (en) * | 2016-04-25 | 2016-09-21 | 成都大学 | Serial communication baud rate real-time self-adaption method |
CN105959093B (en) * | 2016-04-25 | 2019-02-12 | 成都大学 | A kind of serial communication baud rate real-time adaptive method |
CN106326156A (en) * | 2016-08-30 | 2017-01-11 | 西安翔腾微电子科技有限公司 | Single port communication processing circuit based on self-adaptive baud rate and method thereof |
CN106326156B (en) * | 2016-08-30 | 2024-04-05 | 西安翔腾微电子科技有限公司 | Single-port communication processing circuit and method based on self-adaptive baud rate |
CN110875911B (en) * | 2018-09-03 | 2022-03-04 | 厦门奇力微电子有限公司 | Communication protocol and communication method for supporting automatic identification of single data packet data bit number |
CN110875911A (en) * | 2018-09-03 | 2020-03-10 | 厦门奇力微电子有限公司 | Communication protocol and communication method for supporting automatic identification of single data packet data bit number |
CN111400229A (en) * | 2020-03-10 | 2020-07-10 | 南京沁恒微电子股份有限公司 | Baud rate self-adaptive serial communication system and serial communication method |
CN111737182A (en) * | 2020-06-29 | 2020-10-02 | 山东管理学院 | Automatic configuration method and system for serial communication parameters |
CN112463696A (en) * | 2020-08-11 | 2021-03-09 | 上海麦腾物联网技术有限公司 | Serial port baud rate self-adaption method |
CN112532321A (en) * | 2020-11-22 | 2021-03-19 | 湖北久之洋红外系统股份有限公司 | Large dynamic range data communication method of portable laser communication equipment |
CN112532321B (en) * | 2020-11-22 | 2022-04-08 | 湖北久之洋红外系统股份有限公司 | Large dynamic range data communication method of portable laser communication equipment |
CN112994927A (en) * | 2021-02-04 | 2021-06-18 | 海光信息技术股份有限公司 | Retrieval method and retrieval device for daisy chain topology |
CN113032320A (en) * | 2021-04-09 | 2021-06-25 | 山东大学 | Asynchronous serial port communication baud rate self-adaption method |
CN114490487A (en) * | 2022-02-16 | 2022-05-13 | 瀚云科技有限公司 | Serial port information acquisition method, device, equipment and storage medium |
CN114490487B (en) * | 2022-02-16 | 2023-12-19 | 瀚云科技有限公司 | Method, device, equipment and storage medium for acquiring serial port information |
CN117155782A (en) * | 2023-09-15 | 2023-12-01 | 江苏舒茨测控设备股份有限公司 | Method for automatically analyzing communication parameters |
CN117389851A (en) * | 2023-10-20 | 2024-01-12 | 江苏普达迪泰科技有限公司 | Method for monitoring communication data abnormality of drive measurement calibration serial port |
CN117389851B (en) * | 2023-10-20 | 2024-02-09 | 江苏普达迪泰科技有限公司 | Method for monitoring communication data abnormality of drive measurement calibration serial port |
Also Published As
Publication number | Publication date |
---|---|
CN103001734B (en) | 2015-05-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103001734B (en) | Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling | |
CN107743103B (en) | Multi-node access detection and channel estimation method of MMTC (multimedia messaging and control) system based on deep learning | |
CN105068966A (en) | Serial automatic identification method | |
CN109101453B (en) | Asynchronous serial communication sampling system and method | |
CN109286473A (en) | A kind of low complex degree PDCCH channel blind detecting method based on polarization code | |
CN102710282B (en) | Self-synchronizing scrambling blind identification method based on code weight distribution | |
CN103780343A (en) | Device and method for PHICH resource blind detection in SIB1 decoding in TD-LTE system | |
CN114462509A (en) | Distributed Internet of things equipment anomaly detection method | |
CN102231890B (en) | Special burst detection method and device | |
CN103414663A (en) | Morse signal self-adaptive recognition method based on backtracking | |
CN111353025A (en) | Parallel corpus processing method and device, storage medium and computer equipment | |
CN101442380B (en) | Method and apparatus for testing error rate based on high speed serial interface encoded mode | |
CN104298980A (en) | Fingerprint matching method and device based on smart card | |
CN109446052B (en) | Verification method and device for application program | |
CN104360988A (en) | Method and device for identifying coding mode of Chinese characters | |
CN104270155A (en) | Manchester code stream reception and anti-interference analysis method | |
CN116488978A (en) | Frame synchronization method suitable for BR Bluetooth in test environment | |
CN115250217B (en) | OFDM system channel estimation method and device assisted by differential coding and neural network | |
US10616015B2 (en) | Signal processing system and method, and apparatus | |
CN108108267B (en) | Data recovery method and device | |
CN101316227A (en) | Method and device for detecting ACK/NACK information in high-speed packet access | |
CN115048365A (en) | Vehicle data cleaning method and device, electronic device and storage medium | |
CN112821895A (en) | Code identification method for realizing high error rate of signal | |
CN105846956B (en) | Block code code weight analysis recognition methods based on sliding window filtering | |
CN112395864A (en) | Text error correction model training method, text error correction method and related device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20150506 Termination date: 20181017 |
|
CF01 | Termination of patent right due to non-payment of annual fee |