CN104991756B - A kind of floating data guard method of data link transmission process - Google Patents

A kind of floating data guard method of data link transmission process Download PDF

Info

Publication number
CN104991756B
CN104991756B CN201510347139.8A CN201510347139A CN104991756B CN 104991756 B CN104991756 B CN 104991756B CN 201510347139 A CN201510347139 A CN 201510347139A CN 104991756 B CN104991756 B CN 104991756B
Authority
CN
China
Prior art keywords
floating
data
link transmission
transmission process
abnormal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510347139.8A
Other languages
Chinese (zh)
Other versions
CN104991756A (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.)
Nanjing University of Aeronautics and Astronautics
Original Assignee
Nanjing University of Aeronautics and Astronautics
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 Nanjing University of Aeronautics and Astronautics filed Critical Nanjing University of Aeronautics and Astronautics
Priority to CN201510347139.8A priority Critical patent/CN104991756B/en
Publication of CN104991756A publication Critical patent/CN104991756A/en
Application granted granted Critical
Publication of CN104991756B publication Critical patent/CN104991756B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Complex Calculations (AREA)
  • Emergency Protection Circuit Devices (AREA)

Abstract

The invention discloses a kind of floating data guard method of data link transmission process; floating data in transmitting procedure is taken out to the representation of single precision floating datum and double-precision floating points; then bit field operation is carried out to it and builds its data structure; then its abnormal number and unreasonable number are excluded; obtain correct floating number; so that during solving multibyte data link transmission; the computer corruption or the problem of result mistake caused by floating data malfunctions so that embedded system has the safety and reliability of higher.

Description

