WO2022051974A1 - Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium - Google Patents

Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium Download PDF

Info

Publication number
WO2022051974A1
WO2022051974A1 PCT/CN2020/114437 CN2020114437W WO2022051974A1 WO 2022051974 A1 WO2022051974 A1 WO 2022051974A1 CN 2020114437 W CN2020114437 W CN 2020114437W WO 2022051974 A1 WO2022051974 A1 WO 2022051974A1
Authority
WO
WIPO (PCT)
Prior art keywords
code
detected
preset
standard
scoring
Prior art date
Application number
PCT/CN2020/114437
Other languages
French (fr)
Chinese (zh)
Inventor
武泽泽
林喜挺
植俊铭
李诗豪
苏冠华
Original Assignee
深圳市大疆创新科技有限公司
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 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2020/114437 priority Critical patent/WO2022051974A1/en
Publication of WO2022051974A1 publication Critical patent/WO2022051974A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the invention belongs to the field of embedded platforms, and in particular relates to a code detection method, device, equipment and computer-readable storage medium applied to embedded platforms.
  • the controlled device is often controlled to perform a series of functional operations through programming codes.
  • programming codes For example, control unmanned vehicles for environmental detection through programming codes, control drones for aerial photography through programming codes, and so on.
  • control unmanned vehicles for environmental detection through programming codes For example, control drones for aerial photography through programming codes, and so on.
  • control code is often sent to the scoring system, and the scoring system performs detection directly according to the control code itself.
  • the accuracy of the detection results in this detection method is poor, and the detection effect is poor.
  • the present invention provides a code detection method, device, device and computer-readable storage medium applied to an embedded platform, so as to solve the problems of poor code detection result accuracy and poor detection effect.
  • an embodiment of the present invention provides a code detection method applied to an embedded platform, the method comprising:
  • the code-related data of the code to be detected is obtained as the code-related data to be detected;
  • the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
  • the overall score of the code to be detected is determined, and the code detection result is obtained.
  • an embodiment of the present invention provides a code detection apparatus applied to an embedded platform, the apparatus comprising a memory and a processor;
  • the memory for storing program codes
  • the processor calls the program code, and when the program code is executed, is configured to perform the following operations:
  • the code-related data of the code to be detected is obtained as the code-related data to be detected;
  • the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
  • the overall score of the code to be detected is determined, and the code detection result is obtained.
  • an embodiment of the present invention provides a detection device, where the detection device is configured to perform the steps in the code detection method applied to an embedded platform described in the first aspect.
  • an embodiment of the present invention provides an embedded hardware device, where the embedded hardware device is configured to run the code to be detected, and send the running result obtained from the running to the detection device described in the third aspect.
  • an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following operations are implemented:
  • the code-related data of the code to be detected is obtained as the code-related data to be detected;
  • the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
  • the overall score of the code to be detected is determined, and the code detection result is obtained.
  • the code-related data of the code to be detected may be acquired as the code-related data to be detected.
  • the data related to the code to be detected includes the running result to be detected, the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected, and the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected.
  • the overall score of get the code detection result.
  • the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
  • FIG. 1 is a flowchart of steps of a code detection method applied to an embedded platform provided by an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a scoring process provided by an embodiment of the present invention.
  • FIG. 3 is a block diagram of a code detection device applied to an embedded platform provided by an embodiment of the present invention.
  • FIG. 4 is a block diagram of a computing processing device according to an embodiment of the present invention.
  • FIG. 5 is a block diagram of a portable or fixed storage unit according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of steps of a code detection method applied to an embedded platform provided by an embodiment of the present invention. As shown in FIG. 1 , the method can be applied to a detection device, and the method includes:
  • Step 101 Obtain the code-related data of the code to be detected as the code-related data to be detected; the code-related data to be detected includes the running result to be detected, and the running result to be detected is an embedded hardware device according to the code to be detected Obtained by running the code to be detected, the running result to be detected includes output data of sensors in the embedded hardware device.
  • the code to be detected may be generated by a code generation device.
  • the code generation device may receive a user's programming input operation, and generate a corresponding code according to the user's programming input operation.
  • the programming language used when generating the code to be detected may be preset according to the actual situation, for example, it may be written based on the Scratch programming language, or may be based on the python programming language, the C++ programming language, and so on.
  • the code to be detected may be a code for controlling the embedded hardware device and for running on the embedded hardware device.
  • the embedded hardware device is the controlled device corresponding to the code to be detected.
  • the code-related data may be data related to the code to be detected.
  • the code-related data may include a code running result.
  • the code to be detected when the code to be detected is detected, the code to be detected can be executed according to the embedded hardware device first, and the operation result to be detected can be obtained according to the output data of the sensor in the embedded hardware device, so as to facilitate the subsequent execution according to the actual operation. As a result, the code is instrumented.
  • an evaluation server equipped with an online code scoring (Online Judge, OJ) system is often set up.
  • OJ online code scoring
  • the code is directly sent to the evaluation server.
  • the evaluation server compiles and runs the code
  • the OJ system Combined with running time, algorithm complexity, space complexity, memory usage, etc. for a comprehensive score. But this method can often only detect the code running and on the computer.
  • the target machine on which the code to be detected runs is different from the target machine (ie, the computer) on which the code runs in the prior art, the difference in hardware structure between the server and the embedded hardware device is relatively different. Large, the evaluation server cannot simulate the real running environment of the code. If the existing OJ system is directly used to detect the embedded hardware devices only from the aspects of memory usage and space complexity, it may lead to inaccurate detection results. That is, the code running on the embedded hardware device cannot be accurately scored by the OJ system in the evaluation server.
  • the embodiment of the present invention uses the code scoring method combining software and hardware to use the real embedded hardware device in the actual application scene to detect the code to be detected After running, the real output data of the sensor in the embedded hardware device is used as the running result to be detected, and the score is subsequently scored according to the real running result in the actual application scenario, which can improve the accuracy of the detection result and the detection effect to a certain extent.
  • Step 102 according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension.
  • the preset standard code may be a preset code that implements the same control function as the code to be detected. For example, assuming that the code to be detected is used to realize the function of controlling the unmanned vehicle to take pictures along the edge of the area to be detected, then the preset standard code can also be used to realize the function of controlling the unmanned vehicle to take pictures along the edge of the area to be detected.
  • the standard code-related data may be code-related data of preset standard codes, and the standard code-related data may be of the same type as the to-be-detected code-related data, so as to facilitate comparison and scoring according to the two.
  • the standard code related data may include a standard operation result
  • the standard operation result may be an operation result obtained by the embedded hardware device running the preset standard code.
  • the embedded hardware device running the preset standard code and the embedded hardware device running the code to be detected may be the same device, or may be different devices of the same type.
  • one of the embedded hardware devices can be a model A unmanned vehicle, the other embedded hardware device can be another model A unmanned vehicle, or two embedded hardware devices can be the same model A unmanned vehicle. people and vehicles, which is not limited in this embodiment of the present invention.
  • the preset scoring dimension may be set according to actual needs, and different dimensions may correspond to different evaluation criteria. By determining the scoring value to be detected under the preset scoring dimension from the preset scoring dimension, the detection can be refined to a certain extent. precision.
  • Step 103 Determine the overall score of the code to be detected according to the score value under the preset score dimension, and obtain a code detection result.
  • the scoring scores under each preset scoring dimension can be integrated, the code to be detected can be judged as a whole, the overall score of the code to be detected can be obtained, and the overall score can be used as the code detection result.
  • the code detection result can be quantitatively represented, thereby facilitating the user to know the detection result.
  • the code detection result can also be output, so as to facilitate the user to obtain the detection result in time.
  • the code detection method applied to an embedded platform can acquire code-related data of the code to be detected as the code-related data to be detected.
  • the data related to the code to be detected includes the running result to be detected
  • the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected
  • the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected.
  • the overall score of get the code detection result.
  • the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
  • the embedded hardware device in the embodiment of the present invention may be connected to the code generation device and the detection device, respectively.
  • the code generation device can be used to send the code to be detected to the embedded hardware device for running, and the embedded hardware device can send the obtained running result to be detected to the detection device after the running of the code to be detected is completed, that is, the running result to be detected It is sent to the detection device by the embedded hardware device after the execution of the code to be detected is completed.
  • the code generation device can be connected to the detection device, and the code generation device can be used to send other information in the data related to the code to be detected except the running result to be detected to the detection device.
  • the connection between the embedded hardware device, the code generation device and the detection device may be through a wireless local area network (Wireless-Fidelity, WIFI) connection, a Bluetooth connection, or a data line connection, and so on.
  • the code generation device may be a programming terminal, for example, a web terminal, an application (Application, APP) terminal, a client in a computer, and the like.
  • Embedded hardware devices can be embedded processors (Advanced RISC Machines, ARM) terminals, or other hardware platforms built by embedded systems, such as drones, unmanned vehicles, robots, and so on.
  • the detection device can be a computer, a tablet computer, a server, and the like.
  • the code to be detected is sent to the embedded hardware device to run through the code generation device, and the running result is sent through the embedded hardware device Testing the testing equipment can ensure the accuracy of the testing results to a certain extent.
  • the data related to the code to be detected may further include related information of modules used in the code to be detected.
  • the module may be a code block, specifically a method function called in the code, or may be other function modules preset in the programming language.
  • the programming modules built into the Scratch programming language a programming module can be used to implement a function.
  • determining the scoring value of the code to be detected under the preset scoring dimension may include the following steps:
  • Step 1021 Determine a first scoring value of the code to be tested under the first scoring dimension according to the running result to be detected and the standard running result in the data related to the standard code.
  • the first scoring dimension can represent the dimension of the running result item, and the running result item dimension can be used to detect the sensor output data when the code is running on the embedded hardware device. Because the sensor output data has a strong correlation with the running accuracy of embedded hardware devices. Therefore, the first scoring value of the code to be detected under the first scoring dimension can be determined, and the quality of the code to be detected under the dimension of the running result item can be more accurately represented by the first scoring score.
  • Step 1022 Determine the second scoring value of the code to be detected under the second scoring dimension according to the related information of the used module and the standard module information in the standard code related data.
  • the second scoring dimension can represent the program code item dimension, and the program code item dimension can be used to judge the code itself.
  • the standard module information can represent the relevant information of the modules used in the preset standard code. Because the modules used in the code often have a greater impact on the control functions implemented by the code. Therefore, in the embodiment of the present invention, the second scoring score is determined according to the used module, so that the second scoring score can more accurately characterize the quality of the code to be detected in the dimension of the program code item.
  • the second scoring dimension is further combined with the used module to judge, so as to improve the accuracy of the subsequently determined overall score to a certain extent.
  • the method of judging the situation of the code itself in combination with the module in the embodiment of the present invention can improve the accuracy. At the same time, it avoids the introduction of excessive computation, thereby ensuring the detection efficiency.
  • the standard module information may include relevant information of standard modules used in the preset standard code, and according to the relevant information of the used modules and the standard module information in the standard code-related data, it is determined to be detected.
  • the steps of coding the second scoring value under the second scoring dimension may include:
  • Sub-step (1) matching according to the relevant information of the used module and the relevant information of the standard module, to determine the first number of the first module matching the standard module in the used module, And/or, determining a second number of second modules whose used parameters in the first module match those of the standard module.
  • the relevant information may be information that can refer to the module, for example, the name, number, function of the module, the type it belongs to, and the parameters used, and so on.
  • the relevant information of the module can be entered through the configuration information.
  • that the used module matches the standard module may mean that the used module and the standard module are the same module, or the used module and the standard module are of the same type. Since modules of the same type often have the same function, taking the modules belonging to the same type as the judging benchmark, to a certain extent, it can avoid the problem that the second score is low in the subsequent determination, and ensure that the second score can be accurately represented. The actual situation.
  • the relevant information of the module used in the code to be detected can be compared with the relevant information of each standard module. If the relevant information of the two are the same, it can be considered that the used module is the first module that matches the standard module. a module. Further, for each first module, the parameters used in the first module can be compared with the use parameters of the standard module that matches the first module, and if the parameters are the same, it can be considered that the first module is completely parameterized. matching second module.
  • Sub-step (2) determine the second scoring value according to the first ratio and/or the second ratio; the first ratio is the ratio of the first quantity to the total quantity of the standard modules, the The second ratio is the ratio of the second amount to the first amount.
  • the ratio of the first quantity to the total quantity of standard modules may be calculated first to obtain the first ratio, and the ratio of the second quantity to the first quantity may be calculated to obtain the second ratio. Based on these two ratios, a second scoring score is determined. Wherein, the second scoring score may be positively correlated with the first ratio and the second ratio.
  • the second scoring value is determined in combination with the ratio calculated according to the first quantity and the second quantity, which can ensure the accuracy of the second scoring value to a certain extent.
  • the standard module information in this embodiment of the present invention may further include information about disabled modules that are prohibited from being used in the preset standard code. Accordingly, the second score is determined according to the first ratio and/or the second ratio. , which can include:
  • the first ratio and the second ratio may be input into the preset formula, and the output of the preset formula may be used as the first value.
  • the independent variable of the preset formula is positively correlated with the dependent variable.
  • the standard modules in this embodiment of the present invention may include key modules, recommended modules, and necessary modules.
  • the key module may be a module that must be used, and if it has been used, the score occupied by the pre-set key module will be obtained, and if it is not used, the score may be deducted accordingly.
  • Recommended modules can be optional modules. If you use it, you can add points. If you don't use it, you can not deduct points.
  • the prerequisite modules can be other modules in the standard modules except the recommended modules and the critical modules.
  • the first value may include a code block score and a code parameter score.
  • the code block score may include the key module score Section key , the recommendation module score Section recom and other module scores Section other
  • the code parameter score may include the score Sectio matched corresponding to the second module whose parameters are completely matched .
  • N key represents the number of key modules in the standard modules
  • N key_usr represents the number of modules used in the code to be detected that match the key modules
  • N std represents the total number of standard modules
  • N recom represents the number of recommended modules in the standard modules
  • N recom_usr represents the number of modules used in the code to be detected that match the standard modules
  • N matched represents the number of modules to be detected that match the standard modules.
  • code block score determined according to the first ratio can be expressed as:
  • Section other (N matched -N recom_usr -N key_usr )/N std *100.
  • N usr_match_num represents the second number of modules whose parameters are completely matched
  • N std_num represents the number of matched modules (ie, the first number)
  • the second ratio can be represented as: N usr_match_num /N std_num .
  • code parameter score can be expressed as:
  • the sum of the code parameter score and the code block score may be used as the first value.
  • the disabled module may be a module that is not allowed to be used.
  • the relevant information of the module used in the code to be detected can be compared with the relevant information of each forbidden module, if the relevant information of the two is the same, then it can be considered that the used module is the third one that matches the forbidden module. module.
  • N forbid represents the number of disabled modules
  • N forbid_usr is the number of disabled modules used in the code to be detected.
  • the disabled module score Section forbid may be calculated according to the third ratio N forbid_usr /N forbid . Decrease the first value according to Section forbid .
  • An example Section forbid can be specified as:
  • Section forbid -N forbid_usr /N forbid *(Section key +Section recom +Section other +Section matched ).
  • Section key , Section recom , Section other , and Section matched may also be weighted and summed according to preset weights, and then Section forbid is used to deduct points to obtain a final second scoring score.
  • the finally determined No. Two-score scores are more accurate.
  • the standard running result in the embodiment of the present invention may be the running result of the preset standard code running on the embedded hardware device, and the to-be-detected running result is determined according to the running result to be detected and the standard running result in the data related to the standard code.
  • the first scoring value of the code under the first scoring dimension which can include:
  • Sub-step (3) For any one of the sensors, according to the degree of matching between the change information of the output data in the operation result to be detected and the change information of the output data in the standard operation result, determine the score corresponding to the sensor. value; the score value corresponding to the sensor is positively correlated with the matching degree.
  • the sensors in the embodiments of the present invention may include motion-type sensors and non-motion-type sensors.
  • the motion-type sensor may include motion sensors whose output data are continuous numerical values, for example, a position sensor, an angle sensor, an acceleration sensor, a vision sensor, and the like.
  • the non-motion type sensor may be a sensor other than the motion type sensor, for example, a photosensitive sensor for outputting light-emitting/non-emitting state data, and the like.
  • the change information of the output data can be used to characterize the change process of the output data. If the matching degree of the change information is higher, that is, the control process of the embedded hardware device by the code to be detected and the control process of the embedded hardware device by the preset standard code. The control process is closer, and the code to be detected is more accurate in the control dimension of the sensor. Therefore, according to the matching degree, in the case of a higher matching degree, a higher score value corresponding to a sensor can be set.
  • Sub-step (4) Determine the first scoring value according to the scoring value corresponding to each of the sensors.
  • the sum or weighted sum of the corresponding scores of each sensor may be determined as the first score.
  • the degree of closeness between the to-be-detected operation result and the standard operation result can be more accurately reflected due to the matching degree of the change information of the output data in the to-be-detected operation result and the standard operation result. Therefore, in this embodiment of the present invention, the scoring value corresponding to each sensor is first determined according to the matching degree, and the first scoring value is determined according to the scoring value corresponding to the sensor, which can ensure the accuracy of the determined first scoring value to a certain extent.
  • the score may also be determined from other dimensions, for example, the running time, and the like.
  • the above sub-step (3) can be implemented by the following sub-steps:
  • the relative angle parameter value output at each moment can be determined first according to the angle parameter value output by the sensor and the initial angle parameter value; the output curve is generated according to the relative angle parameter value output at each moment; the output is sequentially obtained according to the time sequence Extreme points in the curve.
  • the initial angle parameter value can be the parameter angle value output by the sensor when the sensor is just started
  • the relative parameter angle value can be the parameter angle value output by the sensor, that is, the difference between the total motion value and the initial parameter angle value.
  • the relative parameter angle value can be used as the input of the preset fitting algorithm, and the curve fitted by the fitting algorithm can be used as the output curve.
  • the extreme points in the output curve can be detected sequentially in time sequence to form a change sequence of extreme points. In this way, by first determining the relative parameter angle value and obtaining the extreme point change sequence from the output curve determined by the relative parameter angle value, the extreme value point change sequence can be made more representative to a certain extent.
  • the parameter value when the sensor is an angle sensor, the parameter value may be the angle output by the angle sensor, when the sensor is a position sensor, the parameter value may be the position output by the position sensor, and when the sensor is an acceleration sensor, The parameter value can be the acceleration output by the acceleration sensor.
  • the extreme point in the output curve can be determined according to a preset peak detection algorithm.
  • the second-order derivative of the output curve can be determined by a peak detection algorithm, and the overall concave-convexity of the output curve function can be determined according to the second-order derivative, so as to obtain the inflection point of the output curve, that is, the extreme point.
  • the first derivative is then high-pass filtered to remove data bias due to sensor drift and fluctuation issues.
  • high-pass filtering can be expressed as:
  • the first derivative of the difference can be signed according to the following preset formula:
  • the difference vector can be re-derivative to obtain the second derivative.
  • ⁇ sensor n can be traversed.
  • the critical point that is, the migration process of the extreme point
  • the traversal result can be searched from the traversal result according to the following preset formula in time sequence.
  • N represents the number of data obtained by sampling the output curve, and an represents the found critical point.
  • an a n with a value of 0 in the searched result can be eliminated to obtain a migration chain, that is, a change sequence of extreme points.
  • the extreme point change sequence can be expressed as: maximum value --> minimum value --> minimum value --> maximum value, for example: 2-->-2-->-2-- >2.
  • the standard extreme point change sequence may be determined in advance according to the output data of the sensor in the standard operation result, and the specific determination method may refer to the implementation manner in the above steps, which is not repeated in this embodiment of the present invention.
  • the matched extremum points may be points with the same numerical value and the same relative temporal relationship as those in the standard extremum point change sequence.
  • the change sequence of extreme value points may be compared with the standard change sequence of extreme value points in time sequence, and then the extreme value points with the same numerical value and the same relative time sequence are determined as matching extreme value points. Assuming that the standard extreme point change sequence is: abcde, and the extreme point change sequence is: aced, then it can be determined that the matching extreme point is acd. Among them, the relative timing relationship between acd is the same as the relative timing relationship of "acd" in the standard extreme point change sequence abcde.
  • the embodiment of the present invention may first sort the output data of each sensor according to the execution order of each sensor. Then perform the above operations for each sensor separately, so as to avoid the confusion of the data of multiple sensors, thereby ensuring the accuracy of the final score.
  • the first length can represent the size of the same longest continuous chain, and L represents the first length, and the L mark represents the second length, and the L/L mark can be used as the third ratio P 1 .
  • the larger the third ratio the greater the matching degree.
  • *100% can also be calculated first, and correspondingly, 1- ⁇ is taken as P 1 .
  • the specific value of P anchor may be preset according to actual requirements, for example, P anchor may be 0.5.
  • the preset filtering algorithm may be an erosion and dilation algorithm in the morphological filtering method.
  • the open filter and the closed filter can be used to open and close the output data of the sensor to filter the local peaks and troughs in the sensor signal, thereby filtering the abnormal extreme points.
  • the specific values of the structural elements may be predetermined according to experiments.
  • erosion and dilation operations of x(n) with respect to g(m) can be defined as:
  • opening and closing operations consisting of erosion and dilation operations
  • the accuracy of the output data can be ensured, thereby improving the accuracy of the subsequent scores determined according to the output data.
  • the score corresponding to the sensor is determined according to the change sequence of the extreme point. While avoiding the introduction of a large amount of calculation, the scoring value can be determined according to the change information of the output data, thereby ensuring the calculation efficiency to a certain extent. At the same time, the score is determined by the size of the migration chain composed of the matched extreme points in the extreme point change sequence, which can ensure the accuracy of the score to a certain extent.
  • the above sub-step (3) can be implemented by the following sub-steps:
  • Sub-step (3E) Calculate the error value between the output value change sequence of the output data in the running result to be detected and the output value change sequence of the output data in the standard running result; the matching degree and the error value negative correlation.
  • the output value change sequence of the output data may be a sequence composed of output values, and the sequence may represent the transition chain formed by the anchor point value, and specifically may represent the state change process of the sensor. For example, sampling is performed in seconds, and the output value of the photosensitive sensor can be composed of a sequence of light-emitting-no light-emitting-no light-emitting-light-emitting, that is, the light-sensitive sensor emits light every one second.
  • a preset error algorithm can be used to input the two output value change sequences, for example, as the input of the standard error formula, and then the output is used as the error value.
  • the specific value of P sensor may be preset according to actual requirements, for example, P sensor may be 0.5.
  • the sum of all S anchors and all Ssensors may be determined as the first scoring score, or the sum of all S anchors and all S sensors may be calculated. The weighted sum of the time is obtained to obtain the first scoring score.
  • the error value can more accurately represent the matching degree, in the embodiment of the present invention, by first calculating the error value, and determining the score value corresponding to the sensor according to the error value, the accuracy of the score value can be ensured to a certain extent.
  • the error reporting information may be determined according to data that does not match the standard code-related data in the running result to be detected, and the error reporting information may be output.
  • the anchor value of the sensor can be detected, the unmatched anchor value can be determined, the corresponding preset prompt information can be retrieved, and finally an error report indicating the unmatched anchor value can be output according to the preset prompt information.
  • information For example, "The output value of the sensor: XXX has a problem" can be output. In this way, the user can obtain the problem in time by outputting the error message, thereby facilitating the user to make adjustments.
  • the error message can also be determined according to other static code data other than the running result.
  • the identifier of the disabled module used in the code to be detected can be obtained, and then the error message indicating the disabled module used in the code to be detected is output.
  • the error message indicating the disabled module used in the code to be detected is output.
  • "The following disabled modules exist: YYY, please adjust" can be output.
  • the data related to the code to be detected in the embodiment of the present invention may further include programming parameters of the code to be detected, where the programming parameter may include the programming duration and/or the number of times of debugging of the code to be detected.
  • the step of determining the scoring value of the code to be detected under the preset scoring dimension may also include the following steps:
  • Step 1023 Determine a third scoring value of the code to be detected under a third scoring dimension according to the programming parameter; wherein, the smaller the programming parameter is, the larger the third scoring value is.
  • the third scoring dimension can represent the dimension of writing and debugging items, and the dimension of writing and debugging items can be used to judge from the situation of writing and debugging during code generation. If the writing time is shorter and the number of debugging times is less, the quality of the code can be considered to be higher to a certain extent. Therefore, in this step, when the programming parameter is smaller, a larger third scoring value can be set.
  • the judgment is further combined with programming parameters from the third scoring dimension, thereby improving the accuracy of the overall score determined subsequently to a certain extent.
  • the code to be tested is a plurality of codes to be tested submitted by multiple users.
  • the third scoring value of the code to be tested under the third scoring dimension is determined, which may include:
  • Sub-step (4) for any of the programming parameters, according to the size of the programming parameters, the plurality of codes to be detected are divided into different code levels; wherein, the higher the code level, the corresponding code level. The smaller the programming parameters of the code to be detected.
  • the codes to be detected may be sorted according to the size of the programming parameters, and then the code levels may be divided according to the sorting result. It should be noted that, when the programming parameters of the codes to be detected have the same size, the sequence of the codes to be detected may be determined according to the name or identification (Identity, ID) of the user corresponding to the codes to be detected. For example, the code to be detected with a larger ID is placed at a higher position.
  • the top 10% of the codes to be detected in the sorting result can be divided into code level A, and the top 11%-40% of the sorting results can be classified into code level A.
  • the code to be detected is divided into code level B, the first 41% to 80% of the code to be detected in the sorting result is divided into code level C, and the first 81% to 100% of the code to be detected in the sorting result, that is, the last 10 % of the codes to be detected are assigned to code level D.
  • the top 10% of the code to be detected in the sorting result can be divided into code level A, and the top 11%-20% of the sorting result can be divided into code level A.
  • the code to be detected is divided into code grade B, the first 21% to 70% of the code to be detected in the sorting result is divided into code grade C, the first 71% to 100% of the code to be detected in the sorting result, that is, the last 30 % of the codes to be detected are assigned to code level D.
  • the grades of code grade A, code grade B, code grade C, and code grade D are successively reduced, and the corresponding ratio of each code grade can be defined in the preset programming parameter grade mapping table, and the corresponding ratio of each code grade can be based on actual Requirement settings.
  • Sub-step (5) for any code to be detected, according to the code level corresponding to the code to be detected, determine the score corresponding to the programming parameter; the score corresponding to the programming parameter is positive with the code level. related.
  • the value corresponding to the code level corresponding to the code to be detected may be determined as the score corresponding to the programming parameter.
  • Sub-step (6) Determine the third scoring score according to the score corresponding to the programming parameter.
  • a weighted sum between the scores corresponding to each programming parameter may be calculated to obtain a third score.
  • the weight ratio corresponding to each programming parameter can be set according to actual requirements.
  • the weight ratio corresponding to the writing time and the number of debugging times can be 0.5 respectively, that is, the writing time and the number of debugging times each account for 50% of the score of the debugging item.
  • the data related to the code to be detected may further include the code length of the code to be detected; according to the size of the programming parameter, before dividing a plurality of codes to be detected into different code levels, it is also possible to: determine the length of the code to be detected. Whether the code length meets the preset length requirement; if the code length does not meet the preset length requirement and the number of the used key modules is the preset number, then the first preset value is determined as the third Scoring score; if the code length meets the preset length requirement and/or the number of key modules used is not the preset number, then execute the described programming parameters according to the size of the Describe the steps of dividing a plurality of codes to be detected into different code levels.
  • the preset length requirement and the preset number may be set according to actual requirements.
  • L reference represents the preset length threshold
  • L represents the code length of the code to be detected
  • the preset length requirement may be (L reference - L)/L reference greater than 50%
  • the preset number may be 0.
  • the to-be-detected code can be divided into codes of the first category.
  • the first category can be used to characterize code submitted by malicious users.
  • the subsequent operation of classifying the code to be detected into different code levels may not be performed, that is, the second scoring value of the malicious code is directly set to 0 points.
  • the code length meets the preset length requirement and/or the used key module is not 0, it can be considered that the code to be detected is not malicious code, therefore, the operation of classifying the code to be detected into different code levels can be performed.
  • the code length and the number of key modules used in the code it is determined whether to perform the step of dividing multiple codes to be detected into different code levels according to the size of the programming parameters, which can avoid unnecessary execution of malicious code. operation, which can save processing resources.
  • sub-step (5) can be realized by the following sub-steps:
  • the number of used key modules can be the same as the number of key modules in the standard modules, and the number of disabled modules can be 0, that is, the disabled modules are not used and the matching degree between the running result to be detected and the standard running result satisfies the predetermined It is assumed that the required codes to be detected are classified into codes of the second category.
  • the second category can be used to represent the basic function completion category, and the matching degree meeting the preset requirement can be that the output result of the sensor trajectory comparison method for the operation result to be detected and the standard operation result satisfies the first preset condition, for example, the output result
  • the anchor point feature value comparison method satisfies the second preset condition for the output result of the running result to be detected and the standard running result, for example, the output result is a matching degree of 100 points.
  • the code to be detected can be divided into a third category, and the third category can be used to represent the basic function incomplete category.
  • the corresponding relationship between the preset level and the score may be set according to the actual situation, and the corresponding relationship between the preset level and the score may be a mapping table between the code level and the score.
  • the score corresponding to code level A may be 100
  • the score corresponding to code level B may be 90
  • the score corresponding to code level C may be 80
  • the score corresponding to code level D may be 70
  • the score corresponding to code level A may be 75
  • the score corresponding to code level B may be 65
  • the score corresponding to code level C may be 55.
  • the score corresponding to code level D may be 45.
  • the corresponding relationship between the preset level and the score corresponding to the category may be obtained first, and then the score corresponding to the code level corresponding to the code to be detected is searched from the preset level and the score.
  • the categories of the code to be detected are further subdivided into different categories Setting the corresponding relationship between different levels and scores, and searching for the score corresponding to the code to be detected according to the category of the code to be detected, can make the found score closer to the actual situation, thereby improving the score to a certain extent. accuracy.
  • the data related to the code to be tested may also include basic configuration information of the code to be tested. Accordingly, according to the related data of the code to be tested and the standard code related data of the preset standard code, it is determined that the code to be tested is under the preset scoring dimension.
  • the step of scoring the score value can also include the following steps:
  • Step 1024 Determine the number of preset basic configuration conditions that are satisfied by the code to be detected according to the basic configuration information and the preset basic configuration conditions defined in the standard code related data.
  • the preset basic configuration conditions may be set according to actual conditions.
  • the preset basic configuration conditions may include at least one of the following: successfully establishing a connection with the embedded hardware device in the process of generating the code to be tested, successfully submitting the code to be tested to the testing device, and successfully downloading the code to be tested to the embedded hardware device. It has run and verified the code to be tested. In this way, by setting the configuration condition that needs to be satisfied for normal code detection as the preset basic configuration condition, the accuracy of the subsequent fourth scoring value determined based on the preset basic configuration condition can be ensured to a certain extent.
  • the basic configuration information can be used to represent the basic configuration when the code to be detected is generated.
  • the basic configuration information may include information representing whether the code to be tested is successfully connected to the embedded hardware device, information representing whether the code to be tested has been successfully submitted to the testing device, and whether the code to be tested has been successfully downloaded to the embedded hardware Information about whether the hardware device and embedded hardware device have performed the operation and verification operation of the code to be tested.
  • it can be determined whether the code to be detected satisfies the preset basic configuration condition according to the basic configuration information. Finally, the total number of preset basic configuration conditions satisfied by the code to be detected is counted.
  • Step 1025 Determine a fourth scoring value of the code to be detected under the fourth scoring dimension according to the number; wherein, the fourth scoring value is positively correlated with the number.
  • the fourth scoring dimension can represent the basic item dimension, and the basic item dimension can be used to judge from the basic configuration at the time of code generation. If the number of satisfied preset basic configuration conditions is greater, it can be considered that the configuration of the code to be detected is better, and accordingly, a higher fourth score can be set. In the embodiment of the present invention, by further combining with the basic configuration, the judgment is made from the fourth scoring dimension, thereby improving the accuracy of the overall score determined subsequently to a certain extent.
  • the second preset value is set as the fourth scoring value; if the number matches the total number of preset basic configuration conditions If the total number does not match, the third preset value is set as the fourth score value; the second preset value is greater than the third preset value.
  • the second preset value and the third preset value may be set according to actual requirements. For example, the second preset value may be 100, and the third preset value may be 0. That is, if any of the preset basic configuration conditions are not satisfied, the fourth score is set to 0, and when all the preset basic configuration conditions are satisfied, the fourth score is set to 100.
  • the embodiment selects the second preset value or the third preset value as the fourth scoring value according to the number, to a certain extent, it can avoid that the final overall score of the code to be detected in the malicious test is too large, and the final code to be detected in the normal test is not detected. The overall score is too small, so as to ensure the balance of the overall score determined later.
  • determining the overall score of the code to be detected according to the scoring score under the preset scoring dimension may specifically include: calculating the scoring score under each preset scoring dimension according to the dimension weight corresponding to each preset scoring dimension. The weighted sum of , and then the overall score is obtained.
  • the dimension weight corresponding to each preset scoring dimension may be defined through a weight ratio table, and the specific value of the dimension weight may be set according to actual requirements.
  • the dimension weight corresponding to the first scoring dimension may be 40%
  • the dimension weight corresponding to the second scoring dimension may be 30%
  • the dimension weight corresponding to the third scoring dimension may be 20%
  • the dimension weight corresponding to the fourth scoring dimension Can be 10%.
  • FIG. 2 is a schematic diagram of a scoring process provided by an embodiment of the present invention.
  • a standard user can send a preset standard code to a robot platform for running through a Scratch programming terminal in advance.
  • the operation of the robot platform can capture the operation results and obtain the standard operation results of the preset standard code.
  • the static code data of the preset standard code and the standard operation result may be submitted to the scoring system as standard code related data.
  • the static code data of the preset standard code may include standard module information, related information of prohibited modules that are prohibited from being used, preset basic configuration conditions, and preset detection configuration information.
  • the configuration information may include preset values, preset mapping tables, preset weights, and the like involved in the preceding steps.
  • the user to be tested can send the code to be tested to the robot platform to run through the Scratch programming terminal.
  • the operation of the robot platform can capture the operation results and obtain the operation results to be detected.
  • the static code data of the code to be tested and the running result of the code to be tested may be submitted to the scoring system as data related to the code to be tested.
  • the Scratch programming terminal can be the assessment machine
  • the robot platform can be the external hardware in the scene.
  • the specific hardware type can be set according to the actual needs to ensure that the requirements of different assessment scenarios are met.
  • the static code data of the code to be tested may include related information of modules used in the code to be tested, programming parameters of the code to be tested, code length of the code to be tested, basic configuration information of the code to be tested, and so on.
  • the scoring system may be a system mounted on the detection device for performing each step in the embodiment of the present invention, the scoring system may be an online system, and the detection device may be an online server, that is, the data participating in the detection may be online data. Finally, the scoring system can generate code detection results based on the data related to the code to be tested and the data related to the standard code.
  • the same detection standard is used for different codes to be detected, which can ensure the accuracy of code detection.
  • the detection results can be more suitable for real application scenarios, and the accuracy of code detection can be further improved.
  • FIG. 3 is a block diagram of a code detection apparatus applied to an embedded platform provided by an embodiment of the present invention.
  • the apparatus may include: a memory 301 and a processor 302 .
  • the memory 301 is used to store program codes.
  • the processor 302 calls the program code, and when the program code is executed, is configured to perform the following operations:
  • the code-related data of the code to be detected is obtained as the code-related data to be detected;
  • the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
  • the overall score of the code to be detected is determined, and the code detection result is obtained.
  • the code detection apparatus applied to the embedded platform can acquire the code related data of the code to be detected as the code related data to be detected.
  • the data related to the code to be detected includes the running result to be detected
  • the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected
  • the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected.
  • the overall score of get the code detection result.
  • the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
  • an embodiment of the present invention further provides a detection device, and the detection device is configured to perform the steps in the above embodiments of the code detection method applied to an embedded platform.
  • An embodiment of the present invention further provides an embedded hardware device, the embedded hardware device is used for running the code to be detected, and sending the running result obtained from the running to the above-mentioned detection device.
  • the embedded hardware device is one or more of drones, unmanned vehicles, and robots.
  • an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the above-mentioned code detection method applied to an embedded platform is implemented and can achieve the same technical effect, in order to avoid repetition, it will not be repeated here.
  • the device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
  • Various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof.
  • a microprocessor or a digital signal processor may be used in practice to implement some or all of the functions of some or all of the components in the computing processing device according to the embodiments of the present invention.
  • the present invention can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing part or all of the methods described herein.
  • Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet sites, or provided on carrier signals, or in any other form.
  • FIG. 4 is a block diagram of a computing processing device provided by an embodiment of the present invention. As shown in FIG. 4 , FIG. 4 shows a computing processing device that can implement the method according to the present invention.
  • the computing processing device traditionally includes a processor 710 and a computer program product or computer readable medium in the form of a memory 720 .
  • the memory 720 may be electronic memory such as flash memory, EEPROM (electrically erasable programmable read only memory), EPROM, hard disk, or ROM.
  • the memory 720 has storage space 730 for program code for performing any of the method steps in the above-described methods.
  • the storage space 730 for program codes may include various program codes for implementing various steps in the above methods, respectively.
  • These program codes can be read from or written to one or more computer program products.
  • These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such computer program products are typically portable or fixed storage units as described with reference to FIG. 5 .
  • the storage unit may have storage segments, storage spaces, etc. arranged similarly to the memory 720 in the computing processing device of FIG. 4 .
  • the program code may, for example, be compressed in a suitable form.
  • the storage unit includes computer readable code, ie code readable by a processor such as 710 for example, which when executed by a computing processing device, causes the computing processing device to perform each of the methods described above. step.
  • references herein to "one embodiment,” “an embodiment,” or “one or more embodiments” means that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of the present invention. Also, please note that instances of the phrase “in one embodiment” herein are not necessarily all referring to the same embodiment.
  • any reference signs placed between parentheses shall not be construed as limiting the claim.
  • the word “comprising” does not exclude the presence of elements or steps not listed in a claim.
  • the word “a” or “an” preceding an element does not exclude the presence of a plurality of such elements.
  • the invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware.
  • the use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Arrangements For Transmission Of Measured Signals (AREA)

