CN103001734B - 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 PDF

Info

Publication number
CN103001734B
CN103001734B CN201210394398.2A CN201210394398A CN103001734B CN 103001734 B CN103001734 B CN 103001734B CN 201210394398 A CN201210394398 A CN 201210394398A CN 103001734 B CN103001734 B CN 103001734B
Authority
CN
China
Prior art keywords
data
asynchronous serial
serial communication
bit
frame
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.)
Expired - Fee Related
Application number
CN201210394398.2A
Other languages
Chinese (zh)
Other versions
CN103001734A (en
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.)
Naval University of Engineering PLA
Original Assignee
Naval University of Engineering PLA
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 Naval University of Engineering PLA filed Critical Naval University of Engineering PLA
Priority to CN201210394398.2A priority Critical patent/CN103001734B/en
Publication of CN103001734A publication Critical patent/CN103001734A/en
Application granted granted Critical
Publication of CN103001734B publication Critical patent/CN103001734B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

A kind of asynchronous serial communication agreement automatic detection method based on level sampling
Technical field
The invention belongs to digital communication technology field, specifically a kind of automatic detection method of the asynchronous serial communication agreement based on level sampling, can be used for the communication protocol detection that various application asynchronous serial communication agreement carries out the equipment of communication and transfer of data.
Technical background
The agreement of asynchronous serial communication agreement to be a kind of with Frame be communication unit data information, agreement define Frame by transmit speed (i.e. baud rate), in Frame and the load mode of interframe structure and data, as shown in Figure 1.Baud rate represents the figure place of the binary data transmitted in the unit interval in communication, 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 }.Asynchronous serial communication agreement becomes several Frames needing the Data Segmentation sent, and the structure of Frame is specified by concrete asynchronous serial communication agreement.A Frame starts, as the start bit of frame with a bit low level.Be data bit after start bit, according to the regulation of asynchronous serial communication agreement, all legal value of data bit number of bits is: one of 5 bits, 6 bits, 7 bits, 8 bits.It is check digit after data bit, according to the regulation of asynchronous serial communication agreement, if there is check digit, 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 verification, then do not establish check digit.Position of rest (if not having check digit position of rest and then last bit data position) after check digit, according to the regulation of 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 can have any number of bits (comprising 0 bit) spare bits between frame and frame, spare bits is high level, is the start bit of next frame after spare bits.According to the regulation of asynchronous serial communication agreement, the load mode of communication data can be that ASC II yard transmits or 16 system number transmission.
Asynchronous serial communication needs the protocol parameter appointing mutually that communication uses before communicating, is exactly specifically: baud rate, data bit number of bits, verification mode, position of rest number of bits, data coding mode.Under being equipped with some the occasion that the military import equipment of serial ports is representative, usually because the reason such as to maintain secrecy cannot the supporting specification of equipment, thus do not know asynchronous serial communication agreement that equipment uses.Chinese invention patent " baud rate adaptation method based on single-chip microcomputer input capture function " (application number: CN201110221090.3) proposes one machine and samples to asynchronous serial communication level, is calculated the method for the baud rate of communication by the level finding sampled point minimum number.But there is no 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 coding mode.
In sum, design a kind of detecting algorithm that automatically can complete asynchronous serial communication agreement baud rate, data bit number of bits, verification mode, position of rest number of bits, data coding mode, not only have certain innovative value, also have obvious realistic meaning.
Summary of the invention
For the deficiency of background technology, the present invention proposes one and level sampling is carried out to signal, by the new method of the single low level average length of time Auto-Sensing communication baud rate of calculating sampling signal, and on the basis that baud rate is detected, propose the automatic detection method of data bit number of bits, verification mode, position of rest number of bits, data coding mode.
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:
Step one, asynchronous serial communication level signal are sampled;
In step 2, sampled data, single low level average length of time calculates;
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 estimate that span calculates;
Step 5, in conjunction with asynchronous serial communication agreement, estimate span determination asynchronous serial communication baud rate by asynchronous serial communication baud rate;
Step 6, based on the asynchronous serial communication protocol data frame number of bits of position of rest relevant matches and data frame position detecting;
Step 7, asynchronous serial communication protocol data verification mode and data bit number of bits are detected;
Step 8, based on frame pitch from detect asynchronous serial communication agreement position of rest number of bits detecting;
Step 9, to detect based on the asynchronous serial communication protocol data coded system of minimal error rate Bayes decision-making.
As above based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the concrete grammar that the level signal of described step one asynchronous serial communication carries out sampling is: the sampled result of high level is " 1 ", low level sampled result is " 0 ", and sample frequency is the integral multiple needed by the integral multiple of maximum baud rate detected or the maximum baud rate of asynchronous serial communication agreement defined.Its beneficial effect is: communication data of effectively sampling, such as: need detecting baud rate to be less than or equal to the baud rate of the asynchronous serial port signal of 38400bps, sample frequency gets 4 times of 38400bps, is 153.6KHz; Sample frequency also directly can be taken as the integral multiple of the maximum baud rate of asynchronous serial communication agreement defined, such as: sample frequency gets 2 times of 256000bps, is 512KHz.
As above based on the asynchronous serial communication agreement automatic detection method of 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 statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, then obtain single low level average length of time by low level total time length divided by low level sum:
In formula represent single low level average length of time, n represents low level total number of sample points, and m represents low level sum, represent sample frequency.
As above based on the asynchronous serial communication agreement automatic detection method of 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 formula represent asynchronous serial communication baud rate, represent contained frame number in sampled data, represent the sampling error rate of every frame.Its beneficial effect is: based on the inevitable actual conditions of sampling error, through mathematical analysis, derives under asynchronous serial communication frame structure framework, the mathematical relationship of single low level average length of time and asynchronous serial communication baud rate.
As above based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: described step 4 asynchronous serial communication baud rate estimates being calculated as of span: the relational expression of the asynchronous serial communication baud rate that the single low level average length of time value of the sampled data utilizing statistical computation to obtain and mathematical derivation go out and single low level average length of time calculates the estimation span of asynchronous serial communication baud rate:
As above based on the asynchronous serial communication agreement automatic detection method of 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 { 50, 100, 120, 150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 128000, 256000 }, in the legal value set 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.
As above based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 6 is: with baud rate by the level signal detected for target signal, virtual 5 matching stencils, the feature of described masterplate comprises following five aspects:
Feature 1: 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 5,6,7,8,9 bits respectively;
Feature 5: the bit between masterplate start bit and position of rest is without any level character;
The coupling step of described position of rest relevant matches is:
Step a: carry out coincidence by the start bit of template with the low level in target signal being likely a start of frame bits and aim at, carries out same or computing with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position, record operation values;
Step b: after finding masterplate position of rest, first low level is aimed at;
Step c: repeat step a, step b, until all level of traversal target signal, has calculated a relevant matches;
Steps d: with relevance function calculate 5 masterplates not homogeneous coupling correlation, relevance function is defined as:
(s=5、6、7、8、9)
In formula for carrying out the level value of the target signal bit position of mating, be the level value of template position of rest, N is the total bit number participating in coupling, represent same or operator, s is the number of bits of masterplate frame, for coupling sequence number;
Step e: using the masterplate number of bits of maximum that coupling of relevance function value as frame Nepit figure place, using each start bit aligned position of maximum that coupling of relevance function value as the original position of each Frame.
As above based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 7 is: by position and the length of step one established data frame, extract every intraframe data, 4 kinds, school " particular kind of relationship " statistics is entered to intraframe data;
In particular kind of relationship 1: frame, the bit number of high level is even number, and even parity check statistic adds 1;
In particular kind of relationship 2: frame, the bit number of high level is odd number, and odd statistic adds 1;
In particular kind of relationship 3: frame, last bit is high level, and high verification statistic adds 1;
In particular kind of relationship 4: frame, last bit is low level, and low verification statistic adds 1;
Ratio according to statistic and frame sum compares with " verify and add up threshold value ", 4 kinds of any statistics of statistic account for the ratio of data totalframes beyond " verification statistics threshold value ", just judge the verification mode of verification mode corresponding to that statistic as target signal data, otherwise judge target signal data no parity check, determine that " verification statistics threshold value " is preferably set for 95% according to experiment
When no parity check, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 2, and when there being verification, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 3.
As above based on the asynchronous serial communication agreement automatic detection method of 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 target signal by step 6, step 7, bit distance between statistics frame and frame, searches out the shortest bit distance from the interframe bit distance statistic being not less than totalframes 10% quantity :
(I) =0 (bit), then think that position of rest number of bits is 1 bit;
(II) =0.5 (bit), then think that position of rest number of bits is 1.5 bits;
(III) =1 (bit), then think that position of rest number of bits is 2 bits;
(IV) other situations, then think that position of rest number of bits is 1 bit.
As above based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 9 is: pass through step 6, the determined data frame bit figure place of step 7 and data check mode, take out not containing the intraframe data of check digit, the intraframe data total amount that statistics is taken out and the legal data volume of ASC II coded system decoding value, by the posterior probability that the Bayes decision-making calculated data coded system based on minimal error rate is ASC II yard, whether be greater than " semantic decision gate limit value " with the posterior probability that data coding mode is ASC II yard and judge that the coded system of asynchronous serial communication data is ASC II yard or 16 system numbers, determine that " semantic decision gate limit value " is preferably set for 95% according to experiment, Bayes decision-making computational methods based on minimal error rate are:
In formula represent that data are ASC II yard; represent that data are 16 system numbers; for data error rate; it is the probability that data can be interpreted as ASC II yard; for event: in individual data, have individual data can be translated into ASC II yard; be respectively event under condition probability is tested before occurring, for the posterior probability that data coding mode is ASC II yard.
Innovative point of the present invention: the present invention proposes starting with from 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; Propose one virtual fatigue test masterplate and relevant matches is carried out to target signal, determine the new method of data frame bit figure place and data frame position; And propose the method for detecting of asynchronous serial communication protocol data position number of bits, verification mode, position of rest number of bits, data coding mode on this basis.
Accompanying drawing explanation
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 of the present invention detecting 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 from level;
Fig. 5 is the schematic diagram that the present invention calculates single low level different bit length probability;
Fig. 6 is the schematic diagram that the present invention puts back to the start bit of each frame of asynchronous serial communication frame of taking out and the spare bits of position of rest and interframe in random data;
Fig. 7 is virtual fatigue test masterplate 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 that asynchronous serial communication protocol data verification mode of the present invention and data bit number of bits detect flow chart;
Figure 10 the present invention is based on the flow chart of frame pitch from the asynchronous serial communication agreement position of rest number of bits detecting detected;
Figure 11 is the flow chart of the asynchronous serial communication protocol data coded system detecting that the present invention is based on minimal error rate Bayes decision-making;
Figure 12 is an embodiment figure of the present invention;
Embodiment:
Below in conjunction with accompanying drawing, the invention will be further described.
With reference to Fig. 2, it is implementing procedure figure of the present invention.First the baud rate of signal is detected, at communication baud rate by the basis detected, virtual a series of matching stencil, position of rest relevant matches is carried out with the Different matching point of these masterplates to target signal, by the correlation of each coupling of relevance function tolerance, using maximum that the matching stencil number of bits of relevance function value as frame Nepit figure place, using each start bit aligned position of maximum that coupling of relevance function value as the original position of each Frame.Again according to position and the number of bits of Frame, extract every intraframe data, carry out the inspection of verification mode.Extract simultaneously frame pitch from, by the shortest interframe distance estimations position of rest number of bits.Finally take out not containing the intraframe data of check digit, adopt the Bayes decision-making technique based on minimal error rate, judge that the coded system of asynchronous serial communication data is ASC II yard or 16 system numbers according to the posteriority decision probability of intraframe data ASC II coded system decoding.
With reference to Fig. 3, it is baud rate of the present invention detecting implementation method flow chart.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 needed by the maximum baud rate detected, such as: need detecting baud rate to be less than or equal to the baud rate of the asynchronous serial port signal of 38400bps, sample frequency gets 4 times of 38400bps, is 153.6KHz; Sample frequency also directly can be taken as the integral multiple of the maximum baud rate of asynchronous serial communication agreement defined, such as: sample frequency gets 2 times of 256000bps, is 512KHz.Then the sum of low level sum and low level sampled point in statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, then obtain single low level average length of time by low level total time length divided by low level sum.The relationship combining asynchronous serial communication baud rate and the single low level average length of time derived again calculates the estimation span of asynchronous serial communication baud rate.Finally search in the legal value set of the communication baud rate of the regulation of asynchronous serial communication agreement by the estimation span of the communication baud rate calculated, get the estimation span that falls into baud rate or be defined as the communication baud rate of sampled asynchronous serial port level with the legal value of the immediate baud rate of estimation span of baud rate.
With reference to Fig. 4 to Fig. 6, which show 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 spare bits of the start bit of each frame of asynchronous serial communication signal level data frame and position of rest and interframe all to take out from level, can think that remaining data are random data of communications.
With reference to Fig. 5, it illustrate under errorless code-bar part, the derivation thinking of single low level average specific bit length in 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:
Single low level average specific bit length in random data for:
Be provided with one section to comprise the level signal of individual Frame.After taking out the start bit of each frame and the spare bits of position of rest and interframe, in level signal, low level number is m, therefore the total bit length of low level is estimated as 2m, in a frame random data signals, the probability of low and high level is equal, therefore in frame, the total bit length of level is estimated as 4m.Because the bit length of a frame is 5 ~ 9 bits in 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 of taking out and the spare bits of position of rest and interframe are put back in random data, the level putting into position has 4 kinds of possibilities, as in Fig. 6: 1. high level trailing edge, 2. high level, 3. low level rising edge, 4. low level.Because data are random, 4 kinds may equiprobability.Only being placed on 1. place makes the low level quantity of whole data sequence constant, and the low level quantity being placed on its excess-three position data sequence increases 1.And often perform and once put into operation low level total bit length and increase equal 1.After then putting into the start bit of each frame and the spare bits of position of rest and interframe, the total bit length of low level is estimated as: , low level number is estimated as: .
Consider error code again, if the frame sampling error rate of data is .Error code occurs in low and high 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 low level number to increase 1.Consider that the total bit length of low level after error code is estimated as: , low level number is estimated as: .Bit length just obtains time span divided by baud rate, and the single low level time length of sampled data that there is error code is contemplated to be:
The single low level time length of sampled data can be added up by sampled data, is obtained by following formula:
In formula, n represents low level total number of sample points, and m represents low level sum, represent sample frequency.
The estimation span of asynchronous serial communication baud rate can be derived by above three formulas:
Due to the error rate much smaller than 1, calculate when estimating span and can ignore , be directly written as:
The interval of the estimation span of above-mentioned baud rate is smaller, and the legal value set of baud rate is { 50, 100, 120, 150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 128000, 256000 }, in legal value set, the difference value of adjacent baud rate is very large, search in the legal value set of the communication baud rate of the regulation of asynchronous serial communication agreement, get the estimation span that falls into baud rate or be defined as the communication baud rate of sampled asynchronous serial port level with the legal value of the immediate baud rate of estimation span of baud rate.
With reference to Fig. 7, it is virtual fatigue test masterplate schematic diagram of the present invention, altogether can virtual 5 templates, and the feature of these matching stencils is:
1.. 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;
4. the distance of .5 masterplate start bit and position of rest 5,6,7,8,9 bits respectively;
5.. the bit between masterplate start bit and position of rest is without any level character;
With reference to Fig. 8, it is the position of rest relevant matches schematic diagram that the present invention proposes.The concrete implementation step of position of rest relevant matches is:
Step 1: the matching template choosing the number of bits s=5 between start bit and position of rest, alignment targets signal first low level bit.Record by the number m of the low level bit of matching template s position bit covering in target signal, capped each low level all as initial alignment point in subsequent step, will carry out a relevant matches simultaneously;
Step 2: carry out same or computing with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position, record operation result;
Step 3: the follow-up level of scanning target signal occurs to low level, with start bit alignment targets signal first low level bit of masterplate, repeats step 2, until all level of traversal target signal, has calculated a relevant matches;
Step 4: calculate with relevance function and mate correlation for the first time ;
Step 5: respectively with m the low level bit covered by matching stencil in mating for the first time for initial alignment point, repeat step 2-step 4, obtain other correlation of mating for m time ;
Step 6: if the number of bits s<9 between the start bit of matching stencil and position of rest, then s increases 1, repeats step 1-step 5;
Step 7: the maximum selecting all coupling correlations , using r value then as frame Nepit figure place, using the matching stencil first time coupling that is r by length v low level covering as the start bit of the first frame data of target signal, each start bit aligned position of that time corresponding coupling is as the start bit position of each Frame of target signal.
With reference to Fig. 9, it is that asynchronous serial communication protocol data verification mode of the present invention and data bit number of bits detect flow chart.Extract every intraframe data, the frame number of " particular kind of relationship " that intraframe data meets is added up, compare according to statistic and the ratio of frame sum and " verify and add up threshold value " of setting.4 kinds of any statistics of statistic account for the ratio of data totalframes beyond " verification statistics threshold value ", just judge the verification mode of verification mode corresponding to that statistic as target signal data, otherwise judge target signal data no parity check.Determine that " verification statistics threshold value " is set as 95% according to experiment, the statistics that described " particular kind of relationship " carries out comprised:
In (I) one frame, the bit number of high level is even number, and even parity check statistic adds 1;
In (II) one frame, the bit number of high level is odd number, and odd statistic adds 1;
In (III) one frame, last bit is high level, and high verification statistic adds 1;
In (IV) one frame, last bit is low level, and low verification statistic adds 1;
When judging no parity check, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 2, and when being determined with verification, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 3.
With reference to Figure 10, it the present invention is based on the flow chart of frame pitch from the asynchronous serial communication agreement position of rest number of bits detecting detected.First the bit distance information between every frame is extracted, then search out the shortest bit distance from the interframe bit distance statistic being not less than totalframes 10% quantity judge position of rest number of bits:
(I) =0 (bit), then think that position of rest number of bits is 1 bit;
(II) =0.5 (bit), then think that position of rest number of bits is 1.5 bits;
(III) =1 (bit), then think that position of rest number of bits is 2 bits;
If there is other situations, illustrate always there is spare bits between the most of Frame of target signal, now think that position of rest is 1 bit.Because position of rest is connected with spare bits and the two is high level in asynchronous serial communication, thus more than the position of rest of 1 bit and spare bits of equal value, think that position of rest is 1 bit, do not affect normally carrying out of asynchronous serial communication.
With reference to Figure 11, it is the flow chart of the asynchronous serial communication protocol data coded system detecting that the present invention is based on minimal error rate Bayes decision-making.Asynchronous serial communication intraframe data position number of bits must be more than or equal to the transmission that 7 just can carry out ASC II yard, and the ASC II yard of asynchronous serial communication transmission is character visible, and No. 32 namely in ASC II code table to 127 sign characters.If a data value is not between [32,127], then these data can not be interpreted as ASC II yard.If asynchronous serial communication intraframe data position number of bits is 7 or 8, then need to carry out data coding mode judgement.First extract not containing the intraframe data of check digit, statistics total quantity and the data bulk that can be interpreted as ASC II yard.Then the posterior probability of the coded system ASC II yard of all data is calculated by the Bayes decision-making technique based on minimal error rate.The coded system that this posterior probability is greater than " semantic decision gate limit value " then judges asynchronous serial communication data is ASC II yard, otherwise decision data coded system is 16 system numbers.Determine that " semantic decision gate limit value " is set as 95% according to experiment, the Bayes decision-making computational methods based on minimal error rate are:
In formula represent that data are ASC II yard; represent that data are 16 system numbers; for data error rate; it is the probability that data can be interpreted as ASC II yard; for event: in individual data, have individual data can be translated into ASC II yard; be respectively event under condition probability is tested before occurring, for the posterior probability that data coding mode is ASC II yard.
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 proposes is compiled into computer program, a string asynchronous serial port signal is inputted from computer volume com interface, the communication protocol of this signal is: baud rate: 9600bps, data bit number of bits: 7, check digit: nothing, position of rest number of bits: 2, data coding mode: ASC II yard.Fig. 8 shows agreement detecting result and part detects process data.It should be noted that, the matching stencil showing different frame Nepit figure place in figure in " data word length " hurdle carries out the maximum correlation functional value of relevant matches to 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 the position of rest number of bits of target signal is 2, two kinds of each match points of matching stencil are just in time the first bit and second bit of target signal position of rest, algorithm, based on the randomness of intraframe data, judges that frame Nepit figure place is as 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 the claims in the present invention basis and polishing all belong to protection scope of the present invention.