A kind of floating data guard method of data link transmission process
Technical field
The present invention relates to floating data guard method in a kind of multibyte data transmitting procedure, belongs to data transmission technology neck Domain.
Background technology
Embedded system particularly carries out multibyte transmission, is then spliced into floating number again in data transmission procedure According to when, easily produce unreasonable floating number, such as GPS transport protocols in flight control system, will pass through in IMU transport protocols The substantial amounts of floating data of Serial Port Transmission.When carrying out floating-point operation, if the floating number for participating in computing is unreasonable number, can lead Cause result of calculation meaningless, or even triggering floating-point exception interruption restarts computer corruption.In order to ensure that embedded computer is transported Capable safety and reliability, can carry out filtering out for unreasonable floating number before data are read, therefore in multibyte communication process The floating data protective capability of increase embedded computer just seems increasingly important.
The content of the invention
Goal of the invention:In order to overcome the deficiencies in the prior art, the present invention provides a kind of data link transmission process Floating data guard method, solve unreasonable floating number cause embedded computer produce abnormal conditions, it is ensured that embedded system The stability of normal operation and the communication link work of system.
Technical solution:To achieve the above object, the technical solution adopted by the present invention is:A kind of data link transmission process Floating data guard method, it is realized that floating number is protected based on floating number data structure, specifically includes following steps:
Step 1, the floating data in transmitting procedure is taken out by single precision floating datum according to IEEE floating number arithmetic standards With the representation of double-precision floating points;
Step 2, the single precision floating datum and the representation of double-precision floating points step 1 taken out is operated using bit field The data structure of description floating number is constructed, while the sign bit of floating number, exponent bits, mantissa bit are stripped out;
Step 3, carry out abnormal number to the data structure built in step 2 to exclude, obtain non-abnormal number;
Step 4, the sign bit being stripped out in the non-abnormal number obtained to step 3, exponent bits, mantissa bit carry out numerical value and sentence It is disconnected;For being judged as that unreasonable floating number carries out data filtering, for being judged as that reasonable floating number carries out data update, number is realized According to the protection of the floating data of link transmission process, and floating data error situation is fed back to using return value in the process User.
Preferably:In the step 3 abnormal number for " index 0, and mantissa is non-zero " floating number.
Preferably:Unreasonable floating number in the step 4 is the floating number of " index is maximum ".
Beneficial effect:The floating data guard method of a kind of data link transmission process provided by the invention, compared to existing Technology, has the advantages that:
Floating data in transmitting procedure is taken out the expression shape of single precision floating datum and double-precision floating points by the present invention Formula, then carries out bit field to it and builds its data structure, according to the characteristic of bit field data structure, excludes its abnormal number and unreasonable Number, obtains non-abnormal number and rationally number, that is, obtains correct floating number, therefore it can thoroughly solve multibyte data link biography During defeated, the computer corruption or the problem of result mistake caused by floating data malfunctions so that embedded system has There is the safety and reliability of higher.
Brief description of the drawings
Fig. 1 is single precision floating datum structure diagram.
Fig. 2 is double-precision floating points structure diagram.
Fig. 3 is floating data classification chart.
Fig. 4 is floating data protection scheme flow chart.
Embodiment
The present invention is further described below in conjunction with the accompanying drawings.
A kind of floating data guard method of data link transmission process, it realizes floating number based on floating number data structure Protection, it is abstract according to IEEE floating number arithmetic standard (IEEE Standard for Floating-Point Arithmetic) Go out the representation of single precision floating datum and double-precision floating points, respectively such as attached drawing 1, shown in attached drawing 2.Operated and built using bit field Go out to describe the data structure of floating number, the sign bit of floating number, exponent bits, mantissa bit are stripped out.Again to sign bit, index Position, mantissa bit carry out numerical value judgement, and criteria for classification in 3, respective handling is done to different types of floating number with reference to the accompanying drawings, i.e., only when Just data are updated when judging result is reasonable floating number, otherwise without exception by this data filtering, avoid result of calculation without Meaning or computer corruption situation produce, and finally realize defencive function.Whole protocol procedures are as shown in Figure 4.Specifically include with Lower step:
Step 1, the floating data in transmitting procedure is taken out by single precision floating datum according to IEEE floating number arithmetic standards With the representation of double-precision floating points;
Step 2, the single precision floating datum and the representation of double-precision floating points step 1 taken out is operated using bit field The data structure of description floating number is constructed, while the sign bit of floating number, exponent bits, mantissa bit are stripped out;
Step 3, carry out abnormal number to the data structure built in step 2 to exclude, obtain non-abnormal number;
In the step 3 abnormal number for " index 0, and mantissa is non-zero " floating number.
Step 4, the sign bit being stripped out in the non-abnormal number obtained to step 3, exponent bits, mantissa bit carry out numerical value and sentence It is disconnected;For being judged as that unreasonable floating number carries out data filtering, for being judged as that reasonable floating number carries out data update, number is realized According to the protection of the floating data of link transmission process.
Unreasonable floating number in the step 4 is the floating number of " index is maximum ".
In order to be better understood from the present invention, the realization principle of the present invention is described in detail below.
The floating-point guard method has versatility, and for different embedded type CPUs, this method realizes that process is completely the same, Only in use, it is slightly different according to the difference of the big little endian modes of CPU, its application method.The floating-point protection of the present embodiment Method realizes that last way of realization is the C language function of functional independence based on standard C language, portable strong, its step bag Include and define floating number data structure, acquisition each part of floating number, excludes abnormal number, and exclusion is non-several, rationally counts data more Newly.
1st, floating number data structure is defined
According to IEEE floating number arithmetic standards, floating number is made of three parts:Sign bit, index are mantissa bit.Such as table 1 It is shown.Wherein, for single precision floating datum, as shown in Figure 1, sign bit accounts for 1bit data, exponent bits account for 8bit data, mantissa bit 23bit is accounted for, and is arranged in order from high to low;For double-precision floating points, as shown in Fig. 2, sign bit accounts for 1bit data, index Position accounts for 11bit data, and mantissa bit accounts for 52bit.According to this structure, operated using bit field, each several part of floating number is taken out successively.
1 floating number each several part of table forms situation
2nd, abnormal number is excluded
Floating number classification foundation is concluded as shown in table 2;
2 floating number classification foundation of table
Sequence number Symbol Index Mantissa Numerical value
1 0 Maximum It is non-zero It is non-several
2 0 Maximum 0 It is infinitely great
3 0 0<Index<Maximum It is non-zero Normal number
4 0 0 It is non-zero Abnormal number
5 0 0 0 0
6 1 0 0
7 1 0 It is non-zero Abnormal number
8 1 0<Index<Maximum It is non-zero Normal number
9 1 Maximum 0 It is infinitely great
10 1 Maximum It is non-zero It is non-several
As table 2 summarizes floating number classification foundation.Summed up according to table 2 in attached drawing 3 as a result, wherein two class floating numbers are different Constant.
1) when sign bit is 0, and exponent bits are 0, mantissa bit is not 0;
2) when sign bit is 1, and exponent bits are 0, mantissa bit is not 0.
To sum up the floating number for meeting " index 0, and mantissa is non-zero " is abnormal number, if carrying out floating-point operation Triggering floating-point exception is interrupted, computer corruption can be caused to restart, just terminate function operation at this time, without data update, returned Return 1 and represent that the floating number is abnormal.
3rd, unreasonable number is excluded
As shown in figure 3, it is unreasonable number to have four class floating numbers:
1) when sign bit is 0, when exponent bits are maximum, mantissa bit is not 0;
2) when sign bit be 0, when exponent bits are maximum, mantissa bit 0;
3) when sign bit is 1, when exponent bits are maximum, mantissa bit is not 0.
4) when sign bit be 1, when exponent bits are maximum, mantissa bit 0.
To sum up the floating number for meeting " index is maximum " is unreasonable number, if carrying out floating-point operation acquisition Result of calculation be still unreasonable number (infinitely great, or non-several), just terminate function operation at this time, without data update, Return to 1 and represent that the floating number is meaningless.
4th, data update is rationally counted
After abnormal number and unreasonable number is excluded, remaining is reasonable floating number, can assignment, and normally participate in four fundamental rules Computing, is at this time updated floating data, is then back to numerical value " 0 " and represents that floating number is reasonable.As shown in figure 4, floating-point is protected Function return value uses antilogical, is conducive to statistics error number, i.e. return value 1 represents that floating number is unreasonable, and errors number is tired out Add 1;Return value 0 represents that floating number is reasonable, and error number does not increase.Therefore accumulation return value is can obtain floating point errors total time Number.
By above-mentioned 4 steps, the defencive function of unreasonable floating number in communication process is just realized, system will be caused different Normal data filtering, retains correct floating number.Its pseudocode is as follows:
5th, application method
Floating-point protective program uses after link data frame decoding before floating-point variable assignment, to the floating number of multibyte splicing Pre-processed, determine unreasonable floating number in advance, prevent computer corruption.Meanwhile the application method of the protective program with Conventional method is highly consistent, it can be achieved that the seamless upgrade of code.
Since floating-point guard method has versatility, and floating-point protective program is developed using standard C, therefore for different embedding Enter formula CPU, which makes no modifications i.e. generally applicable.But the difference of the big small ends of CPU, is slightly different its application method, Described in detail in following code sample.
Since single precision and double-precision floating point protective program application method are just the same, therefore by taking single precision protective program as an example Describe its application method in detail.
Floating-point protective program be based on " the easy existing program of transplantation substitute " thought developed, therefore below comparative illustration its why Sample substitutes original program:
(1) (2) explanation:During link transmission data, acquiescence low byte preceding, i.e. Buf [20] for latitude data Least Significant Character Section.When in use, for big end pattern CPU, the low byte of link data need to be assigned to the high byte of variable src, number of links According to high byte be assigned to the low byte of variable src, as shown in code (1);And little endian mode just on the contrary, must order assignment, As shown in code (2).
Original program is after frame decoding, by association by 4 byte data direct splicings into floating number, if abnormal floating-point Number, will inevitably lead to computer corruption;Function is protected using floating-point, it is only necessary to which the assignment statement of association is changed to floating-point Function is protected, does not change user's use habit.
Therefore can be obtained from contrast, floating-point protection function not only can guarantee that the safety and reliability of computer, but also not change user Use habit, can seamlessly substitute original program.
In addition to basic function, floating number error of transmission number can also be counted using return value, user is fed back to, with big end mould Exemplified by formula CPU, its code sample is as follows:
When floating number is abnormal number, protection function returns to 1, and error number can be obtained by constantly adding up to this, side Just user refers to.
The above is only the preferred embodiment of the present invention, it should be pointed out that:For the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications also should It is considered as protection scope of the present invention.