Abstract

A code inspection method and apparatus applied to an embedded platform, a device and a computer-readable storage medium. The method comprises: acquiring code related data of a code to be inspected as code related data to be inspected, the code related data to be inspected comprising a running result to be inspected which is obtained by running, according to an embedded hardware device of the code to be inspected, the code to be inspected, and which comprises output data of a sensor in the embedded hardware device; according to the code related data to be inspected and standard code related data of a preset standard code, determining a score of the code to be inspected under a preset scoring dimension; and according to the score under the preset scoring dimension, determining the overall score of the code to be inspected to obtain a code inspection result. In this way, scoring is performed according to a real running result in an actual application scene, thereby improving the accuracy of the inspection result to a certain extent and improving inspection effect.

Description

应用于嵌入式平台的代码检测方法、装置、设备及计算机可读存储介质Code detection method, device, device and computer-readable storage medium applied to embedded platform 技术领域technical field
本发明属于嵌入式平台领域,特别是涉及一种应用于嵌入式平台的代码检测方法、装置、设备及计算机可读存储介质。The invention belongs to the field of embedded platforms, and in particular relates to a code detection method, device, equipment and computer-readable storage medium applied to embedded platforms.
背景技术Background technique
目前,经常会通过编程代码,控制被控设备执行一系列的功能操作。例如,通过编程代码控制无人车进行环境探测,通过编程代码控制无人机进行航拍,等等。为了提高控制效果,往往需要对控制代码进行质量检测。At present, the controlled device is often controlled to perform a series of functional operations through programming codes. For example, control unmanned vehicles for environmental detection through programming codes, control drones for aerial photography through programming codes, and so on. In order to improve the control effect, it is often necessary to perform quality inspection on the control code.
现有技术中,往往是将控制代码发送给评分系统,由评分系统直接根据控制代码本身进行检测。这种检测方式中检测结果的准确性较差,检测效果较差。In the prior art, the control code is often sent to the scoring system, and the scoring system performs detection directly according to the control code itself. The accuracy of the detection results in this detection method is poor, and the detection effect is poor.
发明内容SUMMARY OF THE INVENTION
本发明提供一种应用于嵌入式平台的代码检测方法、装置、设备及计算机可读存储介质,以便解决代码检测结果的准确性较差,检测效果较差的问题。The present invention provides a code detection method, device, device and computer-readable storage medium applied to an embedded platform, so as to solve the problems of poor code detection result accuracy and poor detection effect.
为了解决上述技术问题,本发明是这样实现的:In order to solve the above-mentioned technical problems, the present invention is achieved in this way:
第一方面,本发明实施例提供了一种应用于嵌入式平台的代码检测方法,该方法包括:In a first aspect, an embodiment of the present invention provides a code detection method applied to an embedded platform, the method comprising:
获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
第二方面,本发明实施例提供了一种应用于嵌入式平台的代码检测装置,所述装置包括存储器和处理器;In a second aspect, an embodiment of the present invention provides a code detection apparatus applied to an embedded platform, the apparatus comprising a memory and a processor;
所述存储器,用于存储程序代码;the memory for storing program codes;
所述处理器,调用所述程序代码,当所述程序代码被执行时,用于执行以下操作:The processor calls the program code, and when the program code is executed, is configured to perform the following operations:
获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
第三方面,本发明实施例提供了一种检测设备,所述检测设备用于执行第一方面中所述的应用于嵌入式平台的代码检测方法中的步骤。In a third aspect, an embodiment of the present invention provides a detection device, where the detection device is configured to perform the steps in the code detection method applied to an embedded platform described in the first aspect.
第四方面,本发明实施例提供了一种嵌入式硬件设备,所述嵌入式硬件设备用于对待检测代码运行,并将运行得到的运行结果发送给第三方面中所述的检测设备。In a fourth aspect, an embodiment of the present invention provides an embedded hardware device, where the embedded hardware device is configured to run the code to be detected, and send the running result obtained from the running to the detection device described in the third aspect.
第四方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现以下操作:In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following operations are implemented:
获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检 测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
在本发明实施例中,可以获取待检测代码的代码相关数据,作为待检测代码相关数据。其中,待检测代码相关数据包括待检测运行结果,待检测运行结果是根据待检测代码的嵌入式硬件设备对待检测代码运行得到的,待检测运行结果包括嵌入式硬件设备中传感器的输出数据,接着,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值,最后,根据预设评分维度下的评分分值,确定待检测代码的整体分值,得到代码检测结果。这样,由实际应用场景中真实的嵌入式硬件设备对待检测代码运行得到真实的运行结果,并根据实际应用场景中真实的运行结果进行评分,进而一定程度上可以提高检测结果的准确性,提高检测效果。In this embodiment of the present invention, the code-related data of the code to be detected may be acquired as the code-related data to be detected. The data related to the code to be detected includes the running result to be detected, the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected, and the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected. The overall score of , get the code detection result. In this way, the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
附图说明Description of drawings
图1是本发明实施例提供的一种应用于嵌入式平台的代码检测方法的步骤流程图;1 is a flowchart of steps of a code detection method applied to an embedded platform provided by an embodiment of the present invention;
图2是本发明实施例提供的一种评分流程示意图;2 is a schematic diagram of a scoring process provided by an embodiment of the present invention;
图3是本发明实施例提供的一种应用于嵌入式平台的代码检测装置的框图;3 is a block diagram of a code detection device applied to an embedded platform provided by an embodiment of the present invention;
图4为本发明实施例提供的一种计算处理设备的框图;FIG. 4 is a block diagram of a computing processing device according to an embodiment of the present invention;
图5为本发明实施例提供的一种便携式或者固定存储单元的框图。FIG. 5 is a block diagram of a portable or fixed storage unit according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
图1是本发明实施例提供的一种应用于嵌入式平台的代码检测方法的步骤流程图,如图1所示,该方法可以应用于检测设备,所述方法包括:1 is a flowchart of steps of a code detection method applied to an embedded platform provided by an embodiment of the present invention. As shown in FIG. 1 , the method can be applied to a detection device, and the method includes:
步骤101、获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据。Step 101: Obtain the code-related data of the code to be detected as the code-related data to be detected; the code-related data to be detected includes the running result to be detected, and the running result to be detected is an embedded hardware device according to the code to be detected Obtained by running the code to be detected, the running result to be detected includes output data of sensors in the embedded hardware device.
本发明实施例中,待检测代码可以是通过代码生成设备生成的,例如,代码生成设备可以接收用户的编程输入操作,根据用户的编程输入操作生成对应的代码。生成待检测代码时采用的编程语言可以是根据实际情况预先设置的,例如,可以是基于Scratch编程语言编写的,也可以是基于python编程语言、C++编程语言,等等。进一步地,待检测代码可以是用于控制嵌入式硬件设备,用于在嵌入式硬件设备上运行的代码。其中,嵌入式硬件设备即为待检测代码对应的被控设备。In this embodiment of the present invention, the code to be detected may be generated by a code generation device. For example, the code generation device may receive a user's programming input operation, and generate a corresponding code according to the user's programming input operation. The programming language used when generating the code to be detected may be preset according to the actual situation, for example, it may be written based on the Scratch programming language, or may be based on the python programming language, the C++ programming language, and so on. Further, the code to be detected may be a code for controlling the embedded hardware device and for running on the embedded hardware device. The embedded hardware device is the controlled device corresponding to the code to be detected.
进一步地,代码相关数据可以是与待检测代码有关的数据,示例的,代码相关数据可以包括代码运行结果。相应地,本发明实施例中对待检测代码进行检测时,可以先根据嵌入式硬件设备对待检测代码运行,根据嵌入式硬件设备中传感器的输出数据获取待检测运行结果,以便于后续根据真实的运行结果对代码进行检测。Further, the code-related data may be data related to the code to be detected. For example, the code-related data may include a code running result. Correspondingly, in the embodiment of the present invention, when the code to be detected is detected, the code to be detected can be executed according to the embedded hardware device first, and the operation result to be detected can be obtained according to the output data of the sensor in the embedded hardware device, so as to facilitate the subsequent execution according to the actual operation. As a result, the code is instrumented.
在一种实现方式中,往往是设置搭载有在线代码评分(OnlineJudge,OJ)系统的测评服务器,对代码进行检测时,将代码直接发送给测评服务器,由测评服务器对代码编译运行后,OJ系统结合运行时间、算法复杂度,空间复杂度、内存使用情况等进行综合评分。但是这种方式 往往仅能针对运行与计算机上的代码进行检测。而针对用于控制嵌入式硬件设备的待检测代码,由于待检测代码运行的目标机与现有方式中代码运行的目标机(即,计算机)不同,服务器与嵌入式硬件设备的硬件结构差异较大,测评服务器无法模拟代码的真实运行环境。如果直接采用现有OJ系统对用于控制嵌入式硬件设备仅从内存使用情况、空间复杂度等方面进行检测,可能会导致检测结果不够准确。即,通过测评服务器中的OJ系统无法准确的对运行于嵌入式硬件设备的代码进行评分。In one implementation, an evaluation server equipped with an online code scoring (Online Judge, OJ) system is often set up. When testing the code, the code is directly sent to the evaluation server. After the evaluation server compiles and runs the code, the OJ system Combined with running time, algorithm complexity, space complexity, memory usage, etc. for a comprehensive score. But this method can often only detect the code running and on the computer. For the code to be detected for controlling the embedded hardware device, since the target machine on which the code to be detected runs is different from the target machine (ie, the computer) on which the code runs in the prior art, the difference in hardware structure between the server and the embedded hardware device is relatively different. Large, the evaluation server cannot simulate the real running environment of the code. If the existing OJ system is directly used to detect the embedded hardware devices only from the aspects of memory usage and space complexity, it may lead to inaccurate detection results. That is, the code running on the embedded hardware device cannot be accurately scored by the OJ system in the evaluation server.
在用于控制嵌入式硬件设备的代码的检测场景中,为了确保代码检测的准确性,本发明实施例通过软硬件结合的代码评分方式,由实际应用场景中真实的嵌入式硬件设备对待检测代码运行后,将嵌入式硬件设备中传感器的真实输出数据作为待检测运行结果,后续根据实际应用场景中的真实运行结果进行评分,进而一定程度上可以提高检测结果的准确性,提高检测效果。In the detection scene of the code used to control the embedded hardware device, in order to ensure the accuracy of the code detection, the embodiment of the present invention uses the code scoring method combining software and hardware to use the real embedded hardware device in the actual application scene to detect the code to be detected After running, the real output data of the sensor in the embedded hardware device is used as the running result to be detected, and the score is subsequently scored according to the real running result in the actual application scenario, which can improve the accuracy of the detection result and the detection effect to a certain extent.
步骤102、根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值。 Step 102 , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension.
本发明实施例中,预设标准代码可以是预先设置的与待检测代码实现相同控制功能的代码。示例的,假设待检测代码用于实现控制无人车沿着待检测区域的边缘进行拍照的功能,那么预设标准代码也可以用于实现控制无人车沿着待检测区域的边缘进行拍照的功能。标准代码相关数据可以是预设标准代码的代码相关数据,标准代码相关数据可以与待检测代码相关数据的种类相同,以方便根据两者进行比对评分。示例的,标准代码相关数据可以包括标准运行结果,该标准运行结果可以是嵌入式硬件设备对预设标准代码进行运行得到的运行结果。需要说明的是,对预设标准代码运行的嵌入式硬件设备可以与对待检测代码运行的嵌入式硬件设备为同一台设备,也可以为类型相同的不同设备。例如,其中一个嵌入式硬件设备可以是一台A型号的无人车,另一个嵌入式硬件设备是另一台A型号的无人车,或者两个嵌入式硬件设备为同一台A型号的无人车,本发明实施例对此不作限定。In this embodiment of the present invention, the preset standard code may be a preset code that implements the same control function as the code to be detected. For example, assuming that the code to be detected is used to realize the function of controlling the unmanned vehicle to take pictures along the edge of the area to be detected, then the preset standard code can also be used to realize the function of controlling the unmanned vehicle to take pictures along the edge of the area to be detected. Function. The standard code-related data may be code-related data of preset standard codes, and the standard code-related data may be of the same type as the to-be-detected code-related data, so as to facilitate comparison and scoring according to the two. For example, the standard code related data may include a standard operation result, and the standard operation result may be an operation result obtained by the embedded hardware device running the preset standard code. It should be noted that the embedded hardware device running the preset standard code and the embedded hardware device running the code to be detected may be the same device, or may be different devices of the same type. For example, one of the embedded hardware devices can be a model A unmanned vehicle, the other embedded hardware device can be another model A unmanned vehicle, or two embedded hardware devices can be the same model A unmanned vehicle. people and vehicles, which is not limited in this embodiment of the present invention.
进一步地,预设评分维度可以是根据实际需求设置,不同维度可以对应不同的评判标准,通过从预设评分维度确定待检测在预设评分维度下的评分分值,一定程度上可以细化检测精度。Further, the preset scoring dimension may be set according to actual needs, and different dimensions may correspond to different evaluation criteria. By determining the scoring value to be detected under the preset scoring dimension from the preset scoring dimension, the detection can be refined to a certain extent. precision.
步骤103、根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。Step 103: Determine the overall score of the code to be detected according to the score value under the preset score dimension, and obtain a code detection result.
本发明实施例中,可以综合各个预设评分维度下的评分分值,对待检测代码进行整体评判,获取待检测代码的整体分值,将整体分值作为代码检测结果。这样,以最终得到的整体分值作为代码检测结果,可以使得代码检测结果被量化表征,进而方便用户获知检测结果。进一步地,还可以输出代码检测结果,以方便用户及时获取到检测结果。In the embodiment of the present invention, the scoring scores under each preset scoring dimension can be integrated, the code to be detected can be judged as a whole, the overall score of the code to be detected can be obtained, and the overall score can be used as the code detection result. In this way, using the final overall score as the code detection result, the code detection result can be quantitatively represented, thereby facilitating the user to know the detection result. Further, the code detection result can also be output, so as to facilitate the user to obtain the detection result in time.
综上所述,本发明实施例提供的应用于嵌入式平台的代码检测方法,可以获取待检测代码的代码相关数据,作为待检测代码相关数据。其中,待检测代码相关数据包括待检测运行结果,待检测运行结果是根据待检测代码的嵌入式硬件设备对待检测代码运行得到的,待检测运行结果包括嵌入式硬件设备中传感器的输出数据,接着,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值,最后,根据预设评分维度下的评分分值,确定待检测代码的整体分值,得到代码检测结果。这样,由实际应用场景中真实的嵌入式硬件设备对待检测代码运行得到真实的运行结果,并根据实际应用场景中真实的运行结果进行评分,进而一定程度上可以提高检测结果的准确性,提高检测效果。To sum up, the code detection method applied to an embedded platform provided by the embodiments of the present invention can acquire code-related data of the code to be detected as the code-related data to be detected. The data related to the code to be detected includes the running result to be detected, the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected, and the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected. The overall score of , get the code detection result. In this way, the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
可选的,本发明实施例中的嵌入式硬件设备可以分别与代码生成设备及检测设备连接。其中,代码生成设备可以用于将待检测代码发送至嵌入式硬件设备运行,嵌入式硬件设备可以对待检测代码运行结束后可以将得到的待检测运行结果发送给检测设备,即,待检测运行结果是嵌入式硬件设备对待检测代码运行结束后,发送给检测设备的。进一步地,代码生成设备可以与检测设备连接,代码生成设备可以用于将待检测代码相关数据中除待检测运行结果之外的其他信息,发送给检测设备。Optionally, the embedded hardware device in the embodiment of the present invention may be connected to the code generation device and the detection device, respectively. The code generation device can be used to send the code to be detected to the embedded hardware device for running, and the embedded hardware device can send the obtained running result to be detected to the detection device after the running of the code to be detected is completed, that is, the running result to be detected It is sent to the detection device by the embedded hardware device after the execution of the code to be detected is completed. Further, the code generation device can be connected to the detection device, and the code generation device can be used to send other information in the data related to the code to be detected except the running result to be detected to the detection device.
具体的,嵌入式硬件设备、代码生成设备及检测设备连接之间可以是通过无线局域网(Wireless-Fidelity,WIFI)连接、蓝牙连接、或者是数据线连接,等等。代码生成设备可以为编程终端,例如,网页端、应用程序(Application,APP)终端、计算机中的客户端,等等。嵌入式硬件设备可以为嵌入式处理器(Advanced RISC Machines,ARM)终端,或其他由嵌入式系统构建的硬件平台,例如,无人机、无人车、机器人,等等。检测设备可以为计算机、平板电脑、服务器等等。本发明实施例中,通过设置嵌入式硬件设备、代码生成设备及检测设备之间互相连接配合,通过代码生成设备将待检测代码发送给嵌入式硬件设备运行,通过嵌入式硬件设备将运行结果发送给检测设备进行检测,一定程度上可以确保检测结果的准确性。Specifically, the connection between the embedded hardware device, the code generation device and the detection device may be through a wireless local area network (Wireless-Fidelity, WIFI) connection, a Bluetooth connection, or a data line connection, and so on. The code generation device may be a programming terminal, for example, a web terminal, an application (Application, APP) terminal, a client in a computer, and the like. Embedded hardware devices can be embedded processors (Advanced RISC Machines, ARM) terminals, or other hardware platforms built by embedded systems, such as drones, unmanned vehicles, robots, and so on. The detection device can be a computer, a tablet computer, a server, and the like. In the embodiment of the present invention, by setting the embedded hardware device, the code generation device and the detection device to connect and cooperate with each other, the code to be detected is sent to the embedded hardware device to run through the code generation device, and the running result is sent through the embedded hardware device Testing the testing equipment can ensure the accuracy of the testing results to a certain extent.
可选的,本发明实施例中,待检测代码相关数据还可以包括待检测代码中所使用模块的相关信息。其中,模块可以是一个代码块,具体可以为代码中调用的方法函数,或者,也可以是编程语言中预设的其他功能模块。例如,Scratch编程语言中内置的编程模块,一个编程模块可以用于实现一个功能。相应地,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值,可以包括下述步骤:Optionally, in this embodiment of the present invention, the data related to the code to be detected may further include related information of modules used in the code to be detected. The module may be a code block, specifically a method function called in the code, or may be other function modules preset in the programming language. For example, the programming modules built into the Scratch programming language, a programming module can be used to implement a function. Correspondingly, according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determining the scoring value of the code to be detected under the preset scoring dimension may include the following steps:
步骤1021、根据所述待检测运行结果与所述标准代码相关数据中的标准运行结果,确定所述待检测代码在第一评分维度下的第一评分分值。Step 1021: Determine a first scoring value of the code to be tested under the first scoring dimension according to the running result to be detected and the standard running result in the data related to the standard code.
本步骤中,第一评分维度可以表征运行结果项维度,运行结果项维度可以用于检测代码在嵌入式硬件设备运行时的传感器输出数据。由于传感器输出数据与嵌入式硬件设备的运行精度关联性较强。因此,可以确定待检测代码在第一评分维度下的第一评分分值,通过第一评分分值较为准确的表征待检测代码在运行结果项维度下的质量。In this step, the first scoring dimension can represent the dimension of the running result item, and the running result item dimension can be used to detect the sensor output data when the code is running on the embedded hardware device. Because the sensor output data has a strong correlation with the running accuracy of embedded hardware devices. Therefore, the first scoring value of the code to be detected under the first scoring dimension can be determined, and the quality of the code to be detected under the dimension of the running result item can be more accurately represented by the first scoring score.
步骤1022、根据所述所使用模块的相关信息及所述标准代码相关数据中的标准模块信息,确定所述待检测代码在第二评分维度下的第二评分分值。Step 1022: Determine the second scoring value of the code to be detected under the second scoring dimension according to the related information of the used module and the standard module information in the standard code related data.
本步骤中,第二评分维度可以表征程序代码项维度,程序代码项维度可以用于从代码本身的情况进行评判。标准模块信息可以表征预设标准代码中所使用模块的相关信息。由于代码中所使用的模块往往会对代码实现的控制功能起到较大的影响。因此,本发明实施例中根据所使用模块确定第二评分分值,使得第二评分分值可以较为准确的表征待检测代码在程序代码项维度下的质量。In this step, the second scoring dimension can represent the program code item dimension, and the program code item dimension can be used to judge the code itself. The standard module information can represent the relevant information of the modules used in the preset standard code. Because the modules used in the code often have a greater impact on the control functions implemented by the code. Therefore, in the embodiment of the present invention, the second scoring score is determined according to the used module, so that the second scoring score can more accurately characterize the quality of the code to be detected in the dimension of the program code item.
本发明实施例中,在根据运行结果从第一评分维度进行评分的基础上,进一步结合所使用模块从第二评分维度进行评判,进而一定程度上提高后续确定的整体评分的准确性。同时,由于代码本身的内容量往往较多,因此,相较于直接将代码本身进行比对的方式,本发明实施例中结合模块对代码本身的情况进行评判的方式,可以在提高准确性的同时,避免引入过多的计算量,进而确保检测效率。In the embodiment of the present invention, on the basis of scoring from the first scoring dimension according to the operation result, the second scoring dimension is further combined with the used module to judge, so as to improve the accuracy of the subsequently determined overall score to a certain extent. At the same time, since the content of the code itself is often large, compared with the method of directly comparing the code itself, the method of judging the situation of the code itself in combination with the module in the embodiment of the present invention can improve the accuracy. At the same time, it avoids the introduction of excessive computation, thereby ensuring the detection efficiency.
可选的,本发明实施例中,标准模块信息可以包括预设标准代码中所使用的标准模块的相关信息,根据所使用模块的相关信息及标准代码相关数据中的标准模块信息,确定待检测代码在第二评分维度下的第二评分分值的步骤,可以包括:Optionally, in this embodiment of the present invention, the standard module information may include relevant information of standard modules used in the preset standard code, and according to the relevant information of the used modules and the standard module information in the standard code-related data, it is determined to be detected. The steps of coding the second scoring value under the second scoring dimension may include:
子步骤(1):根据所述所使用模块的相关信息与所述标准模块的相关信息进行匹配,以确定所述所使用模块中与所述标准模块相匹配的第一模块的第一数量,和/或,确定所述第一模块中所使用参数与所述标准模块的使用参数相匹配的第二模块的第二数量。Sub-step (1): matching according to the relevant information of the used module and the relevant information of the standard module, to determine the first number of the first module matching the standard module in the used module, And/or, determining a second number of second modules whose used parameters in the first module match those of the standard module.
本步骤中,相关信息可以是能够指代模块的信息,例如,模块的名称、编号、所起的功能、所属的种类以及所使用的参数,等等。模块的相关信息可以是通过配置信息录入的。进一步地,所使用模块与标准模块相匹配可以指的是所使用模块与标准模块为同一模块,也可以是所使用模块与标准模块为同一种类的模块。由于同一种类的模块往往具备相同的功能,因此以属于同一种类的模块为判断基准,一定程度上可以避免后续确定的第二评分分值偏低的问题,确保第二评分分值能够准确的表征实际情况。In this step, the relevant information may be information that can refer to the module, for example, the name, number, function of the module, the type it belongs to, and the parameters used, and so on. The relevant information of the module can be entered through the configuration information. Further, that the used module matches the standard module may mean that the used module and the standard module are the same module, or the used module and the standard module are of the same type. Since modules of the same type often have the same function, taking the modules belonging to the same type as the judging benchmark, to a certain extent, it can avoid the problem that the second score is low in the subsequent determination, and ensure that the second score can be accurately represented. The actual situation.
具体实现时,可以将待检测代码中所使用模块的相关信息与各个标准模块的相关信息进行 比对,如果两者的相关信息相同,则可以认为该使用模块是与该标准模块相匹配的第一模块。进一步地,对于各个第一模块,可以将第一模块中所使用参数与和该第一模块相匹配的标准模块的使用参数进行比对,如果参数相同,则可以认为该第一模块是参数完全匹配的第二模块。During the specific implementation, the relevant information of the module used in the code to be detected can be compared with the relevant information of each standard module. If the relevant information of the two are the same, it can be considered that the used module is the first module that matches the standard module. a module. Further, for each first module, the parameters used in the first module can be compared with the use parameters of the standard module that matches the first module, and if the parameters are the same, it can be considered that the first module is completely parameterized. matching second module.
子步骤(2):根据第一比值和/或第二比值,确定所述第二评分分值;所述第一比值为所述第一数量与所述标准模块的总数量的比值,所述第二比值为所述第二数量与所述第一数量的比值。Sub-step (2): determine the second scoring value according to the first ratio and/or the second ratio; the first ratio is the ratio of the first quantity to the total quantity of the standard modules, the The second ratio is the ratio of the second amount to the first amount.
本步骤中可以先计算第一数量与标准模块的总数量的比值,得到第一比值,计算第二数量与第一数量的比值,得到第二比值。根据这两个比值,确定第二评分分值。其中,第二评分分值可以与第一比值,第二比值正相关。In this step, the ratio of the first quantity to the total quantity of standard modules may be calculated first to obtain the first ratio, and the ratio of the second quantity to the first quantity may be calculated to obtain the second ratio. Based on these two ratios, a second scoring score is determined. Wherein, the second scoring score may be positively correlated with the first ratio and the second ratio.
本发明实施例中,如果第一数量及第二数量越多,则说明待检测代码中使用的标准模块越多、使用的参数相匹配的标准模块越多,相应地,可以认为待检测代码越贴近预设标准代码。因此本发明实施例中结合根据第一数量及第二数量计算得到的比值,确定第二评分分值,一定程度上可以确保第二评分分值的准确性。In this embodiment of the present invention, if the first quantity and the second quantity are larger, it means that the code to be tested uses more standard modules and the used parameters match more standard modules. Correspondingly, it can be considered that the code to be tested has more standard modules. Close to the default standard code. Therefore, in the embodiment of the present invention, the second scoring value is determined in combination with the ratio calculated according to the first quantity and the second quantity, which can ensure the accuracy of the second scoring value to a certain extent.
可选的,本发明实施例中标准模块信息中还可以包括预设标准代码中禁止使用的禁用模块的相关信息,相应地,根据第一比值和/或第二比值,确定第二评分分值,可以包括:Optionally, the standard module information in this embodiment of the present invention may further include information about disabled modules that are prohibited from being used in the preset standard code. Accordingly, the second score is determined according to the first ratio and/or the second ratio. , which can include:
子步骤(2A):根据所述第一比值及所述第二比值,生成第一数值;所述第一数值与所述第一比值及所述第二比值正相关。Sub-step (2A): generating a first numerical value according to the first ratio and the second ratio; the first numerical value is positively correlated with the first ratio and the second ratio.
本发明实施例中,可以将第一比值及第二比值输入预设公式中,将预设公式的输出作为第一数值。其中,该预设公式的自变量与因变量正相关。示例的,本发明实施例中的标准模块可以包括关键模块、推荐模块以及必备模块。其中,关键模块可以是必须使用的模块,已使用则获得预先设置的关键模块所占的比分,未使用则可以相应扣分。推荐模块可以为可选模块,如果使用了则可以加分,未使用可以不扣分。必备模块可以为标准模块中除推荐模块和关键模块之外的其他模块。进一步地,第一数值可以包括代码块分值以及代码参数分值。其中,代码块分值可以包括关键模块分值Section key、推荐模块分值Section recom以及其他模块分值Section other,代码参数分值可以包括参数完全匹配的第二模块对应的分值Sectio matchedIn the embodiment of the present invention, the first ratio and the second ratio may be input into the preset formula, and the output of the preset formula may be used as the first value. Wherein, the independent variable of the preset formula is positively correlated with the dependent variable. Exemplarily, the standard modules in this embodiment of the present invention may include key modules, recommended modules, and necessary modules. Among them, the key module may be a module that must be used, and if it has been used, the score occupied by the pre-set key module will be obtained, and if it is not used, the score may be deducted accordingly. Recommended modules can be optional modules. If you use it, you can add points. If you don't use it, you can not deduct points. The prerequisite modules can be other modules in the standard modules except the recommended modules and the critical modules. Further, the first value may include a code block score and a code parameter score. The code block score may include the key module score Section key , the recommendation module score Section recom and other module scores Section other , and the code parameter score may include the score Sectio matched corresponding to the second module whose parameters are completely matched .
以N key表示标准模块中关键模块的数量,N key_usr表示待检测代码中使用的与关键模块相匹配的模块的数量,N std表示标准模块的总数量。N recom表示标准模块中推荐模块的数量,N recom_usr表示待检测代码中使用的与标准模块相匹配的模块的数量,N matched表示待检测模块中与标准模块匹配的模块的数量。 N key represents the number of key modules in the standard modules, N key_usr represents the number of modules used in the code to be detected that match the key modules, and N std represents the total number of standard modules. N recom represents the number of recommended modules in the standard modules, N recom_usr represents the number of modules used in the code to be detected that match the standard modules, and N matched represents the number of modules to be detected that match the standard modules.
相应地,其他模块可以表示为:(N matched-N recom_usr-N key_usr),第一比值可以表示为:N key_usr/N std+N recom_usr/N std+(N matched-N recom_usr-N key_usr)/N std=N matched/N std。 Correspondingly, other modules can be expressed as: (N matched -N recom_usr -N key_usr ), and the first ratio can be expressed as: N key_usr /N std +N recom_usr /N std +(N matched -N recom_usr -N key_usr )/ N std =N matched /N std.
进一步地,根据第一比值确定的代码块分值可以表示为:Further, the code block score determined according to the first ratio can be expressed as:
Section key+Section recom+Section otherSection key +Section recom +Section other .
其中,Section key=N key_usr/N key*N key/N std*100=N key_usr/N std*100。 Wherein, Section key =N key_usr /N key *N key /N std *100=N key_usr /N std *100.
Section recom=N recom_usr/N recom*N recom/N std*100=N recom_usr/N std*100。 Section recom = N recom_usr /N recom *N recom /N std *100=N recom_usr /N std *100.
Section other=(N matched-N recom_usr-N key_usr)/N std*100。 Section other =(N matched -N recom_usr -N key_usr )/N std *100.
即,代码块分值可以表示为:Section key+Section recom+Section other=N matched/N std*100。 That is, the code block score can be expressed as: Section key +Section recom +Section other =N matched /N std *100.
进一步地,以N usr_match_num表示参数完全匹配的模块的第二数量,以N std_num表示相匹配的模块的数量(即,第一数量),那么第二比值可以表示为:N usr_match_num/N std_numFurther, N usr_match_num represents the second number of modules whose parameters are completely matched, and N std_num represents the number of matched modules (ie, the first number), then the second ratio can be represented as: N usr_match_num /N std_num .
进一步地,代码参数分值可以表示为:Further, the code parameter score can be expressed as:
Section matched=N usr_match_num/N std_num*(100-Section key-Section other)。 Section matched = N usr_match_num /N std_num *(100-Section key -Section other ).
最后,可以将代码参数分值与代码块分值之和作为第一数值。Finally, the sum of the code parameter score and the code block score may be used as the first value.
子步骤(2B):根据所述所使用模块的相关信息与所述禁用模块的相关信息进行匹配,以确定所述所使用模块中与所述禁止模块相匹配的第三模块的第三数量。Sub-step (2B): Match according to the related information of the used module and the related information of the prohibited module to determine a third number of third modules in the used modules that match the prohibited module.
本步骤中,禁用模块可以是不允许使用的模块。进一步地,可以将待检测代码中所使用模块的相关信息与各个禁用模块的相关信息进行比对,如果两者的相关信息相同,则可以认为该使用模块是与该禁用模块相匹配的第三模块。In this step, the disabled module may be a module that is not allowed to be used. Further, the relevant information of the module used in the code to be detected can be compared with the relevant information of each forbidden module, if the relevant information of the two is the same, then it can be considered that the used module is the third one that matches the forbidden module. module.
子步骤(2C):根据所述第三数量与所述禁用模块的总数量之间的第三比值,减小所述第一数值;所述第一数值的减小量与所述第三比值正相关。Sub-step (2C): reducing the first numerical value according to a third ratio between the third number and the total number of disabled modules; the reduction of the first numerical value and the third ratio positive correlation.
以N forbid表示禁用模块的数量,N forbid_usr为待检测代码中使用的禁用模块的数量。可以先根据第三比值N forbid_usr/N forbid计算禁用模块分值Section forbid。根据Section forbid对第一数值进行减小。 N forbid represents the number of disabled modules, and N forbid_usr is the number of disabled modules used in the code to be detected. The disabled module score Section forbid may be calculated according to the third ratio N forbid_usr /N forbid . Decrease the first value according to Section forbid .
示例的Section forbid可以具体为: An example Section forbid can be specified as:
Section forbid=-N forbid_usr/N forbid*(Section key+Section recom+Section other+Section matched)。 Section forbid =-N forbid_usr /N forbid *(Section key +Section recom +Section other +Section matched ).
最后,减小后的第一数值可以表示为:Finally, the reduced first value can be expressed as:
Code score=Section key+Section recom+Section other+Section matched+Section forbid Code score =Section key +Section recom +Section other +Section matched +Section forbid
需要说明的是,基于该计算公式可知,若禁止模块都被待检测代码使用,则可以根据Section forbid扣完已经获得的所有分值,即,扣完第一数值。 It should be noted that, based on the calculation formula, it can be known that if the prohibited modules are all used by the code to be detected, all the obtained points can be deducted according to the Section forbid , that is, the first value can be deducted.
子步骤(2D):将减小后的所述第一数值确定为所述第二评分分值。Sub-step (2D): determining the reduced first numerical value as the second scoring score.
需要说明的是,本发明实施例中还可以将Section key、Section recom、Section other以及Section matched按照预设权重进行加权求和,之后使用Section forbid进行扣分,得到最终的第二评分分值。 It should be noted that, in this embodiment of the present invention, Section key , Section recom , Section other , and Section matched may also be weighted and summed according to preset weights, and then Section forbid is used to deduct points to obtain a final second scoring score.
本发明实施例中,通过进一步确定待检测代码中所使用的禁用模块的数量,根据待检测代码中所使用的禁用模块的数量施以对应的减分操作,一定程度上可以使得最终确定的第二评分分值更加准确。In the embodiment of the present invention, by further determining the number of disabled modules used in the code to be detected, and performing a corresponding deduction operation according to the number of disabled modules used in the code to be detected, to a certain extent, the finally determined No. Two-score scores are more accurate.
可选的,本发明实施例中标准运行结果可以为预设标准代码在所述嵌入式硬件设备上运行的运行结果,根据待检测运行结果与标准代码相关数据中的标准运行结果,确定待检测代码在第一评分维度下的第一评分分值,可以包括:Optionally, the standard running result in the embodiment of the present invention may be the running result of the preset standard code running on the embedded hardware device, and the to-be-detected running result is determined according to the running result to be detected and the standard running result in the data related to the standard code. The first scoring value of the code under the first scoring dimension, which can include:
子步骤(3):对于任一所述传感器,根据所述待检测运行结果中输出数据的变化信息与所述标准运行结果中输出数据的变化信息的匹配程度,确定所述传感器对应的评分分值;所述传感器对应的评分分值与所述匹配程度正相关。Sub-step (3): For any one of the sensors, according to the degree of matching between the change information of the output data in the operation result to be detected and the change information of the output data in the standard operation result, determine the score corresponding to the sensor. value; the score value corresponding to the sensor is positively correlated with the matching degree.
本发明实施例中的传感器可以包括运动类型的传感器以及非运动类型的传感器。其中,运动类型的传感器可以包括输出数据为连续数值的运动传感器,例如,位置传感器、角度传感器、加速度传感器、视觉传感器,等等。非运动类型的传感器可以为除运动类型传感器之外的传感器,例如,用于输出发光/不发光两种状态数据的光敏传感器,等等。The sensors in the embodiments of the present invention may include motion-type sensors and non-motion-type sensors. The motion-type sensor may include motion sensors whose output data are continuous numerical values, for example, a position sensor, an angle sensor, an acceleration sensor, a vision sensor, and the like. The non-motion type sensor may be a sensor other than the motion type sensor, for example, a photosensitive sensor for outputting light-emitting/non-emitting state data, and the like.
进一步地,输出数据的变化信息可以用于表征输出数据的变化过程,如果变化信息匹配程度越高,即,待检测代码对嵌入式硬件设备的控制过程与预设标准代码对嵌入式硬件设备的控制过程更贴近,待检测代码在对该传感器的控制维度上更加准确。因此,可以根据匹配程度,在匹配程度越高的情况下,设置越高的传感器对应的评分分值。Further, the change information of the output data can be used to characterize the change process of the output data. If the matching degree of the change information is higher, that is, the control process of the embedded hardware device by the code to be detected and the control process of the embedded hardware device by the preset standard code. The control process is closer, and the code to be detected is more accurate in the control dimension of the sensor. Therefore, according to the matching degree, in the case of a higher matching degree, a higher score value corresponding to a sensor can be set.
子步骤(4):根据各个所述传感器对应的评分分值,确定所述第一评分分值。Sub-step (4): Determine the first scoring value according to the scoring value corresponding to each of the sensors.
示例的,可以将各个传感器的对应的评分分值之和,或加权和确定为第一评分分值。Exemplarily, the sum or weighted sum of the corresponding scores of each sensor may be determined as the first score.
本发明实施例中,由于待检测运行结果与标准运行结果中输出数据的变化信息的匹配程度可以较为准确的反映待检测运行结果与标准运行结果之间的贴近程度。因此,本发明实施例先根据匹配程度确定各个传感器对应的评分分值,根据传感器对应的评分分值确定第一评分分值,一定程度上可以确保确定的第一评分分值的准确性。当然,本发明实施例中也可以从其他维度确定分值,例如,运行时长,等。In the embodiment of the present invention, the degree of closeness between the to-be-detected operation result and the standard operation result can be more accurately reflected due to the matching degree of the change information of the output data in the to-be-detected operation result and the standard operation result. Therefore, in this embodiment of the present invention, the scoring value corresponding to each sensor is first determined according to the matching degree, and the first scoring value is determined according to the scoring value corresponding to the sensor, which can ensure the accuracy of the determined first scoring value to a certain extent. Of course, in this embodiment of the present invention, the score may also be determined from other dimensions, for example, the running time, and the like.
可选的,对于运动类型的传感器,上述子步骤(3)可以通过下述子步骤实现:Optionally, for a motion-type sensor, the above sub-step (3) can be implemented by the following sub-steps:
子步骤(3A):按照时间顺序依次获取所述传感器的输出曲线中的极值点,并根据获取到的极值点生成极值点变化序列;所述传感器的输出曲线根据所述传感器的输出数据确定。Sub-step (3A): sequentially acquiring extreme points in the output curve of the sensor in chronological order, and generating an extreme point change sequence according to the acquired extreme points; the output curve of the sensor is based on the output of the sensor Data OK.
本步骤中可以先根据传感器输出的角度参数值以及初始角度参数值,确定各个时刻下输出的相对角度参数值;根据各个时刻下输出的相对角度参数值,生成输出曲线;按照时间顺序依次获取输出曲线中的极值点。In this step, the relative angle parameter value output at each moment can be determined first according to the angle parameter value output by the sensor and the initial angle parameter value; the output curve is generated according to the relative angle parameter value output at each moment; the output is sequentially obtained according to the time sequence Extreme points in the curve.
其中,初始角度参数值可以是传感器刚启动时输出的参数角度值,相对参数角度值可以为传感器输出的参数角度值,即,运动总数值,与初始参数角度值之差。根据各个时刻下输出的相对参数角度值生成输出曲线时,可以将相对参数角度值作为预设拟合算法的输入,将拟合算法拟合出的曲线作为输出曲线。最后,可以按照时间顺序依次检测输出曲线中的极值点,形成极值点变化序列。这样,通过先确定相对参数角度值,以相对参数角度值确定的输出曲线获取极值点变化序列,一定程度上可以使得极值点变化序列更具代表性。示例的,在传感器为角度传感器的情况下,参数值可以为角度传感器输出的角度,在传感器为位置传感器的情况下、参数值可以为位置传感器输出的位置,在传感器为加速度传感器的情况下、参数值可以为加速度传感器输出的加速度。Wherein, the initial angle parameter value can be the parameter angle value output by the sensor when the sensor is just started, and the relative parameter angle value can be the parameter angle value output by the sensor, that is, the difference between the total motion value and the initial parameter angle value. When generating the output curve according to the relative parameter angle value output at each moment, the relative parameter angle value can be used as the input of the preset fitting algorithm, and the curve fitted by the fitting algorithm can be used as the output curve. Finally, the extreme points in the output curve can be detected sequentially in time sequence to form a change sequence of extreme points. In this way, by first determining the relative parameter angle value and obtaining the extreme point change sequence from the output curve determined by the relative parameter angle value, the extreme value point change sequence can be made more representative to a certain extent. For example, when the sensor is an angle sensor, the parameter value may be the angle output by the angle sensor, when the sensor is a position sensor, the parameter value may be the position output by the position sensor, and when the sensor is an acceleration sensor, The parameter value can be the acceleration output by the acceleration sensor.
进一步地,可以根据预设的峰值检测算法确定输出曲线中的极值点。具体的,可以通过峰值检测算法确定输出曲线的二阶导数,并根据二阶导数确定输出曲线函数整体的凹凸性,进而获取输出曲线的拐点,即,极值点。Further, the extreme point in the output curve can be determined according to a preset peak detection algorithm. Specifically, the second-order derivative of the output curve can be determined by a peak detection algorithm, and the overall concave-convexity of the output curve function can be determined according to the second-order derivative, so as to obtain the inflection point of the output curve, that is, the extreme point.
示例的,可以先计算输出曲线的一阶导数,其中一阶导数可以表示为Δsensor n=sensor n-sensor n-1。然后对一阶导数进行高通过滤,以消除由于传感器的零飘和波动问题导致的数据偏差。其中,高通过滤可以表示为: For example, the first-order derivative of the output curve can be calculated first, where the first-order derivative can be expressed as Δsensor n =sensor n -sensor n-1 . The first derivative is then high-pass filtered to remove data bias due to sensor drift and fluctuation issues. Among them, high-pass filtering can be expressed as:
Δsensor thread=2°,Δsensor n<Δsensor thread,Δsensor n=0。 Δsensor thread =2°, Δsensor n <Δsensor thread , Δsensor n =0.
接着,可以按照下述预设公式对差分后的一阶导数取符号:Next, the first derivative of the difference can be signed according to the following preset formula:
Figure PCTCN2020114437-appb-000001
Figure PCTCN2020114437-appb-000001
经过进一步变形,可以得到差分向量表示:After further deformation, the difference vector representation can be obtained:
if Δsensor n=0&&Δsensor n+1≥0,Δsensor n=1 if Δsensor n =0&&Δsensor n+1 ≥0, Δsensor n =1
if Δsensor n=0&&Δsensor n+1<0,Δsensor n=1 if Δsensor n =0&&Δsensor n+1 <0, Δsensor n =1
接着,可以对差分向量再求导,得到二阶导数。其中二阶导数可以表示为ΔΔsensor n=Δsensor n-Δsensor n-1Then, the difference vector can be re-derivative to obtain the second derivative. The second derivative can be expressed as ΔΔsensor n =Δsensor n -Δsensor n-1 .
最后,可以遍历ΔΔsensor n。示例的,遍历结果中ΔΔsensor n=2的点可以表示波谷,ΔΔsensor n=-2的点可以表示波峰。 Finally, ΔΔsensor n can be traversed. Exemplarily, in the traversal result, a point with ΔΔsensor n =2 may represent a trough, and a point with ΔΔsensor n =-2 may represent a peak.
进一步地,可以按照时间顺序根据下述预设公式从遍历结果中查找临界点,即,极值点的迁移过程。Further, the critical point, that is, the migration process of the extreme point, can be searched from the traversal result according to the following preset formula in time sequence.
Figure PCTCN2020114437-appb-000002
Figure PCTCN2020114437-appb-000002
其中,N表示对输出曲线进行采样得到的数据的个数,a n表示查找到的临界点。 Among them, N represents the number of data obtained by sampling the output curve, and an represents the found critical point.
进一步地,可以剔除查找到的结果中数值为0的a n,得到迁移链,即,极值点变化序列。示例的,该极值点变化序列可以表示为:极大值-->极小值-->极小值-->极大值,例如:2-->-2-->-2-->2。 Further, an a n with a value of 0 in the searched result can be eliminated to obtain a migration chain, that is, a change sequence of extreme points. Exemplarily, the extreme point change sequence can be expressed as: maximum value --> minimum value --> minimum value --> maximum value, for example: 2-->-2-->-2-- >2.
子步骤(3B):根据所述极值点变化序列与所述标准运行结果中所述传感器的标准极值点变化序列,确定所述极值点变化序列中与所述标准极值点变化序列相匹配的极值点。Sub-step (3B): According to the extreme point change sequence and the standard extreme point change sequence of the sensor in the standard operation result, determine the extreme point change sequence and the standard extreme point change sequence in the extreme point change sequence matching extreme points.
本步骤中,标准极值点变化序列可以是预先根据标准运行结果中传感器的输出数据确定的,具体的确定方式可以参照上述步骤中的实现方式,本发明实施例对此不做赘述。进一步地,相匹配的极值点可以为数值相同且相对时序关系与标准极值点变化序列中的相对时序关系相同的 点。示例的,可以按照时间顺序将极值点变化序列与标准极值点变化序列进行比对,然后将数值相同且相对时序相同的极值点确定为相匹配的极值点。假设标准极值点变化序列为:abcde,极值点变化序列为:aced,那么可以确定相匹配的极值点为acd。其中,acd之间的相对时序关系与在标准极值点变化序列abcde中“acd”的相对时序关系相同。In this step, the standard extreme point change sequence may be determined in advance according to the output data of the sensor in the standard operation result, and the specific determination method may refer to the implementation manner in the above steps, which is not repeated in this embodiment of the present invention. Further, the matched extremum points may be points with the same numerical value and the same relative temporal relationship as those in the standard extremum point change sequence. Exemplarily, the change sequence of extreme value points may be compared with the standard change sequence of extreme value points in time sequence, and then the extreme value points with the same numerical value and the same relative time sequence are determined as matching extreme value points. Assuming that the standard extreme point change sequence is: abcde, and the extreme point change sequence is: aced, then it can be determined that the matching extreme point is acd. Among them, the relative timing relationship between acd is the same as the relative timing relationship of "acd" in the standard extreme point change sequence abcde.
需要说明的是,由于嵌入式硬件设备中可能会包含多个传感器,因此,本发明实施例可以先根据各个传感器的执行顺序对各个传感器的输出数据进行排序。然后针对每个传感器分别执行上述操作,这样可以避免多个传感器的数据出现混淆,进而确保最终确定的评分分值的准确性。It should be noted that, since the embedded hardware device may include multiple sensors, the embodiment of the present invention may first sort the output data of each sensor according to the execution order of each sensor. Then perform the above operations for each sensor separately, so as to avoid the confusion of the data of multiple sensors, thereby ensuring the accuracy of the final score.
子步骤(3C):计算第一长度与第二长度之间的第三比值;所述第一长度为所述相匹配的极值点组成的变化序列的长度,所述第二长度为所述标准极值点变化序列的长度,所述匹配程度与所述第三比值正相关。Sub-step (3C): Calculate the third ratio between the first length and the second length; the first length is the length of the change sequence composed of the matched extreme points, and the second length is the The length of the standard extreme point change sequence, and the matching degree is positively correlated with the third ratio.
本步骤中,第一长度可以表征相同最长连续链的大小,以L表示第一长度,L 表示第二长度,可以将L/L 作为第三比值P 1。其中,第三比值越大,说明匹配程度越大。或者也可以先计算ε=|(L-L )/L |*100%,相应地,将1-ε作为P 1In this step, the first length can represent the size of the same longest continuous chain, and L represents the first length, and the L mark represents the second length, and the L/L mark can be used as the third ratio P 1 . Among them, the larger the third ratio, the greater the matching degree. Alternatively, ε=|(LL scale )/L scale |*100% can also be calculated first, and correspondingly, 1-ε is taken as P 1 .
子步骤(3D):根据所述第三比值,确定所述传感器对应的评分分值。Sub-step (3D): According to the third ratio, determine the score corresponding to the sensor.
示例的,可以预先设置第一占比P anchor,然后将P anchor与第三比值的乘积,确定为该传感器对应的评分分值,即,S anchor=P 1*P anchor。其中,P anchor的具体值可以是根据实际需求预先设置的,例如,P anchor可以为0.5。 For example, the first ratio P anchor may be preset, and then the product of P anchor and the third ratio is determined as the score corresponding to the sensor, that is, S anchor =P 1 *P anchor . The specific value of P anchor may be preset according to actual requirements, for example, P anchor may be 0.5.
需要说明的是,为了确保计算结果的准确性,本发明实施例中还可以在子步骤(3A)之前执行以下操作:根据预设的滤波算法,对所述传感器的输出数据中出现的异常极值点进行过滤。其中,预设的滤波算法可以为形态学滤波方法中的腐蚀和膨胀算法。具体的,可以根据腐蚀和膨胀算法,采用开滤波器及闭滤波器对传感器的输出数据进行开运算以及闭运算,过滤传感器信号中的局部的波峰和波谷,进而实现过滤异常极值点。It should be noted that, in order to ensure the accuracy of the calculation results, the following operations may also be performed before sub-step (3A) in this embodiment of the present invention: value points to filter. The preset filtering algorithm may be an erosion and dilation algorithm in the morphological filtering method. Specifically, according to the erosion and expansion algorithm, the open filter and the closed filter can be used to open and close the output data of the sensor to filter the local peaks and troughs in the sensor signal, thereby filtering the abnormal extreme points.
具体的,假设传感器输出数据为X(n),(n=1,2,…,N),预先定义的结构体元素为g(m),其中(m=1,2,…,M;且N>=M)。其中,结构体元素的具体值可以是根据实验预先确定的。示例的,本发明实施例中的结构体元素可以为:g(k)=[1,1,1,1,1]。Specifically, it is assumed that the sensor output data is X(n), (n=1,2,...,N), the predefined structural element is g(m), where (m=1,2,...,M; and N>=M). The specific values of the structural elements may be predetermined according to experiments. Exemplarily, the structural element in this embodiment of the present invention may be: g(k)=[1, 1, 1, 1, 1].
进一步地,x(n)关于g(m)的腐蚀和膨胀操作可以定义为:Further, the erosion and dilation operations of x(n) with respect to g(m) can be defined as:
(xΘg)(n)=min[x(n+m)-g(m)]m∈0,1,...,M-1(xΘg)(n)=min[x(n+m)-g(m)]m∈0,1,...,M-1
Figure PCTCN2020114437-appb-000003
Figure PCTCN2020114437-appb-000003
相应地,由腐蚀和膨胀运算组成的开运算以及闭运算可以分别表示为:Correspondingly, the opening and closing operations consisting of erosion and dilation operations can be expressed as:
Figure PCTCN2020114437-appb-000004
Figure PCTCN2020114437-appb-000004
Figure PCTCN2020114437-appb-000005
Figure PCTCN2020114437-appb-000005
本发明实施例中,通过先对输出数据中出现的异常极值点进行过滤,可以确保输出数据的准确性,进而提高后续根据输出数据确定的分值的准确性。In the embodiment of the present invention, by first filtering the abnormal extreme value points appearing in the output data, the accuracy of the output data can be ensured, thereby improving the accuracy of the subsequent scores determined according to the output data.
本发明实施例中,通过获取极值点,根据极值点变化序列确定传感器对应的评分分值。可以在避免引入较多计算量的同时,实现根据输出数据的变化信息确定评分分值,进而一定程度上可以确保计算效率。同时,通过极值点变化序列中相匹配的极值点组成的迁移链的大小,确定评分分值,一定程度上可以确保评分分值的准确性。In the embodiment of the present invention, by acquiring the extreme point, the score corresponding to the sensor is determined according to the change sequence of the extreme point. While avoiding the introduction of a large amount of calculation, the scoring value can be determined according to the change information of the output data, thereby ensuring the calculation efficiency to a certain extent. At the same time, the score is determined by the size of the migration chain composed of the matched extreme points in the extreme point change sequence, which can ensure the accuracy of the score to a certain extent.
可选的,对于非运动类型的传感器,上述子步骤(3)可以通过下述子步骤实现:Optionally, for a non-motion type sensor, the above sub-step (3) can be implemented by the following sub-steps:
子步骤(3E):计算所述待检测运行结果中输出数据的输出值变化序列与所述标准运行结果中输出数据的输出值变化序列之间的误差值;所述匹配程度与所述误差值负相关。Sub-step (3E): Calculate the error value between the output value change sequence of the output data in the running result to be detected and the output value change sequence of the output data in the standard running result; the matching degree and the error value negative correlation.
本步骤中,输出数据的输出值变化序列可以是输出值组成的序列,该序列可以表征锚点值形成的迁移链,具体可以表征传感器的状态变化过程。例如,以秒为单位进行采样,光敏传感 器的输出值组成的序列可以为发光-不发光-发光-不发光-发光-不发光,即,光敏传感器是每间隔一秒进行一次发光。进一步地,计算误差值时,可以将两个输出值变化序列输入采用预设的误差算法,例如,作为标准误差公式的输入,然后将输出作为误差值。In this step, the output value change sequence of the output data may be a sequence composed of output values, and the sequence may represent the transition chain formed by the anchor point value, and specifically may represent the state change process of the sensor. For example, sampling is performed in seconds, and the output value of the photosensitive sensor can be composed of a sequence of light-emitting-no light-emitting-no light-emitting-light-emitting, that is, the light-sensitive sensor emits light every one second. Further, when calculating the error value, a preset error algorithm can be used to input the two output value change sequences, for example, as the input of the standard error formula, and then the output is used as the error value.
子步骤(3F):根据所述误差值,确定所述传感器对应的评分分值。Sub-step (3F): According to the error value, determine the score value corresponding to the sensor.
具体的,可以将输出值变化序列中的输出值划分为多组输出值,根据每组输出值计算一个误差值,进而得到多个误差值。然后计算这多个误差值的平均值ε2。接着计算P 2=1-ε2,最后将预先设置第二占比P sensor与P 2的乘积,确定为该传感器对应的评分分值,即,S sensor=P 2*P sensor。其中,P sensor的具体值可以是根据实际需求预先设置的,例如,P sensor可以为0.5。 Specifically, the output values in the output value change sequence may be divided into multiple groups of output values, and an error value is calculated according to each group of output values, thereby obtaining multiple error values. The average ε2 of these multiple error values is then calculated. Then, P 2 =1-ε2 is calculated, and finally, the product of the second proportion P sensor and P 2 is preset to determine the score corresponding to the sensor, that is, S sensor =P 2 *P sensor . The specific value of P sensor may be preset according to actual requirements, for example, P sensor may be 0.5.
进一步地,根据各个传感器对应的评分分值,确定第一评分分值时,可以是将所有S anchor与所有 Ssensor之和确定为第一评分分值,或者是计算所有S anchor与所有S sensor之间的加权和,得到第一评分分值。 Further, when determining the first scoring score according to the corresponding scoring value of each sensor, the sum of all S anchors and all Ssensors may be determined as the first scoring score, or the sum of all S anchors and all S sensors may be calculated. The weighted sum of the time is obtained to obtain the first scoring score.
由于误差值可以较为准确的表征匹配程度,本发明实施例中通过先计算误差值,根据误差值确定传感器对应的评分分值,一定程度上可以确保评分分值的准确性。Since the error value can more accurately represent the matching degree, in the embodiment of the present invention, by first calculating the error value, and determining the score value corresponding to the sensor according to the error value, the accuracy of the score value can be ensured to a certain extent.
可选的,本发明实施例中还可以根据待检测运行结果中与标准代码相关数据中不相匹配的数据,确定报错信息,并输出报错信息。示例的,可以通过对传感器的锚点值进行检测,确定不相匹配的锚点值,并检索对应的预设提示信息,最后根据该预设提示信息输出指示不相匹配的锚点值的报错信息。例如,可以输出“传感器的输出值:XXX存在问题”。这样,通过输出报错信息可以使用户及时获取问题,进而方便用户进行调整。需要说明的是,还可以根据除运行结果之外的其他静态代码数据,确定报错信息。示例的,可以获取待检测代码中使用的禁用模块的标识,然后输出指示待检测代码中使用的禁用模块的报错信息。例如,可以输出“存在以下禁用模块:YYY,请调整”。Optionally, in this embodiment of the present invention, the error reporting information may be determined according to data that does not match the standard code-related data in the running result to be detected, and the error reporting information may be output. For example, the anchor value of the sensor can be detected, the unmatched anchor value can be determined, the corresponding preset prompt information can be retrieved, and finally an error report indicating the unmatched anchor value can be output according to the preset prompt information. information. For example, "The output value of the sensor: XXX has a problem" can be output. In this way, the user can obtain the problem in time by outputting the error message, thereby facilitating the user to make adjustments. It should be noted that the error message can also be determined according to other static code data other than the running result. For example, the identifier of the disabled module used in the code to be detected can be obtained, and then the error message indicating the disabled module used in the code to be detected is output. For example, "The following disabled modules exist: YYY, please adjust" can be output.
可选的,本发明实施例中待检测代码相关数据还可以包括待检测代码的编程参数,其中,编程参数可以包括待检测代码的编程时长和/或调试次数。相应地,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值的步骤,还可以包括下述步骤:Optionally, the data related to the code to be detected in the embodiment of the present invention may further include programming parameters of the code to be detected, where the programming parameter may include the programming duration and/or the number of times of debugging of the code to be detected. Correspondingly, according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, the step of determining the scoring value of the code to be detected under the preset scoring dimension may also include the following steps:
步骤1023、根据所述编程参数,确定所述待检测代码在第三评分维度下的第三评分分值;其中,所述编程参数越小,所述第三评分分值越大。Step 1023: Determine a third scoring value of the code to be detected under a third scoring dimension according to the programming parameter; wherein, the smaller the programming parameter is, the larger the third scoring value is.
本步骤中,第三评分维度可以表征编写调试项维度,编写调试项维度可以用于从代码生成时编写和调试的情况进行评判。如果编写时长越短,调试次数越少,一定程度上可以认为代码的质量越高。因此,本步骤中可以在编程参数越小的情况下,设置越大的第三评分分值。In this step, the third scoring dimension can represent the dimension of writing and debugging items, and the dimension of writing and debugging items can be used to judge from the situation of writing and debugging during code generation. If the writing time is shorter and the number of debugging times is less, the quality of the code can be considered to be higher to a certain extent. Therefore, in this step, when the programming parameter is smaller, a larger third scoring value can be set.
本发明实施例中,通过进一步结合编程参数从第三评分维度进行评判,进而一定程度上提高后续确定的整体评分的准确性。In the embodiment of the present invention, the judgment is further combined with programming parameters from the third scoring dimension, thereby improving the accuracy of the overall score determined subsequently to a certain extent.
可选的,待检测代码为多个用户提交的多个待检测代码,根据编程参数,确定待检测代码在第三评分维度下的第三评分分值,可以包括:Optionally, the code to be tested is a plurality of codes to be tested submitted by multiple users. According to programming parameters, the third scoring value of the code to be tested under the third scoring dimension is determined, which may include:
子步骤(4):对于任一所述编程参数,按照所述编程参数的大小,将所述多个待检测代码划分至不同代码等级;其中,所述代码等级越高,所述代码等级对应的待检测代码的编程参数越小。Sub-step (4): for any of the programming parameters, according to the size of the programming parameters, the plurality of codes to be detected are divided into different code levels; wherein, the higher the code level, the corresponding code level. The smaller the programming parameters of the code to be detected.
本步骤中,可以先按照编程参数的大小对待检测代码进行排序,然后根据排序结果划分代码等级。需要说明的是,在出现待检测代码的编程参数大小相同时,可以根据待检测代码对应的用户的姓名或标识(Identity,ID)确定待检测代码的顺序。例如,将ID更大的待检测代码设置在更靠前的位置。In this step, the codes to be detected may be sorted according to the size of the programming parameters, and then the code levels may be divided according to the sorting result. It should be noted that, when the programming parameters of the codes to be detected have the same size, the sequence of the codes to be detected may be determined according to the name or identification (Identity, ID) of the user corresponding to the codes to be detected. For example, the code to be detected with a larger ID is placed at a higher position.
示例的,以编程参数为编程时长,按照编程参数由大至小进行排序为例,可以将排序结果中前10%的待检测代码划分至代码等级A,将排序结果中前11%~40%的待检测代码划分至代码等级B,将排序结果中前41%~80%的待检测代码划分至代码等级C,将排序结果中前81%~100% 的待检测代码,即,将后10%的待检测代码划分至代码等级D。进一步地,以编程参数为调试次数,按照调试次数由大至小进行排序为例,可以将排序结果中前10%的待检测代码划分至代码等级A,将排序结果中前11%~20%的待检测代码划分至代码等级B,将排序结果中前21%~70%的待检测代码划分至代码等级C,将排序结果中前71%~100%的待检测代码,即,将后30%的待检测代码划分至代码等级D。其中,代码等级A、代码等级B、代码等级C、代码等级D的等级依次降低,各个代码等级对应的比例可以在预设的编程参数等级映射表中定义,各个代码等级对应的比例可以根据实际需求设置。As an example, taking the programming parameters as the programming time and sorting the programming parameters from large to small as an example, the top 10% of the codes to be detected in the sorting result can be divided into code level A, and the top 11%-40% of the sorting results can be classified into code level A. The code to be detected is divided into code level B, the first 41% to 80% of the code to be detected in the sorting result is divided into code level C, and the first 81% to 100% of the code to be detected in the sorting result, that is, the last 10 % of the codes to be detected are assigned to code level D. Further, taking the programming parameter as the number of debugging times, and sorting the debugging times from large to small as an example, the top 10% of the code to be detected in the sorting result can be divided into code level A, and the top 11%-20% of the sorting result can be divided into code level A. The code to be detected is divided into code grade B, the first 21% to 70% of the code to be detected in the sorting result is divided into code grade C, the first 71% to 100% of the code to be detected in the sorting result, that is, the last 30 % of the codes to be detected are assigned to code level D. Among them, the grades of code grade A, code grade B, code grade C, and code grade D are successively reduced, and the corresponding ratio of each code grade can be defined in the preset programming parameter grade mapping table, and the corresponding ratio of each code grade can be based on actual Requirement settings.
子步骤(5):对于任一所述待检测代码,根据所述待检测代码对应的代码等级,确定所述编程参数对应的分值;所述编程参数对应的分值与所述代码等级正相关。Sub-step (5): for any code to be detected, according to the code level corresponding to the code to be detected, determine the score corresponding to the programming parameter; the score corresponding to the programming parameter is positive with the code level. related.
示例的,可以将待检测代码对应的代码等级对应的数值,确定为编程参数对应的分值。For example, the value corresponding to the code level corresponding to the code to be detected may be determined as the score corresponding to the programming parameter.
子步骤(6):根据所述编程参数对应的分值,确定所述第三评分分值。Sub-step (6): Determine the third scoring score according to the score corresponding to the programming parameter.
示例的,可以计算各个编程参数对应的分值之间的加权和,得到第三评分分值。其中,各个编程参数对应的权重比例可以是根据实际需求设置的,例如,编写时长和调试次数对应的权重比例可以分别为0.5,即,编写时长和调试次数各占调试项分值的50%。Exemplarily, a weighted sum between the scores corresponding to each programming parameter may be calculated to obtain a third score. The weight ratio corresponding to each programming parameter can be set according to actual requirements. For example, the weight ratio corresponding to the writing time and the number of debugging times can be 0.5 respectively, that is, the writing time and the number of debugging times each account for 50% of the score of the debugging item.
本发明实施中,通过按照编程参数的大小,将待检测代码划分至不同代码等级,针对代码等级确定编程参数对应的分值,可以确保确定的编程参数对应的分值贴合实际情况,进而确保后续确定的第三评分分值的准确性。In the implementation of the present invention, by dividing the code to be detected into different code levels according to the size of the programming parameter, and determining the score corresponding to the programming parameter according to the code level, it can be ensured that the score corresponding to the determined programming parameter fits the actual situation, thereby ensuring that The accuracy of the subsequent determination of the third scoring score.
可选的,待检测代码相关数据还可以包括待检测代码的代码长度;按照所述编程参数的大小,将多个待检测代码划分至不同代码等级之前,还可以:确定所述待检测代码的代码长度是否满足预设长度要求;若所述代码长度不满足所述预设长度要求且所述所使用的关键模块的数量为预设数量,则将第一预设值确定为所述第三评分分值;若所述代码长度满足所述预设长度要求和/或所述所使用的关键模块的数量不为所述预设数量,则执行所述按照所述编程参数的大小,将所述多个待检测代码划分至不同代码等级的步骤。Optionally, the data related to the code to be detected may further include the code length of the code to be detected; according to the size of the programming parameter, before dividing a plurality of codes to be detected into different code levels, it is also possible to: determine the length of the code to be detected. Whether the code length meets the preset length requirement; if the code length does not meet the preset length requirement and the number of the used key modules is the preset number, then the first preset value is determined as the third Scoring score; if the code length meets the preset length requirement and/or the number of key modules used is not the preset number, then execute the described programming parameters according to the size of the Describe the steps of dividing a plurality of codes to be detected into different code levels.
具体的,关键模块的定义以及确定关键模块的数量的方式,可以参照前述步骤中的相关描述,此处不作赘述。进一步地,预设长度要求及预设数量可以是根据实际需求设置的。Specifically, for the definition of the key modules and the manner of determining the number of the key modules, reference may be made to the relevant descriptions in the preceding steps, which will not be repeated here. Further, the preset length requirement and the preset number may be set according to actual requirements.
示例的,以L参考表示预设长度阈值,L表示待检测代码的代码长度,预设长度要求可以为(L 参考-L)/L 参考大于50%,预设数量可以为0。进一步地,如果代码长度不满足预设长度要求且所使用的关键模块为0,则可以将该待检测代码划分为第一类别的代码。其中,第一类别可以用于表征恶意用户提交的代码。相应地,可以不执行后续将待检测代码划分至不同代码等级的操作,即,直接将恶意代码的第二评分分值设置为0分。进一步地,如果代码长度满足预设长度要求和/或所使用的关键模块不为0,则可以认为待检测代码不为恶意代码,因此,可以执行将待检测代码划分至不同代码等级的操作。 Exemplarily, L reference represents the preset length threshold, L represents the code length of the code to be detected, the preset length requirement may be (L reference - L)/L reference greater than 50%, and the preset number may be 0. Further, if the code length does not meet the preset length requirement and the used key module is 0, the to-be-detected code can be divided into codes of the first category. Among them, the first category can be used to characterize code submitted by malicious users. Correspondingly, the subsequent operation of classifying the code to be detected into different code levels may not be performed, that is, the second scoring value of the malicious code is directly set to 0 points. Further, if the code length meets the preset length requirement and/or the used key module is not 0, it can be considered that the code to be detected is not malicious code, therefore, the operation of classifying the code to be detected into different code levels can be performed.
本发明实施例中,根据代码长度以及代码中所使用的关键模块的数量,确定是否执行按照编程参数的大小将多个待检测代码划分至不同代码等级的步骤,可以避免对恶意代码执行不必要的操作,进而可以节省处理资源。In the embodiment of the present invention, according to the code length and the number of key modules used in the code, it is determined whether to perform the step of dividing multiple codes to be detected into different code levels according to the size of the programming parameters, which can avoid unnecessary execution of malicious code. operation, which can save processing resources.
可选的,上述子步骤(5)可以通过下述子步骤实现:Optionally, the above-mentioned sub-step (5) can be realized by the following sub-steps:
子步骤(5A):根据所述待检测代码中所使用的关键模块的数量、禁用模块的数量以及所述待检测运行结果与所述标准运行结果的匹配程度,确定所述待检测代码的所属类别。Sub-step (5A): According to the number of key modules used in the code to be detected, the number of disabled modules and the degree of matching between the running result to be detected and the standard running result, determine the belonging of the code to be detected. category.
本步骤中,可以将所使用的关键模块的数量与标准模块中关键模块的数量相同、禁用模块的数量为0,即,未使用禁用模块以及待检测运行结果与标准运行结果的匹配程度满足预设要求的待检测代码划分为第二类别的代码。其中,第二类别可以用于表征基本功能完成类,匹配程度满足预设要求可以为传感器轨迹比对法针对待检测运行结果与标准运行结果的输出结果满足第一预设条件,例如,输出结果为匹配度很高,锚点特征值比对法针对待检测运行结果与标准运行结果的输出结果满足第二预设条件,例如,输出结果为匹配度100分。进一步地,如果待 检测代码不属于第一类别也不属于第二类别,则可以将该待检测代码划分为第三类别,第三类别可以用于表征基本功能未完成类。In this step, the number of used key modules can be the same as the number of key modules in the standard modules, and the number of disabled modules can be 0, that is, the disabled modules are not used and the matching degree between the running result to be detected and the standard running result satisfies the predetermined It is assumed that the required codes to be detected are classified into codes of the second category. The second category can be used to represent the basic function completion category, and the matching degree meeting the preset requirement can be that the output result of the sensor trajectory comparison method for the operation result to be detected and the standard operation result satisfies the first preset condition, for example, the output result In order to have a high degree of matching, the anchor point feature value comparison method satisfies the second preset condition for the output result of the running result to be detected and the standard running result, for example, the output result is a matching degree of 100 points. Further, if the code to be detected does not belong to the first category nor the second category, the code to be detected can be divided into a third category, and the third category can be used to represent the basic function incomplete category.
子步骤(5B):从与所述所属类别对应的预设等级与分值对应关系中,查找所述待检测代码对应的代码等级对应的分值,得到所述编程参数对应的分值。其中,不同类别对应的预设等级与分值对应关系中,同一等级对应的分值不同。Sub-step (5B): Search for the score corresponding to the code level corresponding to the code to be detected from the corresponding relationship between the preset level and the score corresponding to the category, and obtain the score corresponding to the programming parameter. Wherein, in the corresponding relationship between preset levels and scores corresponding to different categories, the scores corresponding to the same level are different.
本步骤中,预设等级与分值对应关系可以是根据实际情况设置,预设等级与分值对应关系可以为代码等级与分值之间的映射表。示例的,第二类别对应的预设等级与分值对应关系中,代码等级A对应的分值可以为100、代码等级B对应的分值可以为90、代码等级C对应的分值可以为80、代码等级D对应的分值可以为70。进一步地,第三类别对应的预设等级与分值对应关系中,代码等级A对应的分值可以为75、代码等级B对应的分值可以为65、代码等级C对应的分值可以为55、代码等级D对应的分值可以为45。In this step, the corresponding relationship between the preset level and the score may be set according to the actual situation, and the corresponding relationship between the preset level and the score may be a mapping table between the code level and the score. For example, in the corresponding relationship between the preset level and the score corresponding to the second category, the score corresponding to code level A may be 100, the score corresponding to code level B may be 90, and the score corresponding to code level C may be 80. , the score corresponding to code level D may be 70. Further, in the corresponding relationship between the preset level and the score corresponding to the third category, the score corresponding to code level A may be 75, the score corresponding to code level B may be 65, and the score corresponding to code level C may be 55. , the score corresponding to code level D may be 45.
具体的,可以先获取所属类别对应的预设等级与分值对应关系,然后从该预设等级与分值中,查找待检测代码对应的代码等级所对应的分值。Specifically, the corresponding relationship between the preset level and the score corresponding to the category may be obtained first, and then the score corresponding to the code level corresponding to the code to be detected is searched from the preset level and the score.
本发明实施例中,根据待检测代码中所使用的关键模块的数量、禁用模块的数量以及待检测运行结果与标准运行结果的匹配程度,进一步地细分待检测代码的类别,并为不同类别设置不同的等级与分值对应关系,根据待检测代码的所属类别针对性的查找待检测代码对应的分值,可以使得查找到的分值更能贴近实际情况,进而一定程度上提高分值的准确性。In the embodiment of the present invention, according to the number of key modules used in the code to be detected, the number of disabled modules, and the degree of matching between the running result to be detected and the standard running result, the categories of the code to be detected are further subdivided into different categories Setting the corresponding relationship between different levels and scores, and searching for the score corresponding to the code to be detected according to the category of the code to be detected, can make the found score closer to the actual situation, thereby improving the score to a certain extent. accuracy.
可选的,待检测代码相关数据还可以包括待检测代码的基础配置信息,相应地,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值的步骤,还可以包括下述步骤:Optionally, the data related to the code to be tested may also include basic configuration information of the code to be tested. Accordingly, according to the related data of the code to be tested and the standard code related data of the preset standard code, it is determined that the code to be tested is under the preset scoring dimension. The step of scoring the score value can also include the following steps:
步骤1024、根据所述基础配置信息及所述标准代码相关数据中定义的预设基础配置条件,确定所述待检测代码满足的预设基础配置条件的数量。Step 1024: Determine the number of preset basic configuration conditions that are satisfied by the code to be detected according to the basic configuration information and the preset basic configuration conditions defined in the standard code related data.
本步骤中,预设基础配置条件可以是根据实际情况设置的。示例的,预设基础配置条件可以包括以下至少一项:在生成待检测代码的过程中与嵌入式硬件设备成功建立连接、待检测代码被成功提交至检测设备以及待检测代码被成功下载至嵌入式硬件设备并对待检测代码执行了运行及验证操作。这样,通过设置正常进行代码检测所需满足的配置条件作为预设基础配置条件,一定程度上可以确保后续基于预设基础配置条件确定的第四评分分值的准确性。In this step, the preset basic configuration conditions may be set according to actual conditions. Exemplarily, the preset basic configuration conditions may include at least one of the following: successfully establishing a connection with the embedded hardware device in the process of generating the code to be tested, successfully submitting the code to be tested to the testing device, and successfully downloading the code to be tested to the embedded hardware device. It has run and verified the code to be tested. In this way, by setting the configuration condition that needs to be satisfied for normal code detection as the preset basic configuration condition, the accuracy of the subsequent fourth scoring value determined based on the preset basic configuration condition can be ensured to a certain extent.
进一步地,基础配置信息可以用于表征生成待检测代码时的基础配置情况。例如,基础配置信息可以包括表征待检测代码的过程中与嵌入式硬件设备是否成功建立连接的信息、表征待检测代码是否被成功提交至检测设备的信息以及待检测代码是否被成功下载至嵌入式硬件设备以及嵌入式硬件设备是否对待检测代码执行了运行及验证操作的信息。本步骤中,可以先针对每个预设基础配置条件,根据基础配置信息判断待检测代码是否满足该预设基础配置条件。最后,统计待检测代码满足的预设基础配置条件的总数量。Further, the basic configuration information can be used to represent the basic configuration when the code to be detected is generated. For example, the basic configuration information may include information representing whether the code to be tested is successfully connected to the embedded hardware device, information representing whether the code to be tested has been successfully submitted to the testing device, and whether the code to be tested has been successfully downloaded to the embedded hardware Information about whether the hardware device and embedded hardware device have performed the operation and verification operation of the code to be tested. In this step, for each preset basic configuration condition, it can be determined whether the code to be detected satisfies the preset basic configuration condition according to the basic configuration information. Finally, the total number of preset basic configuration conditions satisfied by the code to be detected is counted.
步骤1025、根据所述数量确定所述待检测代码在第四评分维度下的第四评分分值;其中,所述第四评分分值与所述数量正相关。Step 1025: Determine a fourth scoring value of the code to be detected under the fourth scoring dimension according to the number; wherein, the fourth scoring value is positively correlated with the number.
本步骤中,第四评分维度可以表征基础项维度,基础项维度可以用于从代码生成时的基础配置情况进行评判。如果满足的预设基础配置条件的数量越多,则可以认为待检测代码的配置情况越好,相应地,可以设置越高的第四评分分值。本发明实施例中,通过进一步结合基础配置情况从第四评分维度进行评判,进而一定程度上提高后续确定的整体评分的准确性。In this step, the fourth scoring dimension can represent the basic item dimension, and the basic item dimension can be used to judge from the basic configuration at the time of code generation. If the number of satisfied preset basic configuration conditions is greater, it can be considered that the configuration of the code to be detected is better, and accordingly, a higher fourth score can be set. In the embodiment of the present invention, by further combining with the basic configuration, the judgment is made from the fourth scoring dimension, thereby improving the accuracy of the overall score determined subsequently to a certain extent.
可选的,若所述数量与预设基础配置条件的总数量相匹配,则将第二预设值设置为所述第四评分分值;若所述数量与所述预设基础配置条件的总数量不相匹配,则将第三预设值设置为所述第四评分分值;所述第二预设值大于所述第三预设值。其中,第二预设值及第三预设值可以是根据实际需求设置的,示例的,第二预设值可以为100,第三预设值可以为0。即,在存在任意一个预设基础配置条件未满足的情况下,将第四评分分值设置为0,在所有预设基础配置条 件均满足的情况下,将第四评分分值设置为100。进一步地,如果存在预设基础配置条件未满足,则可以认为提交的待检测代码属于恶意测试,如果不存在预设基础配置条件未满足,则可以认为提交的待检测代码属于正常测试,本发明实施例根据数量选择第二预设值或第三预设值作为第四评分分值,一定程度上可以避免恶意测试的待检测代码最终的整体分值过大,正常测试的待检测代码最终的整体分值过小,进而确保后续确定的整体分值的均衡性。Optionally, if the number matches the total number of preset basic configuration conditions, the second preset value is set as the fourth scoring value; if the number matches the total number of preset basic configuration conditions If the total number does not match, the third preset value is set as the fourth score value; the second preset value is greater than the third preset value. The second preset value and the third preset value may be set according to actual requirements. For example, the second preset value may be 100, and the third preset value may be 0. That is, if any of the preset basic configuration conditions are not satisfied, the fourth score is set to 0, and when all the preset basic configuration conditions are satisfied, the fourth score is set to 100. Further, if there is a preset basic configuration condition that is not satisfied, it can be considered that the submitted code to be tested belongs to a malicious test. If there is no preset basic configuration condition that is not satisfied, it can be considered that the submitted code to be tested belongs to a normal test. The present invention The embodiment selects the second preset value or the third preset value as the fourth scoring value according to the number, to a certain extent, it can avoid that the final overall score of the code to be detected in the malicious test is too large, and the final code to be detected in the normal test is not detected. The overall score is too small, so as to ensure the balance of the overall score determined later.
可选的,根据预设评分维度下的评分分值,确定待检测代码的整体分值,可以具体包括:根据各个预设评分维度对应的维度权重,计算各个预设评分维度下的评分分值的加权和,进而得到整体分值。Optionally, determining the overall score of the code to be detected according to the scoring score under the preset scoring dimension may specifically include: calculating the scoring score under each preset scoring dimension according to the dimension weight corresponding to each preset scoring dimension. The weighted sum of , and then the overall score is obtained.
其中,各个预设评分维度对应的维度权重可以通过权重比例表定义,维度权重的具体值可以根据实际需求设置。示例的,第一评分维度对应的维度权重可以为40%,第二评分维度对应的维度权重可以为30%,第三评分维度对应的维度权重可以为20%,第四评分维度对应的维度权重可以为10%。The dimension weight corresponding to each preset scoring dimension may be defined through a weight ratio table, and the specific value of the dimension weight may be set according to actual requirements. For example, the dimension weight corresponding to the first scoring dimension may be 40%, the dimension weight corresponding to the second scoring dimension may be 30%, the dimension weight corresponding to the third scoring dimension may be 20%, and the dimension weight corresponding to the fourth scoring dimension Can be 10%.
下面以嵌入式硬件设备为机器人平台,本发明实施例中的应用于嵌入式平台的代码检测方法应用于Scratch编程场景的具体实例进行说明。示例的,图2是本发明实施例提供的一种评分流程示意图,如图2所示,标准用户可以预先通过Scratch编程终端将预设标准代码发送给机器人平台运行。机器人平台运行可以捕获运行结果,得到预设标准代码的标准运行结果。接着可以将预设标准代码的静态代码数据及标准运行结果作为标准代码相关数据提交给评分系统。其中,预设标准代码的静态代码数据可以包括标准模块信息、禁止使用的禁用模块的相关信息、预设基础配置条件以及预设检测配置信息。其中,该配置信息可以包括前述步骤中涉及的预设值、预设映射表、预设权重,等等。In the following, an embedded hardware device is used as a robot platform, and a specific example in which the code detection method applied to the embedded platform in the embodiment of the present invention is applied to a Scratch programming scenario will be described. By way of example, FIG. 2 is a schematic diagram of a scoring process provided by an embodiment of the present invention. As shown in FIG. 2 , a standard user can send a preset standard code to a robot platform for running through a Scratch programming terminal in advance. The operation of the robot platform can capture the operation results and obtain the standard operation results of the preset standard code. Then, the static code data of the preset standard code and the standard operation result may be submitted to the scoring system as standard code related data. Wherein, the static code data of the preset standard code may include standard module information, related information of prohibited modules that are prohibited from being used, preset basic configuration conditions, and preset detection configuration information. The configuration information may include preset values, preset mapping tables, preset weights, and the like involved in the preceding steps.
进一步地,待检测用户可以通过Scratch编程终端将待检测代码发送给机器人平台运行。机器人平台运行可以捕获运行结果,得到待检测运行结果。接着可以将待检测代码的静态代码数据及待检测运行结果作为待检测代码相关数据提交给评分系统。其中,在编程考核场景下,Scratch编程终端可以为考核机器,机器人平台可以为场景中的外置硬件,具体的硬件类型可以根据实际需求设置,以确保满足不同考核场景的要求即可。进一步地,待检测代码的静态代码数据可以包括待检测代码中所使用模块的相关信息、待检测代码的编程参数、待检测代码的代码长度及待检测代码的基础配置信息,等等。评分系统可以是检测设备搭载的用于执行本发明实施例中各个步骤的系统,评分系统可以为线上系统,检测设备可以为线上服务器,即,参与检测的数据可以为线上数据。最后,评分系统可以基于待检测代码相关数据以及标准代码相关数据,可以生成代码检测结果。Further, the user to be tested can send the code to be tested to the robot platform to run through the Scratch programming terminal. The operation of the robot platform can capture the operation results and obtain the operation results to be detected. Then, the static code data of the code to be tested and the running result of the code to be tested may be submitted to the scoring system as data related to the code to be tested. Among them, in the programming assessment scenario, the Scratch programming terminal can be the assessment machine, and the robot platform can be the external hardware in the scene. The specific hardware type can be set according to the actual needs to ensure that the requirements of different assessment scenarios are met. Further, the static code data of the code to be tested may include related information of modules used in the code to be tested, programming parameters of the code to be tested, code length of the code to be tested, basic configuration information of the code to be tested, and so on. The scoring system may be a system mounted on the detection device for performing each step in the embodiment of the present invention, the scoring system may be an online system, and the detection device may be an online server, that is, the data participating in the detection may be online data. Finally, the scoring system can generate code detection results based on the data related to the code to be tested and the data related to the standard code.
本发明实施例中,对不同的待检测代码采用相同的检测标准,可以确保代码检测的准确性。同时,通过结合真实应用场景中嵌入式硬件设备的运行结果进行检测,可以使检测结果更加适配真实应用场景,进一步提高代码检测的准确性。In the embodiment of the present invention, the same detection standard is used for different codes to be detected, which can ensure the accuracy of code detection. At the same time, by combining the operation results of embedded hardware devices in real application scenarios for detection, the detection results can be more suitable for real application scenarios, and the accuracy of code detection can be further improved.
图3是本发明实施例提供的一种应用于嵌入式平台的代码检测装置的框图,该装置可以包括:存储器301和处理器302。FIG. 3 is a block diagram of a code detection apparatus applied to an embedded platform provided by an embodiment of the present invention. The apparatus may include: a memory 301 and a processor 302 .
所述存储器301,用于存储程序代码。The memory 301 is used to store program codes.
所述处理器302,调用所述程序代码,当所述程序代码被执行时,用于执行以下操作:The processor 302 calls the program code, and when the program code is executed, is configured to perform the following operations:
获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
具体的,处理器302执行的各个操作的具体实现过程可以参照前述方法实施例中的相关描述,此处不再赘述。Specifically, for the specific implementation process of each operation performed by the processor 302, reference may be made to the relevant descriptions in the foregoing method embodiments, which will not be repeated here.
综上所述,本发明实施例提供的应用于嵌入式平台的代码检测装置,可以获取待检测代码的代码相关数据,作为待检测代码相关数据。其中,待检测代码相关数据包括待检测运行结果,待检测运行结果是根据待检测代码的嵌入式硬件设备对待检测代码运行得到的,待检测运行结果包括嵌入式硬件设备中传感器的输出数据,接着,根据待检测代码相关数据及预设标准代码的标准代码相关数据,确定待检测代码在预设评分维度下的评分分值,最后,根据预设评分维度下的评分分值,确定待检测代码的整体分值,得到代码检测结果。这样,由实际应用场景中真实的嵌入式硬件设备对待检测代码运行得到真实的运行结果,并根据实际应用场景中真实的运行结果进行评分,进而一定程度上可以提高检测结果的准确性,提高检测效果。To sum up, the code detection apparatus applied to the embedded platform provided by the embodiment of the present invention can acquire the code related data of the code to be detected as the code related data to be detected. The data related to the code to be detected includes the running result to be detected, the running result to be detected is obtained by running the code to be detected according to the embedded hardware device of the code to be detected, and the running result to be detected includes the output data of the sensor in the embedded hardware device, and then , according to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension, and finally, according to the scoring value under the preset scoring dimension, determine the code to be detected. The overall score of , get the code detection result. In this way, the real running results are obtained by running the code to be detected by the real embedded hardware device in the actual application scenario, and the scores are scored according to the real running results in the actual application scenario, thereby improving the accuracy of the detection results to a certain extent and improving the detection performance. Effect.
进一步地,本发明实施例还提供一种检测设备,所述检测设备用于执行上述应用于嵌入式平台的代码检测方法实施例中的步骤。Further, an embodiment of the present invention further provides a detection device, and the detection device is configured to perform the steps in the above embodiments of the code detection method applied to an embedded platform.
本发明实施例还提供一种嵌入式硬件设备,所述嵌入式硬件设备用于对待检测代码运行,并将运行得到的运行结果发送给上述检测设备。可选的,所述嵌入式硬件设备为无人机、无人车、机器人中的一种或多种。An embodiment of the present invention further provides an embedded hardware device, the embedded hardware device is used for running the code to be detected, and sending the running result obtained from the running to the above-mentioned detection device. Optionally, the embedded hardware device is one or more of drones, unmanned vehicles, and robots.
进一步地,本发明实施例还提供一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现上述应用于嵌入式平台的代码检测方法中的各个步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。Further, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the above-mentioned code detection method applied to an embedded platform is implemented and can achieve the same technical effect, in order to avoid repetition, it will not be repeated here.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器来实现根据本发明实施例的计算处理设备中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。Various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor may be used in practice to implement some or all of the functions of some or all of the components in the computing processing device according to the embodiments of the present invention. The present invention can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet sites, or provided on carrier signals, or in any other form.
例如,图4为本发明实施例提供的一种计算处理设备的框图,如图4所示,图4示出了可以实现根据本发明的方法的计算处理设备。该计算处理设备传统上包括处理器710和以存储器720形式的计算机程序产品或者计算机可读介质。存储器720可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器720具有用于执行上述方法中的任何方法步骤的程序代码的存储空间730。例如,用于程序代码的存储空间730可以包括分别用于实现上面的方法中的各种步骤的各个程序代码。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图5所述的便携式或者固定存储单元。该存储单元可以具有与图4的计算处理设备中的存储器720类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码,即可以由例如诸如710之类的处理器读取的代码,这些代码当由计算处理设备运行时,导致该计算处理设备执行上面所描述的方法中的各个步骤。For example, FIG. 4 is a block diagram of a computing processing device provided by an embodiment of the present invention. As shown in FIG. 4 , FIG. 4 shows a computing processing device that can implement the method according to the present invention. The computing processing device traditionally includes a processor 710 and a computer program product or computer readable medium in the form of a memory 720 . The memory 720 may be electronic memory such as flash memory, EEPROM (electrically erasable programmable read only memory), EPROM, hard disk, or ROM. The memory 720 has storage space 730 for program code for performing any of the method steps in the above-described methods. For example, the storage space 730 for program codes may include various program codes for implementing various steps in the above methods, respectively. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such computer program products are typically portable or fixed storage units as described with reference to FIG. 5 . The storage unit may have storage segments, storage spaces, etc. arranged similarly to the memory 720 in the computing processing device of FIG. 4 . The program code may, for example, be compressed in a suitable form. Typically, the storage unit includes computer readable code, ie code readable by a processor such as 710 for example, which when executed by a computing processing device, causes the computing processing device to perform each of the methods described above. step.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other.
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。Reference herein to "one embodiment," "an embodiment," or "one or more embodiments" means that a particular feature, structure, or characteristic described in connection with an embodiment is included in at least one embodiment of the present invention. Also, please note that instances of the phrase "in one embodiment" herein are not necessarily all referring to the same embodiment.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. It will be understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be The technical solutions described in the foregoing embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (23)

  1. 一种应用于嵌入式平台的代码检测方法,其特征在于,应用于检测设备,所述方法包括:A code detection method applied to an embedded platform, characterized in that, applied to a detection device, the method comprising:
    获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
    根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
    根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
  2. 根据权利要求1所述方法,其特征在于,所述待检测代码相关数据还包括所述待检测代码中所使用模块的相关信息;所述根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值,包括:The method according to claim 1, wherein the data related to the code to be detected further includes related information of modules used in the code to be detected; Standard code-related data, determine the scoring value of the code to be detected under the preset scoring dimension, including:
    根据所述待检测运行结果与所述标准代码相关数据中的标准运行结果,确定所述待检测代码在第一评分维度下的第一评分分值;According to the running result to be detected and the standard running result in the relevant data of the standard code, determine the first scoring value of the code to be detected under the first scoring dimension;
    根据所述所使用模块的相关信息及所述标准代码相关数据中的标准模块信息,确定所述待检测代码在第二评分维度下的第二评分分值。According to the related information of the used module and the standard module information in the standard code related data, the second scoring value of the code to be detected under the second scoring dimension is determined.
  3. 根据权利要求2所述方法,其特征在于,所述标准模块信息包括所述预设标准代码中所使用的标准模块的相关信息,所述根据所述所使用模块的相关信息及所述标准代码相关数据中的标准模块信息,确定所述待检测代码在第二评分维度下的第二评分分值,包括:The method according to claim 2, wherein the standard module information comprises relevant information of a standard module used in the preset standard code, and the information according to the relevant information of the used module and the standard code The standard module information in the relevant data determines the second scoring value of the code to be detected under the second scoring dimension, including:
    根据所述所使用模块的相关信息与所述标准模块的相关信息进行匹配,以确定所述所使用模块中与所述标准模块相匹配的第一模块的第一数量,和/或,确定所述第一模块中所使用参数与所述标准模块的使用参数相匹配的第二模块的第二数量;Matching the relevant information of the used modules with the relevant information of the standard modules to determine the first number of the first modules in the used modules that match the standard modules, and/or to determine the the second number of second modules whose parameters used in the first module match those of the standard module;
    根据第一比值和/或第二比值,确定所述第二评分分值;所述第一比值为所述第一数量与所述标准模块的总数量的比值,所述第二比值为所述第二数量与所述第一数量的比值。The second score is determined according to the first ratio and/or the second ratio; the first ratio is the ratio of the first quantity to the total quantity of the standard modules, and the second ratio is the The ratio of the second quantity to the first quantity.
  4. 根据权利要求3所述方法,其特征在于,所述标准模块信息还包括所述预设标准代码中禁止使用的禁用模块的相关信息;所述根据第一比值和/或第二比值,确定所述第二评分分值,包括:The method according to claim 3, characterized in that, the standard module information further includes information about disabled modules that are prohibited from being used in the preset standard code; The second scoring score, including:
    根据所述第一比值及所述第二比值,生成第一数值;所述第一数值与所述第一比值及所述第二比值正相关;generating a first numerical value according to the first ratio and the second ratio; the first numerical value is positively correlated with the first ratio and the second ratio;
    根据所述所使用模块的相关信息与所述禁用模块的相关信息进行匹配,以确定所述所使用模块中与所述禁止模块相匹配的第三模块的第三数量;Matching according to the relevant information of the used module and the relevant information of the forbidden module to determine a third number of third modules in the used modules that match the forbidden module;
    根据所述第三数量与所述禁用模块的总数量之间的第三比值,减小所述第一数值;所述第一数值的减小量与所述第三比值正相关;reducing the first numerical value according to a third ratio between the third quantity and the total quantity of the disabled modules; the reduction of the first numerical value is positively correlated with the third ratio;
    将减小后的所述第一数值确定为所述第二评分分值。The reduced first numerical value is determined as the second scoring score.
  5. 根据权利要求2所述方法,其特征在于,所述标准运行结果为所述预设标准代码在所述嵌入式硬件设备上运行的运行结果,所述根据所述待检测运行结果与所述标准代码相关数据中的标准运行结果,确定所述待检测代码在第一评分维度下的第一评分分值,包括:The method according to claim 2, wherein the standard running result is the running result of the preset standard code running on the embedded hardware device, and the running result according to the to-be-detected running result and the standard The standard operation result in the code-related data determines the first scoring value of the code to be detected under the first scoring dimension, including:
    对于任一所述传感器,根据所述待检测运行结果中输出数据的变化信息与所述标准运行结果中输出数据的变化信息的匹配程度,确定所述传感器对应的评分分值;所述传感器对应的评分分值与所述匹配程度正相关;For any one of the sensors, according to the degree of matching between the change information of the output data in the operation result to be detected and the change information of the output data in the standard operation result, determine the score corresponding to the sensor; the sensor corresponds to The score of the score is positively correlated with the matching degree;
    根据各个所述传感器对应的评分分值,确定所述第一评分分值。The first scoring value is determined according to the scoring value corresponding to each of the sensors.
  6. 根据权利要求5所述方法,其特征在于,对于运动类型的传感器,所述根据所述待检测运行结果中输出数据的变化信息与所述标准运行结果中输出数据的变化信息的匹配程度,确定所述传感器对应的评分分值,包括:The method according to claim 5, wherein, for a motion type sensor, the determination is based on the degree of matching between the change information of the output data in the operation result to be detected and the change information of the output data in the standard operation result. The scores corresponding to the sensors include:
    按照时间顺序依次获取所述传感器的输出曲线中的极值点,并根据获取到的极值点生成极值点变化序列;所述传感器的输出曲线根据所述传感器的输出数据确定;Acquire extremum points in the output curve of the sensor in time sequence, and generate an extremum point variation sequence according to the acquired extremum points; the output curve of the sensor is determined according to the output data of the sensor;
    根据所述极值点变化序列与所述标准运行结果中所述传感器的标准极值点变化序列,确定所述极值点变化序列中与所述标准极值点变化序列相匹配的极值点;According to the extreme point change sequence and the standard extreme point change sequence of the sensor in the standard operation result, determine the extreme point in the extreme point change sequence that matches the standard extreme point change sequence ;
    计算第一长度与第二长度之间的第三比值;所述第一长度为所述相匹配的极值点组成的变化序列的长度,所述第二长度为所述标准极值点变化序列的长度,所述匹配程度与所述第三比值正相关;Calculate a third ratio between the first length and the second length; the first length is the length of the change sequence composed of the matched extreme points, and the second length is the standard extreme point change sequence The length of the matching degree is positively correlated with the third ratio;
    根据所述第三比值,确定所述传感器对应的评分分值。According to the third ratio, the score corresponding to the sensor is determined.
  7. 根据权利要求5所述方法,其特征在于,对于非运动类型的传感器,所述根据所述待检测运行结果中输出数据的变化信息与所述标准运行结果中输出数据的变化信息的匹配程度,确定所述传感器对应的评分分值,包括:The method according to claim 5, wherein, for a non-motion type sensor, according to the degree of matching between the change information of the output data in the operation result to be detected and the change information of the output data in the standard operation result, Determining the score corresponding to the sensor includes:
    计算所述待检测运行结果中输出数据的输出值变化序列与所述标准运行结果中输出数据的输出值变化序列之间的误差值;所述匹配程度与所述误差值负相关;calculating the error value between the output value variation sequence of the output data in the running result to be detected and the output value variation sequence of the output data in the standard running result; the matching degree is negatively correlated with the error value;
    根据所述误差值,确定所述传感器对应的评分分值。According to the error value, the score value corresponding to the sensor is determined.
  8. 根据权利要求6所述方法,其特征在于,所述按照时间顺序依次获取所述传感器的输出曲线中的极值点,包括:The method according to claim 6, wherein the step of sequentially acquiring extreme points in the output curve of the sensor in time sequence comprises:
    根据所述传感器输出的参数值以及初始参数值,确定各个时刻下输出的相对参数值;According to the parameter value output by the sensor and the initial parameter value, determine the relative parameter value output at each moment;
    根据所述各个时刻下输出的相对参数值,生成所述输出曲线;generating the output curve according to the relative parameter values output at each moment;
    按照时间顺序依次获取所述输出曲线中的极值点;Acquiring the extreme points in the output curve sequentially in time sequence;
    其中,所述传感器为角度传感器、位置传感器或加速度传感器,所述参数值为所述角度传感器输出的角度、所述位置传感器输出的位置或所述加速度传感器输出的加速度。The sensor is an angle sensor, a position sensor or an acceleration sensor, and the parameter value is the angle output by the angle sensor, the position output by the position sensor, or the acceleration output by the acceleration sensor.
  9. 根据权利要求6所述方法,其特征在于,所述方法还包括:The method according to claim 6, wherein the method further comprises:
    根据预设的滤波算法,对所述传感器的输出数据中出现的异常极值点进行过滤。According to a preset filtering algorithm, the abnormal extreme value points appearing in the output data of the sensor are filtered.
  10. 根据权利要求2所述方法,其特征在于,所述待检测代码相关数据还包括所述待检测代码的编程参数,所述编程参数包括所述待检测代码的编程时长和/或调试次数;所述方法还包括:The method according to claim 2, wherein the data related to the code to be detected further includes programming parameters of the code to be detected, and the programming parameter includes the programming duration and/or the number of times of debugging of the code to be detected; The method also includes:
    根据所述编程参数,确定所述待检测代码在第三评分维度下的第三评分分值;According to the programming parameter, determine the third scoring value of the code to be detected under the third scoring dimension;
    其中,所述编程参数越小,所述第三评分分值越大。Wherein, the smaller the programming parameter is, the larger the third score is.
  11. 根据权利要求10所述方法,其特征在于,所述待检测代码为多个待检测代码;所述根据所述编程参数,确定所述待检测代码在第三评分维度下的第三评分分值,包括:The method according to claim 10, wherein the code to be detected is a plurality of codes to be detected; the third scoring value of the code to be detected under a third scoring dimension is determined according to the programming parameter ,include:
    对于任一所述编程参数,按照所述编程参数的大小,将所述多个待检测代码划分至不同代码等级;其中,所述代码等级越高,所述代码等级对应的待检测代码的编程参数越小;For any of the programming parameters, according to the size of the programming parameter, the plurality of codes to be detected are divided into different code levels; wherein, the higher the code level is, the higher the code level corresponds to the programming of the code to be detected. The smaller the parameter;
    对于任一所述待检测代码,根据所述待检测代码对应的代码等级,确定所述编程参数对应的分值;所述编程参数对应的分值与所述代码等级正相关;For any of the codes to be detected, the score corresponding to the programming parameter is determined according to the code level corresponding to the code to be detected; the score corresponding to the programming parameter is positively correlated with the code level;
    根据所述编程参数对应的分值,确定所述第三评分分值。The third scoring score is determined according to the score corresponding to the programming parameter.
  12. 根据权利要求11所述方法,其特征在于,所述根据所述待检测代码对应的代码等级,确定所述编程参数对应的分值,包括:The method according to claim 11, wherein the determining the score corresponding to the programming parameter according to the code level corresponding to the code to be detected, comprises:
    根据所述待检测代码中所使用的关键模块的数量、禁用模块的数量以及所述待检测运行结果与所述标准运行结果的匹配程度,确定所述待检测代码的所属类别;According to the number of key modules used in the code to be detected, the number of disabled modules and the degree of matching between the running result to be detected and the standard running result, determine the category of the code to be detected;
    从与所述所属类别对应的预设等级与分值对应关系中,查找所述待检测代码对应的代码等级对应的分值,得到所述编程参数对应的分值;Searching for the score corresponding to the code level corresponding to the code to be detected from the corresponding relationship between the preset level and the score corresponding to the category, and obtaining the score corresponding to the programming parameter;
    其中,不同类别对应的预设等级与分值对应关系中,同一等级对应的分值不同。Wherein, in the corresponding relationship between preset levels and scores corresponding to different categories, the scores corresponding to the same level are different.
  13. 根据权利要求12所述方法,其特征在于,所述待检测代码相关数据还包括所述待检测代码的代码长度;所述按照所述编程参数的大小,将所述多个待检测代码划分至不同代码等级之前,所述方法还包括:The method according to claim 12, wherein the data related to the codes to be detected further comprises a code length of the codes to be detected; and the plurality of codes to be detected are divided into Before different code levels, the method further includes:
    确定所述待检测代码的代码长度是否满足预设长度要求;Determine whether the code length of the code to be detected meets the preset length requirement;
    若所述代码长度不满足所述预设长度要求且所述所使用的关键模块的数量为预设数量,则将第一 预设值确定为所述第三评分分值;If the code length does not meet the preset length requirement and the quantity of the used key modules is a preset quantity, then the first preset value is determined as the third scoring value;
    若所述代码长度满足所述预设长度要求和/或所述所使用的关键模块的数量不为所述预设数量,则执行所述按照所述编程参数的大小,将所述多个待检测代码划分至不同代码等级的步骤。If the code length satisfies the preset length requirement and/or the number of the used key modules is not the preset number, executing the step according to the size of the programming parameter to Steps in which the detection code is divided into different code levels.
  14. 根据权利要求2至13任一所述方法,其特征在于,所述待检测代码相关数据还包括所述待检测代码的基础配置信息,所述方法还包括:The method according to any one of claims 2 to 13, wherein the data related to the code to be detected further includes basic configuration information of the code to be detected, and the method further includes:
    根据所述基础配置信息及所述标准代码相关数据中定义的预设基础配置条件,确定所述待检测代码满足的预设基础配置条件的数量;According to the basic configuration information and the preset basic configuration conditions defined in the standard code related data, determine the number of preset basic configuration conditions that the code to be detected satisfies;
    根据所述数量确定所述待检测代码在第四评分维度下的第四评分分值;其中,所述第四评分分值与所述数量正相关。A fourth scoring value of the code to be detected under a fourth scoring dimension is determined according to the number; wherein, the fourth scoring value is positively correlated with the number.
  15. 根据权利要求14所述方法,其特征在于,所述根据所述数量确定所述待检测代码在第四评分维度下的第四评分分值,包括:The method according to claim 14, wherein the determining the fourth scoring value of the code to be detected under the fourth scoring dimension according to the quantity comprises:
    若所述数量与所述预设基础配置条件的总数量相匹配,则将第二预设值设置为所述第四评分分值;If the number matches the total number of the preset basic configuration conditions, setting the second preset value as the fourth scoring value;
    若所述数量与所述预设基础配置条件的总数量不相匹配,则将第三预设值设置为所述第四评分分值,所述第二预设值大于所述第三预设值。If the number does not match the total number of the preset basic configuration conditions, a third preset value is set as the fourth score value, and the second preset value is greater than the third preset value value.
  16. 根据权利要求14所述方法,其特征在于,所述预设基础配置条件包括以下至少一项:在生成所述待检测代码的过程中与所述嵌入式硬件设备成功建立连接、所述待检测代码被成功提交至所述检测设备以及所述待检测代码被成功下载至所述嵌入式硬件设备并对所述待检测代码执行了运行及验证操作。The method according to claim 14, wherein the preset basic configuration conditions include at least one of the following: a connection is successfully established with the embedded hardware device in the process of generating the code to be detected, the The code is successfully submitted to the testing device and the code to be tested is successfully downloaded to the embedded hardware device and execution and verification operations are performed on the code to be tested.
  17. 根据权利要求2所述方法,其特征在于,所述方法还包括:The method according to claim 2, wherein the method further comprises:
    根据所述待检测运行结果中与所述标准代码相关数据中不相匹配的数据,确定报错信息;According to the data that does not match the standard code-related data in the running result to be detected, determine the error message;
    输出所述报错信息。Output the error message.
  18. 根据权利要求1所述方法,其特征在于,所述嵌入式硬件设备分别与代码生成设备及所述检测设备连接;所述代码生成设备用于将所述待检测代码发送至所述嵌入式硬件设备运行,所述待检测运行结果是所述嵌入式硬件设备对所述待检测代码运行结束后发送给所述检测设备的;The method according to claim 1, wherein the embedded hardware device is respectively connected to a code generation device and the detection device; the code generation device is configured to send the code to be detected to the embedded hardware The device is running, and the running result to be detected is sent to the detection device after the embedded hardware device finishes running the code to be detected;
    所述代码生成设备与所述检测设备连接,所述代码生成设备用于将所述待检测代码相关数据中除所述待检测运行结果之外的其他信息,发送给所述检测设备。The code generation device is connected to the detection device, and the code generation device is configured to send other information in the data related to the code to be detected except the running result to be detected to the detection device.
  19. 一种应用于嵌入式平台的代码检测装置,其特征在于,所述装置包括存储器和处理器;A code detection device applied to an embedded platform, characterized in that the device includes a memory and a processor;
    所述存储器,用于存储程序代码;the memory for storing program codes;
    所述处理器,调用所述程序代码,当所述程序代码被执行时,用于执行以下操作:The processor calls the program code, and when the program code is executed, is configured to perform the following operations:
    获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
    根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
    根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
  20. 一种检测设备,其特征在于,所述检测设备用于执行权利要求1至18中任一项所述的应用于嵌入式平台的代码检测方法中的步骤。A detection device, characterized in that, the detection device is used to execute the steps in the code detection method applied to an embedded platform according to any one of claims 1 to 18.
  21. 一种嵌入式硬件设备,其特征在于,所述嵌入式硬件设备用于对待检测代码运行,并将运行得到的运行结果发送给权利要求20中所述的检测设备。An embedded hardware device, characterized in that the embedded hardware device is used for running the code to be detected, and sending the running result obtained from the running to the detection device described in claim 20 .
  22. 根据权利要求21所述方法,其特征在于,所述嵌入式硬件设备为无人机、无人车、机器人中的一种或多种。The method according to claim 21, wherein the embedded hardware device is one or more of an unmanned aerial vehicle, an unmanned vehicle, and a robot.
  23. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现以下操作:A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following operations are implemented:
    获取待检测代码的代码相关数据,作为待检测代码相关数据;所述待检测代码相关数据包括待检测运行结果,所述待检测运行结果是根据所述待检测代码的嵌入式硬件设备对所述待检测代码运行得到的,所述待检测运行结果包括所述嵌入式硬件设备中传感器的输出数据;The code-related data of the code to be detected is obtained as the code-related data to be detected; the data related to the code to be detected includes the running result to be detected, and the running result to be detected is based on the embedded hardware device of the code to be detected. Obtained by running the code to be detected, and the running result to be detected includes output data of sensors in the embedded hardware device;
    根据所述待检测代码相关数据及预设标准代码的标准代码相关数据,确定所述待检测代码在预设评分维度下的评分分值;According to the relevant data of the code to be detected and the relevant data of the standard code of the preset standard code, determine the scoring value of the code to be detected under the preset scoring dimension;
    根据所述预设评分维度下的评分分值,确定所述待检测代码的整体分值,得到代码检测结果。According to the scoring score under the preset scoring dimension, the overall score of the code to be detected is determined, and the code detection result is obtained.