Claims (9)

1., based on an asynchronous serial communication agreement automatic detection method for level sampling, it is characterized in that: comprise the steps:
Step one, asynchronous serial communication level signal are sampled;
In step 2, sampled data, single low level average length of time calculates;
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 estimate that span calculates, and its account form is specially: the relational expression of the asynchronous serial communication baud rate that the single low level average length of time value of the sampled data utilizing statistical computation to obtain and mathematical derivation go out and single low level average length of time calculates the estimation span of asynchronous serial communication baud rate: , represent low level total number of sample points, represent low level sum, represent sample frequency, represent asynchronous serial communication baud rate;
Step 5, in conjunction with asynchronous serial communication agreement, estimate span determination asynchronous serial communication baud rate by asynchronous serial communication baud rate;
Step 6, based on the asynchronous serial communication protocol data frame number of bits of position of rest relevant matches and data frame position detecting;
Step 7, asynchronous serial communication protocol data verification mode and data bit number of bits are detected;
Step 8, based on frame pitch from detect asynchronous serial communication agreement position of rest number of bits detecting;
Step 9, to detect based on the asynchronous serial communication protocol data coded system of minimal error rate Bayes decision-making.
2. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the concrete grammar that the level signal of described step one asynchronous serial communication carries out sampling is: the sampled result of high level is " 1 ", low level sampled result is " 0 ", and sample frequency is the integral multiple needed by the integral multiple of maximum baud rate detected or the maximum baud rate of asynchronous serial communication agreement defined.
3. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of 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 statistic sampling data, obtain low level total time length with the sum of low level sampled point divided by sample frequency, then obtain single low level average length of time by low level total time length divided by low level sum:
In formula represent single low level average length of time, represent low level total number of sample points, represent low level sum, represent sample frequency.
4., as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of 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 formula represent asynchronous serial communication baud rate, represent contained frame number in sampled data, represent the sampling error rate of every frame.
5. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of 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 { 50, 100, 120, 150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 128000, 256000 }, in the legal value set 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.
6. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 6 is: with baud rate by the level signal detected for target signal, virtual 5 matching stencils, the feature of described masterplate comprises following five aspects:
Feature 1: 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 5,6,7,8,9 bits respectively;
Feature 5: the bit between masterplate start bit and position of rest is without any level character;
The coupling step of described position of rest relevant matches is:
Step a: carry out coincidence by the start bit of template with the low level in target signal being likely a start of frame bits and aim at, carries out same or computing with the target signal bit position that the position of rest of masterplate overlaps with masterplate position of rest position, record operation values;
Step b: after finding masterplate position of rest, first low level is aimed at;
Step c: repeat step a, step b, until all level of traversal target signal, has calculated a relevant matches;
Steps d: with relevance function calculate 5 masterplates not homogeneous coupling correlation, relevance function is defined as:
In formula for carrying out the level value of the target signal bit position of mating, be the level value of template position of rest, N is the total bit number participating in coupling, represent same or operator, for the number of bits of masterplate frame, for coupling sequence number;
Step e: using the masterplate number of bits of maximum that coupling of relevance function value as frame Nepit figure place, using each start bit aligned position of maximum that coupling of relevance function value as the original position of each Frame.
7. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 7 is: by position and the length of step one established data frame, extract every intraframe data, 4 kinds, school " particular kind of relationship " statistics is entered to intraframe data;
In particular kind of relationship 1: frame, the bit number of high level is even number, and even parity check statistic adds 1;
In particular kind of relationship 2: frame, the bit number of high level is odd number, and odd statistic adds 1;
In particular kind of relationship 3: frame, last bit is high level, and high verification statistic adds 1;
In particular kind of relationship 4: frame, last bit is low level, and low verification statistic adds 1;
Ratio according to statistic and frame sum compares with " verify and add up threshold value ", 4 kinds of any statistics of statistic account for the ratio of data totalframes beyond " verification statistics threshold value ", just judge the verification mode of verification mode corresponding to that statistic as target signal data, otherwise judge target signal data no parity check; Determine that " verification statistics threshold value " is set as 95% according to experiment,
When no parity check, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 2, and when there being verification, data bit number of bits equals the determined data frame bit figure place of step 6 and subtracts 3.
8. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of 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 target signal by step 6, step 7, bit distance between statistics frame and frame, searches out the shortest bit distance from the interframe bit distance statistic being not less than totalframes 10% quantity :
(I) , then think that position of rest number of bits is 1 bit;
(II) , then think that position of rest number of bits is 1.5 bits;
(III) , then think that position of rest number of bits is 2 bits;
(IV) other situations, then think that position of rest number of bits is 1 bit.
9. as claimed in claim 1 based on the asynchronous serial communication agreement automatic detection method of level sampling, it is characterized in that: the specific implementation of described step 9 is: pass through step 6, the determined data frame bit figure place of step 7 and data check mode, take out not containing the intraframe data of check digit, the intraframe data total amount that statistics is taken out and the legal data volume of ASC II coded system decoding value, by the posterior probability that the Bayes decision-making calculated data coded system based on minimal error rate is ASC II yard, whether be greater than " semantic decision gate limit value " with the posterior probability that data coding mode is ASC II yard and judge that the coded system of asynchronous serial communication data is ASC II yard or 16 system numbers, determine that " semantic decision gate limit value " is preferably set for 95% according to experiment, Bayes decision-making computational methods based on minimal error rate are:
In formula represent that data are ASC II yard; represent that data are 16 system numbers; for data error rate; it is the probability that data can be interpreted as ASC II yard; for event: in individual data, have individual data can be translated into ASC II yard; be respectively with event under condition probability is tested before occurring, for the posterior probability that data coding mode is ASC II yard.
CN201210394398.2A 2012-10-17 2012-10-17 Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling Expired - Fee Related CN103001734B (en)

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 CN103001734A (en) 2013-03-27
CN103001734B true 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)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN104486034B (en) * 2014-12-08 2017-12-01 江西洪都航空工业集团有限责任公司 A kind of RS422/485 serial port communication datas group bag method
CN105959093B (en) * 2016-04-25 2019-02-12 成都大学 A kind of serial communication baud rate real-time adaptive method
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
CN111400229A (en) * 2020-03-10 2020-07-10 南京沁恒微电子股份有限公司 Baud rate self-adaptive serial communication system and serial communication method
CN111737182B (en) * 2020-06-29 2022-04-15 山东管理学院 Automatic configuration method and system for serial communication parameters
CN112463696A (en) * 2020-08-11 2021-03-09 上海麦腾物联网技术有限公司 Serial port baud rate self-adaption method
CN112532321B (en) * 2020-11-22 2022-04-08 湖北久之洋红外系统股份有限公司 Large dynamic range data communication method of portable laser communication equipment
CN112994927B (en) * 2021-02-04 2022-11-25 海光信息技术股份有限公司 Retrieval method and retrieval device for daisy chain topology
CN113032320B (en) * 2021-04-09 2022-10-18 山东大学 Asynchronous serial port communication baud rate self-adaption method
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
CN117389851B (en) * 2023-10-20 2024-02-09 江苏普达迪泰科技有限公司 Method for monitoring communication data abnormality of drive measurement calibration serial port