Claims (2)

1. a kind of floating data guard method of data link transmission process, it is characterised in that comprise the following steps:
Step 1, the floating data in transmitting procedure is taken out by single precision floating datum and double according to IEEE floating number arithmetic standards The representation of accuracy floating-point number;
Step 2, the single precision floating datum and the representation of double-precision floating points step 1 taken out utilizes bit field operation structure Go out to describe the data structure of floating number, while the sign bit of floating number, exponent bits, mantissa bit are stripped out;
Step 3, carry out abnormal number to the data structure built in step 2 to exclude, obtain non-abnormal number;Abnormal number is " index is 0, and mantissa is non-zero " floating number;
Step 4, the sign bit being stripped out in the non-abnormal number obtained to step 3, exponent bits, mantissa bit carry out numerical value judgement; For being judged as that unreasonable floating number carries out data filtering, for being judged as that reasonable floating number carries out data update, data are realized The protection of the floating data of link transmission process, and floating data error situation is fed back into use using return value in the process Family.
2. the floating data guard method of data link transmission process according to claim 1, it is characterised in that:The step Unreasonable floating number in rapid 4 is the floating number of " index is maximum ".
CN201510347139.8A 2015-06-19 2015-06-19 A kind of floating data guard method of data link transmission process Active CN104991756B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510347139.8A CN104991756B (en) 2015-06-19 2015-06-19 A kind of floating data guard method of data link transmission process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510347139.8A CN104991756B (en) 2015-06-19 2015-06-19 A kind of floating data guard method of data link transmission process