PCT/CN2020/114437 2020-09-10 2020-09-10 Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium WO2022051974A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/114437 WO2022051974A1 (en) 2020-09-10 2020-09-10 Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/114437 WO2022051974A1 (en) 2020-09-10 2020-09-10 Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium

Publications (1)

Publication Number Publication Date
WO2022051974A1 true WO2022051974A1 (en) 2022-03-17

Family

ID=80632611

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/114437 WO2022051974A1 (en) 2020-09-10 2020-09-10 Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium

Country Status (1)

Country Link
WO (1) WO2022051974A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104111888A (en) * 2014-07-03 2014-10-22 曹建楠 Code evaluation method, device and system for teaching
US20150309920A1 (en) * 2014-04-29 2015-10-29 Hitachi, Ltd. Method and system for testing control software of a controlled system
CN105427695A (en) * 2015-11-03 2016-03-23 中国农业大学 Automatic evaluation method and system for programming type examination question
CN107229561A (en) * 2016-03-24 2017-10-03 华为技术有限公司 Applied program testing method and equipment
CN110502428A (en) * 2019-07-08 2019-11-26 平安科技(深圳)有限公司 Code test method, device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150309920A1 (en) * 2014-04-29 2015-10-29 Hitachi, Ltd. Method and system for testing control software of a controlled system
CN104111888A (en) * 2014-07-03 2014-10-22 曹建楠 Code evaluation method, device and system for teaching
CN105427695A (en) * 2015-11-03 2016-03-23 中国农业大学 Automatic evaluation method and system for programming type examination question
CN107229561A (en) * 2016-03-24 2017-10-03 华为技术有限公司 Applied program testing method and equipment
CN110502428A (en) * 2019-07-08 2019-11-26 平安科技(深圳)有限公司 Code test method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
US11494594B2 (en) Method for training model and information recommendation system
CN106846362B (en) Target detection tracking method and device
CN108829808B (en) Page personalized sorting method and device and electronic equipment
WO2019223384A1 (en) Feature interpretation method and device for gbdt model
CN109815988B (en) Model generation method, classification method, device and computer-readable storage medium
TW201947463A (en) Model test method and device
CN108960269B (en) Feature acquisition method and device for data set and computing equipment
CN112488218A (en) Image classification method, and training method and device of image classification model
CN111860568B (en) Method and device for balanced distribution of data samples and storage medium
CN107766316B (en) Evaluation data analysis method, device and system
CN106998336B (en) Method and device for detecting user in channel
CN111652145A (en) Formula detection method and device, electronic equipment and storage medium
CN112995690B (en) Live content category identification method, device, electronic equipment and readable storage medium
CN113919432A (en) Classification model construction method, data classification method and device
CN112100509B (en) Information recommendation method, device, server and storage medium
WO2022051974A1 (en) Code inspection method and apparatus applied to embedded platform, device and computer-readable storage medium
US11527091B2 (en) Analyzing apparatus, control method, and program
CN109460474B (en) User preference trend mining method
CN116912911A (en) Satisfaction data screening method and device, electronic equipment and storage medium
CN116127450A (en) Model evaluation method and device
CN115861890A (en) Video analysis method and device, electronic equipment and storage medium
CN115859065A (en) Model evaluation method, device, equipment and storage medium
CN112434717B (en) Model training method and device
JP2003196662A (en) Cut detection device and its program
CN113918471A (en) Test case processing method and device and computer readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20952762

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20952762

Country of ref document: EP

Kind code of ref document: A1