Citations (3)

* Cited by examiner, † Cited by third party
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

Patent Citations (3)

* Cited by examiner, † Cited by third party
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

Also Published As

Publication number Publication date
CN103001734A (en) 2013-03-27

Similar Documents

Publication Publication Date Title
CN103001734B (en) Method for automatically detecting asynchronous serial port communication protocol on basis of level sampling
CN101414939B (en) Internet application recognition method based on dynamical depth package detection
CN105068966A (en) Serial automatic identification method
CN109561106B (en) Ship communication message real-time analysis and filtering method
CN102880501A (en) Realizing method, device and system for recommending applications
CN110691035A (en) Method and device for determining network congestion, electronic equipment and storage medium
CN110874744B (en) Data anomaly detection method and device
CN109413047A (en) Determination method, system, server and the storage medium of Behavior modeling
CN112787984A (en) Vehicle-mounted network anomaly detection method and system based on correlation analysis
CN103546242A (en) Method for detecting error rate of original data of remote sensing satellite
CN104348815A (en) Method and device for verifying verification code
CN109446052B (en) Verification method and device for application program
CN104298980A (en) Fingerprint matching method and device based on smart card
CN109376064B (en) Method and equipment for generating interface test report
CN114157486B (en) Communication flow data abnormity detection method and device, electronic equipment and storage medium
CN115934756A (en) Hybrid-encoding operator calculation method, device, equipment and medium
CN106446125B (en) Method and device for improving data quality
CN101316227A (en) Method and device for detecting ACK/NACK information in high-speed packet access
CN111783804B (en) Abnormal ticket determining method, device, equipment and storage medium
CN111967667A (en) Distributed operation and maintenance method and system for rail transit
CN102523181B (en) Blind frame synchronization sequence estimation method
CN102263791A (en) Method and system for checking resource files
CN115866235A (en) Video quality evaluation method and device, electronic equipment and storage medium
CN105846854B (en) A kind of blind-identification method and device of frame synchronization
CN117395080B (en) Encryption system scanner detection method, device, electronic equipment and storage medium

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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150506

Termination date: 20181017