Publications (2)

Publication Number Publication Date
CN104991756A CN104991756A (en) 2015-10-21
CN104991756B true CN104991756B (en) 2018-04-17

Family

ID=54303572

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510347139.8A Active CN104991756B (en) 2015-06-19 2015-06-19 A kind of floating data guard method of data link transmission process

Country Status (1)

Country Link
CN (1) CN104991756B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104238992A (en) * 2014-09-09 2014-12-24 南京航空航天大学 High-performance imprecise floating point adder and application method thereof

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7689639B2 (en) * 2004-06-04 2010-03-30 Telefonaktiebolaget Lm Ericsson (Publ) Complex logarithmic ALU

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104238992A (en) * 2014-09-09 2014-12-24 南京航空航天大学 High-performance imprecise floating point adder and application method thereof

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
单精度浮点数累加和误差研究;陈天超等;《计算机应用》;20130601;第33卷(第6期);第1531-1533页 *
基于IEEE 754的浮点数存储格式分析研究;朱亚超;《计算机与信息技术》;20061231(第9期);第50-52页 *

Also Published As

Publication number Publication date
CN104991756A (en) 2015-10-21

Similar Documents

Publication Publication Date Title
US20210004206A1 (en) Prepare for shorter precision (round for reround) mode in a decimal floating-point instruction
CN104732228B (en) A kind of detection of PDF document mess code, the method for correction
US9621496B2 (en) Correction of incoming messaging
CN103164426A (en) Method and device of recognizing named entity
CN105187420B (en) A kind of communications protocol matching process based on RS422 buses
DE102012208803A1 (en) System and method for forwarding Fiber Channel input and output data
CN103324612B (en) A kind of method of participle and device
CN101976148A (en) Hand input system and method
CN110909168A (en) Knowledge graph updating method and device, storage medium and electronic device
CN108363558A (en) Number of machines level data comparative approach towards big data processing
CN108959259B (en) New word discovery method and system
CN104991756B (en) A kind of floating data guard method of data link transmission process
CN109830272B (en) Data standardization method and device, computer equipment and storage medium
TW200613977A (en) Method to switch the lock-bits combination used to lock a page table entry upon receiving system reset exceptions
CN112949290B (en) Text error correction method and device and communication equipment
CN111832070B (en) Data masking method, device, electronic equipment and storage medium
CN108536693A (en) A kind of filtering sensitive words method, apparatus, electronic equipment, storage medium
CN105404527B (en) Interface allocation method and system based on SAP platform
CN110245332B (en) Chinese coding method and device based on bidirectional long-short-term memory network model
CN112966268A (en) SQL detection method and system based on neural network model and Hash matching
CN106598936A (en) Letter word extracting method and apparatus
CN103714055A (en) Method and device for automatically extracting bilingual dictionary from pictures
CN114328687B (en) Event extraction model training method and device and event extraction method and device
JP7268119B2 (en) Error correction method, device and electronic device for numeric content in text
CN116029284B (en) Chinese substring extraction method, chinese substring extraction system, storage medium and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant