Optical port test fixture configuration information reading method, device and optical port test fixture
By using preset data structures and verification value mechanisms in the optical port test fixture, the write failure problem caused by power failure is solved, and the configuration information of the optical port test fixture is accurately read, ensuring effective testing of the switch's optical communication port.
Patent Information
- Application Number
- CN202410677171.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2044-05-29
AI Technical Summary
The optical port test fixture loses power during the erase or writing of nonvolatile media, resulting in the failure to accurately read configuration information, affecting the effective testing of the switch's optical communication port.
The optical port test fixture configuration information is constructed using preset data structures, and the reference check value is determined before writing to the nonvolatile medium. The configuration information is written to multiple pages of the nonvolatile medium, and the success of the writing process is judged based on the written verification value, so as to accurately read the configuration information.
It realizes accurate reading of effective configuration information when the optical port test fixture is powered off, avoids data loss caused by write failure, and ensures effective testing of the switch's optical communication port.
Smart Images

Figure CN118250168B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for reading configuration information of an optical port test fixture, and an optical port test fixture. Background Art
[0002] The optical communication port of the switch needs to be tested before the switch leaves the factory. Currently, an optical port test fixture is often used to test the optical communication port of the switch. In the process of using the optical port test fixture to test the optical communication port of the switch, the configuration information of the optical port test fixture needs to be permanently stored with the help of non-volatile media.
[0003] It is known from the related art that the non-volatile medium built into the optical port test fixture needs to be erased before being written in the process of saving information. If the optical port test fixture loses power during the erasing or writing process of the non-volatile medium, there will be a risk of failure to write data to the non-volatile medium, and it will be impossible to determine whether the configuration information of the optical port test fixture read is valid information, which will affect the optical port test fixture's effective testing of the optical communication port of the switch.
[0004] Therefore, currently, finding a method for reading the configuration information of the optical port test fixture that is not affected by the power failure of the optical port test fixture has become a research hotspot. Summary of the invention
[0005] The present invention provides a method and device for reading configuration information of an optical port test fixture and an optical port test fixture, which can accurately read effective configuration information of the optical port test fixture, thereby being unaffected by power failure of the optical port test fixture during operation.
[0006] The present invention provides a method for reading optical port test fixture configuration information, the method comprising: constructing optical port test fixture configuration information according to a preset data structure to obtain constructed optical port test fixture configuration information, wherein the preset data structure at least comprises a check value site and an optical port test fixture configuration information site; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain first page optical port test fixture configuration information written into the first page; based on the first page optical port test fixture configuration information, calculating a first page check value corresponding to the first page optical port test fixture configuration information; based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium.
[0007] According to a method for reading configuration information of an optical port test fixture provided by the present invention, the optical port test fixture configuration information is obtained by reading from the non-volatile medium based on the reference check value and the first page check value, specifically including: when the reference check value and the first page check value are the same, the optical port test fixture configuration information is obtained by reading from the first page of the non-volatile medium.
[0008] According to a method for reading optical port test fixture configuration information provided by the present invention, the method also includes: when the reference check value and the first page check value are different, issuing an alarm reminder, wherein the alarm reminder is used to prompt the user that there is an error in the first page optical port test fixture configuration information written to the first page.
[0009] According to a method for reading optical port test fixture configuration information provided by the present invention, after writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain the first page optical port test fixture configuration information written on the first page, the method further includes: writing the constructed optical port test fixture configuration information into a second page of a non-volatile medium to obtain the second page optical port test fixture configuration information written on the second page, wherein the second page is different from the first page; after calculating the first page check value corresponding to the first page optical port test fixture configuration information based on the first page optical port test fixture configuration information, the method further includes: calculating the second page check value corresponding to the second page optical port test fixture configuration information based on the second page optical port test fixture configuration information; the optical port test fixture configuration information is obtained by reading from the non-volatile medium based on the reference check value and the first page check value, specifically including: reading from the non-volatile medium the optical port test fixture configuration information based on the reference check value, the first page check value and the second page check value.
[0010] According to a method for reading configuration information of an optical port test fixture provided by the present invention, the optical port test fixture configuration information is obtained by reading from the non-volatile medium based on the reference check value, the first page check value and the second page check value, specifically including: when the reference check value is the same as the first page check value, and the reference check value is different from the second page check value, the optical port test fixture configuration information is obtained by reading from the first page of the non-volatile medium.
[0011] According to a method for reading configuration information of an optical port test fixture provided by the present invention, the optical port test fixture configuration information is obtained by reading from the non-volatile medium based on the reference check value, the first page check value and the second page check value, specifically including: when the reference check value is the same as the second page check value, and the reference check value is different from the first page check value, the optical port test fixture configuration information is obtained by reading from the second page of the non-volatile medium.
[0012] According to a method for reading optical port test fixture configuration information provided by the present invention, the preset data structure also includes a write count position, wherein the write count position stores a count value for representing the number of times the first page optical port test fixture configuration information and / or the second page optical port test fixture configuration information are written into the non-volatile medium; the method also includes: based on the first page optical port test fixture configuration information, calculating a first page count value corresponding to the first page optical port test fixture configuration information; based on the second page optical port test fixture configuration information, calculating a second page count value corresponding to the second page optical port test fixture configuration information; the count value based on the reference check value, the The first page check value and the second page check value are read from the non-volatile medium to obtain the optical port test fixture configuration information, specifically including: when the reference check value is equal to the first page check value, and the reference check value is equal to the second page check value, judging the size of the first page count value and the second page count value; when the first page count value is greater than the second page count value, reading the optical port test fixture configuration information from the first page of the non-volatile medium; when the first page count value is less than the second page count value, reading the optical port test fixture configuration information from the second page of the non-volatile medium.
[0013] According to a method for reading optical port test fixture configuration information provided by the present invention, the reference verification value is determined in the following manner: obtaining verification configuration information of the constructed optical port test fixture configuration information, wherein the verification configuration information is information located within the verification value site interval in the constructed optical port test fixture configuration information; based on the verification configuration information, processing is performed in accordance with a preset verification processing method to obtain a reference verification value corresponding to the constructed optical port test fixture configuration information.
[0014] According to a method for reading optical port test fixture configuration information provided by the present invention, the first page check value is determined in the following manner: obtaining the first page check configuration information of the first page optical port test fixture configuration information, wherein the first page check configuration information is information located within the check value site interval in the first page optical port test fixture configuration information; based on the first page check configuration information, processing is performed in accordance with the preset check processing method that is the same as the check configuration information to obtain the first page check value corresponding to the first page optical port test fixture configuration information.
[0015] According to a method for reading optical port test fixture configuration information provided by the present invention, the second page verification value is determined in the following manner: obtaining the second page verification configuration information of the second page optical port test fixture configuration information, wherein the second page verification configuration information is information located within the verification value site interval in the second page optical port test fixture configuration information; based on the second page verification configuration information, processing is performed in accordance with a preset verification processing method that is the same as the verification configuration information to obtain the second page verification value corresponding to the second page optical port test fixture configuration information.
[0016] According to a method for reading configuration information of an optical port test fixture provided by the present invention, the configuration information of the optical port test fixture includes plug count value configuration information, production date configuration information and production serial number configuration information.
[0017] According to a method for reading optical port test fixture configuration information provided by the present invention, the post-construction optical port test fixture configuration information includes post-construction plug-in count value configuration information, post-construction production date configuration information and post-construction production serial number configuration information; the first page includes multiple different first sub-pages; the post-construction optical port test fixture configuration information is written into the first page of a non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page, specifically including: writing the post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information into different first sub-pages respectively to obtain the first page plug-in count value configuration information, the first page production date configuration information and the first page production serial number configuration information written into different first sub-pages.
[0018] According to a method for reading optical port test fixture configuration information provided by the present invention, the post-construction optical port test fixture configuration information includes post-construction plug-in count value configuration information, post-construction production date configuration information and post-construction production serial number configuration information; the second page includes multiple different second sub-pages; the post-construction optical port test fixture configuration information is written into the second page of a non-volatile medium to obtain the second page optical port test fixture configuration information written into the second page, specifically including: writing the post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information into different second sub-pages respectively to obtain the second page plug-in count value configuration information, the second page production date configuration information and the second page production serial number configuration information written into different second sub-pages.
[0019] According to a method for reading configuration information of an optical port test fixture provided by the present invention, the method also includes: when it is monitored that the plug count value in the first page plug count value configuration information written into the first sub-page is greater than or equal to the plug count value, an alarm reminder is issued, wherein the alarm reminder is used to remind the user that the frequency of use of the optical port test fixture exceeds the service life.
[0020] According to a method for reading configuration information of an optical port test jig provided by the present invention, after the optical port test jig configuration information is read by the non-volatile medium based on the reference check value and the first page check value, the method further includes: when the switch to be detected is connected to the optical port test jig, and the optical port test jig configuration information read by the non-volatile medium can be accessed based on the optical communication port of the switch to be detected, determining that the optical communication port of the switch to be detected is normal; when the switch to be detected is connected to the optical port test jig, and the optical communication port of the switch to be detected cannot access the optical port test jig configuration information read by the non-volatile medium, determining that the optical communication port of the switch to be detected is abnormal.
[0021] The present invention also provides an optical port test fixture, which includes: an interface, wherein the interface is used to connect to the optical communication port of the switch to be tested; a non-volatile medium, wherein the non-volatile medium has a micro control unit, and the micro control unit executes the optical port test fixture configuration information reading method.
[0022] The present invention also provides an optical port test fixture configuration information reading device, the device comprising: a construction module, used to construct the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value site and an optical port test fixture configuration information site; a determination module, used to determine a reference check value corresponding to the constructed optical port test fixture configuration information before writing the constructed optical port test fixture configuration information into a non-volatile medium; a writing module, used to write the constructed optical port test fixture configuration information into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page; a calculation module, used to calculate the first page check value corresponding to the first page optical port test fixture configuration information based on the first page optical port test fixture configuration information; and a reading module, used to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value.
[0023] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for reading configuration information of an optical port test fixture as described in any one of the above is implemented.
[0024] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for reading configuration information of an optical port test fixture as described in any one of the above is implemented.
[0025] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for reading configuration information of an optical port test fixture as described in any one of the above is implemented.
[0026] The optical port test fixture configuration information reading method, device and optical port test fixture provided by the present invention construct the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determine a reference check value corresponding to the constructed optical port test fixture configuration information; write the constructed optical port test fixture configuration information into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page; based on the first page optical port test fixture configuration information, calculate a first page check value corresponding to the first page optical port test fixture configuration information, and then read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value. Since the reference check value is calculated before the post-construction optical port test fixture configuration information is written, and the first page check value is calculated after the post-construction optical port test fixture configuration information is written, by comparing the reference check value and the first page check value, it can be determined whether the post-construction optical port test fixture configuration information fails during the writing process, thereby achieving accurate reading of valid optical port test fixture configuration information, thereby not being affected by power failure of the optical port test fixture during operation, and laying a foundation for accurate optical communication port detection of the switch to be tested. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 This is one of the flow charts of the method for reading the configuration information of the optical port test fixture provided by the present invention;
[0029] Figure 2 It is a flow chart of obtaining the configuration information of the optical port test fixture by reading from a non-volatile medium based on a reference check value and a first page check value provided by the present invention;
[0030] Figure 3 It is a flow chart of obtaining the optical port test fixture configuration information by reading from a non-volatile medium based on a reference check value, a first page check value, and a second page check value provided by the present invention;
[0031] Figure 4 This is the second flow chart of the method for reading the configuration information of the optical port test fixture provided by the present invention;
[0032] Figure 5 It is a schematic diagram of an application scenario of erasing and writing a non-volatile medium provided by the present invention;
[0033] Figure 6 It is a schematic diagram of a reading application scenario of the non-volatile medium provided by the present invention;
[0034] Figure 7 It is a structural schematic diagram of the optical port test fixture configuration information reading device provided by the present invention;
[0035] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] It is known from the related technology that in intelligent switch products, there are many different switch network service ports for sending and receiving data. All optical communication ports need to be tested before the switch products leave the factory, including testing the high-speed link signal, low-speed link signal, power consumption status, temperature status, voltage status, etc. of the optical communication ports. If the optical module plus optical cable is directly used for testing, the cost is huge and it is not easy to operate. Therefore, the optical port test fixture came into being. The optical port test fixture is responsible for self-loop testing of the above-mentioned various signals and states of the optical communication port of the switch, quantifying the various functional indicators of the optical communication port of the switch product before leaving the factory, and improving the product test indicators.
[0038] Some data in the optical port test fixture needs to be permanently saved, such as plug-in count value, production date and production serial number, so it needs to be written to non-volatile media for storage. Flash can be selected as the medium to store this information. The operation of writing to flash is divided into two steps: erasing the specified area of flash and writing the value to the specified location. For some optical port test fixtures, there is only page erase, one page is 512 bytes, so the data is erased 512 bytes each time; after the erasure is completed, the corresponding value is written to the specified page. The whole process takes a certain amount of time.
[0039] If the optical port test fixture is plugged into the optical communication port to power on, and unplugged to power off, if the optical port test fixture is not inserted accurately during the plug-in and unplugging process, it needs to be unplugged and plugged again, or it is not inserted properly and has poor contact and needs to be reinserted, the optical port test fixture will be powered on and off immediately during this process. If the program happens to run to the stage where the plug-in and unplugging counts are written to the flash, powering off may cause the erase process to be interrupted, and the latest count value cannot be written, or the written value is wrong. In other words, it is impossible to determine whether the configuration information of the optical port test fixture read is valid information, which in turn affects the optical port test fixture's effective testing of the optical communication port of the switch.
[0040] The method for reading configuration information of an optical port test fixture provided by the present invention can solve the problem that a flash read and write fails due to abnormal power failure, thereby making it impossible to determine whether the configuration information of the optical port test fixture read is valid information, thereby affecting the optical port test fixture's effective testing of the optical communication port of the switch.
[0041] Figure 1 This is one of the flow charts of the method for reading the configuration information of the optical port test fixture provided by the present invention.
[0042] The following will be combined Figure 1 The process of the method for reading the configuration information of the optical port test fixture provided by the present invention is described.
[0043] In an exemplary embodiment of the present invention, Figure 1 It can be known that the method for reading the configuration information of the optical port test fixture may include steps 110 to 150, and each step will be introduced below.
[0044] In step 110, the optical port test fixture configuration information is constructed according to a preset data structure to obtain constructed optical port test fixture configuration information.
[0045] In one embodiment, the optical port test fixture configuration information may include plug-in count configuration information, production date configuration information, and production serial number configuration information. In addition, the optical port test fixture configuration information may also include communication rate, etc. In this embodiment, the optical port test fixture configuration information is specifically limited and adjusted according to actual conditions.
[0046] In this embodiment, for the convenience of description, it is described by taking the example that the optical port test fixture configuration information may include plug count value configuration information, production date configuration information and production serial number configuration information.
[0047] In another embodiment, the optical port test fixture configuration information can be constructed according to a preset data structure, so as to obtain the constructed optical port test fixture configuration information. The preset data structure may include at least a check value site and an optical port test fixture configuration information site. The check value site stores check information for characterizing information characteristics of the constructed optical port test fixture configuration information; the optical port test fixture configuration information site stores specific optical port test fixture configuration information.
[0048] In another embodiment, for the plug-in count value configuration information, the constructed plug-in count value configuration information obtained by constructing it according to the preset data structure may be as follows:
[0049] / / Data structure of plug-in and pull-out counts
[0050] typedef struct dataInsert{
[0051] uint8_t checksum;
[0052] uint8_t count_flag;
[0053] uint8_t data[3];
[0054] } insert_data;
[0055] Among them, checksum can represent the information corresponding to the check value position; insert_data can represent the information corresponding to the optical port test fixture configuration information position.
[0056] In another embodiment, the production date configuration information may be constructed according to a preset data structure to obtain the following constructed production date configuration information:
[0057] / / Data structure of production date
[0058] typedef struct dataDate{
[0059] uint8_t checksum;
[0060] uint8_t count_flag;
[0061] uint8_t data[8];
[0062] } date_data;
[0063] Among them, checksum can represent the information corresponding to the check value position; date_data can represent the information corresponding to the optical port test fixture configuration information position.
[0064] In another embodiment, the production serial number configuration information may be constructed according to a preset data structure to obtain the following constructed production serial number configuration information:
[0065] / / Production serial number data structure
[0066] typedef struct dataSerialNo{
[0067] uint8_t checksum;
[0068] uint8_t count_flag;
[0069] uint8_t data
[16] ;
[0070] } serialNo_data;
[0071] Among them, checksum can represent the information corresponding to the check value position; serialNo_data can represent the information corresponding to the optical port test fixture configuration information position.
[0072] The plug-in count data structure data_Insert is used as an example for introduction. The relevant data of the entire structure needs to be stored in the non-volatile medium of the optical port test fixture, such as flash. After reading, it is parsed according to the structure definition. The checksum in the structure is the checksum of the verification configuration information in the structure. The verification method is to accumulate and then take the remainder of the specific data. Count_flag is the write count. When reading data, the A part (which can correspond to the first page optical port test fixture configuration information written on the first page) and the B part (which can correspond to the second page optical port test fixture configuration information written on the second page) are verified and the final data version is confirmed. The Data array stores the plug-in count value stored in the plug-in count.
[0073] In step 120, before writing the constructed optical port test fixture configuration information into the non-volatile medium, a reference check value corresponding to the constructed optical port test fixture configuration information is determined.
[0074] In one embodiment, before writing the post-construction optical port test fixture configuration information into the non-volatile medium, a reference check value corresponding to the post-construction optical port test fixture configuration information can be determined. The reference check value can be used to identify the post-construction optical port test fixture configuration information that is standard information that needs to be written before being written into the non-volatile medium.
[0075] In step 130, the constructed optical port test fixture configuration information is written into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page.
[0076] In step 140 , based on the first page optical port test fixture configuration information, a first page check value corresponding to the first page optical port test fixture configuration information is calculated.
[0077] In step 150, based on the reference check value and the first page check value, optical port test fixture configuration information is read from the non-volatile medium.
[0078] In another embodiment, the post-construction optical port test fixture configuration information can be written into the first page of the non-volatile medium, so that the first page optical port test fixture configuration information written into the first page can be obtained. It should be noted that if there is no problem in the writing process, the first page optical port test fixture configuration information is ideally the same as the post-construction optical port test fixture configuration information. In order to ensure whether the first page optical port test fixture configuration information is the same as the post-construction optical port test fixture configuration information, it can be determined based on the comparison of the standard check value of the post-construction optical port test fixture configuration information and the first page check value of the first page optical port test fixture configuration information.
[0079] In one embodiment, the standard check value is calculated based on the optical port test fixture configuration information after construction, and the first page check value is calculated based on the optical port test fixture configuration information on the first page. The comparison between the first page check value and the standard check value can reflect the comparison between the optical port test fixture configuration information after construction and the optical port test fixture configuration information on the first page, so that it can be determined whether the optical port test fixture configuration information after construction fails during the writing process, and the effective optical port test fixture configuration information can be accurately read, so that it can be unaffected by the power failure of the optical port test fixture during operation, laying a foundation for accurately performing optical communication port detection of the switch to be detected.
[0080] The optical port test fixture configuration information reading method provided by the present invention constructs the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page; based on the first page optical port test fixture configuration information, calculating a first page check value corresponding to the first page optical port test fixture configuration information, and then based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium. Since the reference check value is calculated before the post-construction optical port test fixture configuration information is written, and the first page check value is calculated after the post-construction optical port test fixture configuration information is written, by comparing the reference check value and the first page check value, it can be determined whether the post-construction optical port test fixture configuration information fails during the writing process, thereby achieving accurate reading of valid optical port test fixture configuration information, thereby not being affected by power failure of the optical port test fixture during operation, and laying a foundation for accurate optical communication port detection of the switch to be tested.
[0081] In an exemplary embodiment of the present invention, the above-mentioned embodiment is continued as an example for explanation. Based on the reference check value and the first page check value, the optical port test fixture configuration information is obtained by reading from the non-volatile medium (corresponding to step 150), which can be implemented in the following manner:
[0082] When the reference check value and the first page check value are the same, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium.
[0083] In one embodiment, since the standard check value is calculated based on the post-construction optical port test fixture configuration information, the first page check value is calculated based on the first page optical port test fixture configuration information. When the reference check value of the post-construction optical port test fixture configuration information and the first page check value of the first page optical port test fixture configuration information are the same, it indicates that the written post-construction optical port test fixture configuration information is successful, and therefore, the optical port test fixture configuration information can be read from the first page of the non-volatile medium.
[0084] In another embodiment, since the first page of the non-volatile medium stores the post-construction optical port test fixture configuration information, the corresponding optical port test fixture configuration information can be read according to the optical port test fixture configuration information position of the post-construction optical port test fixture configuration information, thereby accurately reading the optical port test fixture configuration information without having to pay attention to whether the optical port test fixture is powered off, thereby laying a foundation for accurately performing optical communication port detection of the switch to be detected.
[0085] In another exemplary embodiment of the present invention, continuing to use the above-mentioned embodiment as an example for description, the method for reading the configuration information of the optical port test fixture may further include the following steps:
[0086] When the reference check value and the first page check value are different, an alarm reminder is issued, wherein the alarm reminder is used to prompt the user that there is an error in the first page optical port test fixture configuration information written into the first page.
[0087] Continuing with the description in the previous text, since the standard check value is calculated based on the post-construction optical port test fixture configuration information, the first page check value is calculated based on the first page optical port test fixture configuration information. When the reference check value of the post-construction optical port test fixture configuration information and the first page check value of the first page optical port test fixture configuration information are different, it means that the written post-construction optical port test fixture configuration information is unsuccessful, and therefore, an alarm reminder can be issued to remind the user that there is an error in the first page optical port test fixture configuration information written to the first page.
[0088] Figure 2 It is a flow chart of obtaining the configuration information of the optical port test fixture by reading from a non-volatile medium based on a reference check value and a first page check value provided by the present invention.
[0089] The following will be combined Figure 2 The process of obtaining the optical port test fixture configuration information by reading from the non-volatile medium based on the reference check value and the first page check value is described.
[0090] In an exemplary embodiment of the present invention, after writing the constructed optical port test fixture configuration information into the first page of the non-volatile medium and obtaining the first page optical port test fixture configuration information written into the first page, Figure 2 It can be seen that based on the reference check value and the first page check value, obtaining the optical port test fixture configuration information by reading from the non-volatile medium may include steps 210 to 230, and each step will be described below.
[0091] In step 210, the constructed optical port test fixture configuration information is written into the second page of the non-volatile medium to obtain the second page optical port test fixture configuration information written into the second page.
[0092] In order to ensure that the corresponding optical port test fixture configuration information can be effectively read, since abnormal power failure is an instantaneous event, when an abnormality occurs, if copy A is being erased, copy B retains the last valid version, which has only a limited difference from the latest data; if copy B is being erased, copy A retains the latest version. This avoids the problem of data loss caused by abnormal power failure.
[0093] In view of this, in one embodiment, the optical port test fixture configuration information after construction can also be written into the second page of the non-volatile medium to obtain the second page optical port test fixture configuration information written into the second page, wherein the second page is different from the first page. It should be noted that in this embodiment, the first page optical port test fixture configuration information and the second page optical port test fixture configuration information are not primary or secondary or primary and backup.
[0094] In step 220, based on the second page optical port test fixture configuration information, a second page check value corresponding to the second page optical port test fixture configuration information is calculated.
[0095] In step 230, based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information is read from the non-volatile medium.
[0096] In one embodiment, the second page check value corresponding to the second page optical port test fixture configuration information can also be calculated based on the second page optical port test fixture configuration information. Further, based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information is read from the non-volatile medium.
[0097] Figure 3 It is a flow chart of obtaining the optical port test fixture configuration information by reading from a non-volatile medium based on a reference check value, a first page check value and a second page check value provided by the present invention.
[0098] The following will be combined Figure 3 The process of obtaining the optical port test fixture configuration information by reading from a non-volatile medium based on a reference check value, a first page check value and a second page check value is described.
[0099] In an exemplary embodiment of the present invention, Figure 3 It can be seen that based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information read from the non-volatile medium may include steps 310 to 390, wherein steps 310 to 320 are respectively the same or similar to steps 210 to 220. For its specific implementation and beneficial effects, please refer to the previous description, which will not be repeated in this embodiment. Steps 330 to 390 will be introduced below respectively.
[0100] In step 330 , when the reference check value is the same as the first page check value and the reference check value is different from the second page check value, the optical port test fixture configuration information is read from the first page of the non-volatile medium.
[0101] In one embodiment, if the reference check value is the same as the first page check value, and the reference check value is different from the second page check value, it can be explained that the first page optical port test fixture configuration information written to the first page is correct, and the second page optical port test fixture configuration information written to the second page is incorrect. Then the optical port test fixture configuration information can be read from the first page of the non-volatile medium.
[0102] In step 340 , when the reference check value is the same as the second page check value and the reference check value is different from the first page check value, the optical port test fixture configuration information is read from the second page of the non-volatile medium.
[0103] In one embodiment, if the reference check value is the same as the second page check value, and the reference check value is different from the first page check value, it can be explained that the second page optical port test fixture configuration information written into the second page is correct, and the first page optical port test fixture configuration information written into the first page is incorrect. Then the optical port test fixture configuration information can be read from the second page of the non-volatile medium.
[0104] In step 350 , based on the first page optical port test fixture configuration information, a first page number count value corresponding to the first page optical port test fixture configuration information is calculated.
[0105] In step 360, based on the second page optical port test fixture configuration information, a second page number count value corresponding to the second page optical port test fixture configuration information is calculated.
[0106] In step 370 , when the reference check value is equal to the first page check value and the reference check value is equal to the second page check value, the magnitude of the first page count value and the second page count value is determined.
[0107] In step 380 , when the first page count value is greater than the second page count value, the optical port test fixture configuration information is read from the first page of the non-volatile medium.
[0108] In step 390 , when the first page count value is less than the second page count value, the optical port test fixture configuration information is read from the second page of the non-volatile medium.
[0109] The preset data structure may further include a write count bit, wherein the write count bit stores a count value for representing the number of times the first page optical port test fixture configuration information and / or the second page optical port test fixture configuration information are written into the non-volatile medium.
[0110] In one embodiment, the data structure of the plug-in count described above is used as an example for explanation, wherein count_flag can represent information of a write count location.
[0111] In the application process, the first page count value corresponding to the first page optical port test fixture configuration information can be calculated based on the first page optical port test fixture configuration information, and the second page count value corresponding to the second page optical port test fixture configuration information can be calculated based on the second page optical port test fixture configuration information. Since the flash writing process is always ongoing, there is a situation where the A part of the information is written at the current moment, and the B part of the information is written at the previous moment.
[0112] In one embodiment, if the reference check value is equal to the check value of the first page, and the reference check value is equal to the check value of the second page, it means that the configuration information of the optical port test fixture on the first page and the configuration information of the optical port test fixture on the second page are both accurately written, then it is necessary to select the latest written configuration information as the final information to be read. In one example, if the calculated count value of the first page is 30 times, and the calculated count value of the second page is 29 times, it means that the configuration information of the optical port test fixture on the first page is the latest written configuration information, then the optical port test fixture configuration information can be read from the first page of the non-volatile medium. If the calculated count value of the second page is 30 times, and the calculated count value of the first page is 29 times, it means that the configuration information of the optical port test fixture on the second page is the latest written configuration information, then the configuration information of the optical port test fixture can be read from the second page of the non-volatile medium. Through this embodiment, it is possible to solve the problem of the optical port test fixture configuration information caused by abnormal power failure flash read and write failure, such as the failure to write the plug-in count data, production date and production serial number, thereby solving the problem that the optical port test fixture cannot be used.
[0113] In another exemplary embodiment of the present invention, the reference check value may be determined in the following manner:
[0114] Obtaining verification configuration information of the constructed optical port test fixture configuration information, wherein the verification configuration information is information located within a verification value position interval in the constructed optical port test fixture configuration information;
[0115] Based on the verification configuration information, processing is performed according to a preset verification processing method to obtain a reference verification value corresponding to the constructed optical port test fixture configuration information.
[0116] In one embodiment, the verification configuration information of the post-construction optical port test fixture configuration information can be obtained, and based on the verification configuration information, the information is processed according to a preset verification processing method to obtain a reference verification value corresponding to the post-construction optical port test fixture configuration information. The verification configuration information can be information located in the verification value position interval in the post-construction optical port test fixture configuration information.
[0117] In one example, the verification configuration information may be the configuration information of the entire optical port test fixture. In the application process, the preset verification processing method may be a verification and processing method, for example, the verification configuration information may be accumulated and then the modulus of specific data may be taken. It should be noted that the preset verification processing method may also be other verification processing methods, and the preset verification processing method is not specifically limited in this embodiment.
[0118] Since the reference check value is determined based on the post-construction optical port test fixture configuration information, it is possible to determine whether the post-construction optical port test fixture configuration information is accurately written into the first page (second page) based on the reference check value and the first page check value (second page check value).
[0119] In another embodiment, in order to ensure that the obtained reference check value will not be maliciously tampered with, thereby affecting the accuracy of judging whether the configuration information of the optical port test fixture after construction is accurately written into the first page (second page), the reference check value can also be encrypted. Among them, the method of encrypting the reference check value can also be applied to the encryption process of the first page check value and the second page check value, so as to ensure the stability and non-tampering of the first page check value and the second page check value, and ensure the accuracy of subsequent judgments.
[0120] In another exemplary embodiment of the present invention, the first page check value may be determined in the following manner:
[0121] Acquire first page verification configuration information of the first page optical port test fixture configuration information, wherein the first page verification configuration information is information located in the verification value position interval of the first page optical port test fixture configuration information;
[0122] Based on the first page verification configuration information, the first page verification value corresponding to the first page optical port test fixture configuration information is obtained by processing in the same preset verification processing manner as the verification configuration information.
[0123] In another exemplary embodiment of the present invention, the second page check value may be determined in the following manner:
[0124] Acquire the second page verification configuration information of the second page optical port test fixture configuration information, wherein the second page verification configuration information is information located in the verification value position interval of the second page optical port test fixture configuration information;
[0125] Based on the second page verification configuration information, processing is performed in accordance with the same preset verification processing method as the verification configuration information to obtain a second page verification value corresponding to the second page optical port test fixture configuration information.
[0126] It should be noted that, in the process of determining the first page check value and the second page check value, the specific implementation method is the same or similar to the method of determining the reference check value, and will not be repeated in this embodiment.
[0127] In another exemplary embodiment of the present invention, the post-construction optical port test fixture configuration information may include post-construction plug-in count value configuration information, post-construction production date configuration information and post-construction production serial number configuration information; the first page may include multiple different first sub-pages.
[0128] The following method can be used to write the constructed optical port test fixture configuration information into the first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page:
[0129] The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different first sub-pages to obtain the first page plug-in count value configuration information, the first page production date configuration information and the first page production serial number configuration information written into different first sub-pages.
[0130] In one embodiment, the plug count data, the production date, and the production serial number may be stored in different pages, respectively, to avoid the situation where all data is lost due to a failure to erase after writing a page.
[0131] In another exemplary embodiment of the present invention, the post-construction optical port test fixture configuration information may include post-construction plug-in count value configuration information, post-construction production date configuration information and post-construction production serial number configuration information; the second page may include multiple different second sub-pages.
[0132] The following method can be used to write the constructed optical port test fixture configuration information into the second page of the non-volatile medium to obtain the second page optical port test fixture configuration information written into the second page:
[0133] The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different second sub-pages to obtain the second page plug-in count value configuration information, the second page production date configuration information and the second page production serial number configuration information written into different second sub-pages.
[0134] In one embodiment, based on the same principle as the above embodiment, when writing the post-construction optical port test fixture configuration information of the second page, different types of post-construction optical port test fixture configuration information, such as post-construction plug-in count configuration information, post-construction production date configuration information, and post-construction production serial number configuration information, can be written into different second sub-pages, respectively. This can avoid the situation where all data is lost due to a single erase failure after writing a page.
[0135] It can be understood that by storing the plug count data, production date and production serial number in different pages (different first sub-pages and different second sub-pages), and storing the plug count data, production date and production serial number in duplicate and on different pages (first page and second page), the problem of failure to write the optical port test fixture configuration information due to abnormal power failure flash read and write failure can be effectively avoided.
[0136] In another embodiment, the following embodiment can be used as an example for explanation, wherein the domestic MCU used in the optical port test fixture has a 32K flash, the flash access address range is 0x0000-0x7fff, 512 bytes is a page, and the address range of the Nth page is 0x200 N~0x200 N+0x1FF, the minimum unit of single erase is one page.
[0137] The plug-in count data, production date and production serial number can be stored in two parts, A and B, in different pages of the flash, and the following pages are divided to store the corresponding data. The specific storage form can be referred to in Table 1.
[0138] Table 1 Data storage distribution table
[0139]
[0140] Among them, copy A can correspond to the first page, and copy B can correspond to the second page.
[0141] In another exemplary embodiment of the present invention, the method for reading configuration information of an optical port test fixture may further include the following steps:
[0142] When it is monitored that the plug count value in the first page plug count value configuration information written into the first subpage is greater than or equal to the plug count value, an alarm reminder is issued, wherein the alarm reminder is used to remind the user that the usage frequency of the optical port test fixture exceeds the service life.
[0143] In one embodiment, the plug-in count value needs to increase by 1 each time the optical port test fixture is plugged in or out. When it increases to a certain value, it means that the optical port test fixture has exceeded its service life and needs to be scrapped. Among them, the plug-in count value needs to increase by 1 each time the optical port test fixture is plugged in or out, which can be reflected by the plug-in count value in the plug-in count value configuration information on the first page. During the application process, when the plug-in count value is greater than or equal to the plug-in count value, it means that the frequency of use of the optical port test fixture has exceeded its service life, and a timely alarm is required to avoid inaccurate data read subsequently. Exceptionally, if the plug-in count value is written incorrectly, it will lead to the inability to correctly judge the life cycle of the optical port test fixture, and it will be impossible to confirm whether it is a test fixture that has exceeded its service life. Furthermore, if a test problem occurs during the switch test process, it will be impossible to locate whether it is a problem with the optical port test fixture or a problem with the switch, which reduces the efficiency of problem solving and brings hidden dangers to the switch product testing.
[0144] Figure 4 This is the second flow chart of the method for reading the configuration information of the optical port test fixture provided by the present invention.
[0145] In order to further introduce the optical port test fixture configuration information reading method provided by the present invention, the following will be combined with Figure 4 Provide explanation.
[0146] In an exemplary embodiment of the present invention, Figure 4 It can be seen that the method for reading the configuration information of the optical port test fixture may include steps 410 to 470, wherein steps 410 to 450 are respectively the same or similar to steps 110 to 150. For its specific implementation and beneficial effects, please refer to the previous description, which will not be repeated in this embodiment. Steps 460 and 470 will be introduced respectively below.
[0147] In step 460, when the switch to be tested is connected to the optical port test fixture and the optical port test fixture configuration information read from the non-volatile medium can be accessed by the optical communication port of the switch to be tested, it is determined that the optical communication port of the switch to be tested is normal;
[0148] In step 470, when the switch to be tested is connected to the optical port test fixture and the optical communication port of the switch to be tested cannot access the optical port test fixture configuration information read from the non-volatile medium, it is determined that the optical communication port of the switch to be tested is abnormal.
[0149] In one embodiment, when the optical port test jig configuration information is accurately read from a non-volatile medium, it can be determined that the optical communication port of the switch to be detected is normal when the switch to be detected is connected to the optical port test jig. When the switch to be detected is connected to the optical port test jig, and the optical port test jig configuration information read from the non-volatile medium can be accessed based on the optical communication port of the switch to be detected, it can be determined that the optical communication port of the switch to be detected is normal. When the switch to be detected is connected to the optical port test jig, and the optical port test jig configuration information read from the non-volatile medium cannot be accessed based on the optical communication port of the switch to be detected, it can be determined that the optical communication port of the switch to be detected is abnormal. Through this embodiment, the detection of the optical communication port of the switch to be detected can be completed efficiently and accurately.
[0150] It can be understood that the optical port test fixture configuration information reading method provided by the present invention can distribute the erasing and writing of non-volatile media, as well as the reading process. Figure 5 and Figure 6 The aforementioned process is described.
[0151] Figure 5 It is a schematic diagram of the application scenario of erasing and writing the non-volatile medium provided by the present invention.
[0152] In one embodiment, the erasing and writing process of the non-volatile medium may be implemented based on an erase-write composite function, wherein the erase-write composite function may be as follows:
[0153] void Flash_Write(unsigned int addr, uint8_t xdata src_ptr, unsignedchar num)
[0154] {
[0155] uint8_t i = 0;
[0156] uint16_t checksum = 0;
[0157] uint8_t count = 0;
[0158] if(addr<0x7FFF&&addr>= 0x7000)
[0159] {
[0160] count = Byte_Read(addr+1);
[0161] src_ptr[1] += count;
[0162] for(i= 1;i <mun;i++)
[0163] {
[0164] checksum += src_ptr[i];
[0165] }
[0166] src_ptr[0] = checksum % 0xdd;
[0167] Page_Erase(addr);
[0168] Array_Write(addr,src_ptr,num);
[0169] }
[0170] }
[0171] The above-mentioned conforming function combines erasing and writing into one function. In the parameter of Flash_Write, addr is the first address of the page to be written, and src_ptr is a pointer to the data structure data_Insert, where the data part has been filled in before the function is called. Since the count_flag in the structure is the write count value for each backup, it can only be performed in the write operation, and the calculation of the checksum also needs to be performed in the write function. When performing a write operation, Flash_Write needs to be executed twice, and the write address is selected as the first address of A and B respectively, so that the problem of data loss caused by abnormal power failure can be avoided. Because abnormal power failure is an instantaneous event, when an abnormality occurs, if A is being erased, B retains the last valid version, which has only a limited and minor difference with the latest data; if B is being erased, A retains the latest version. This avoids the problem of data loss caused by abnormal power failure.
[0172] Combination Figure 5 It can be seen that parameters can be input into the function, where the parameters include flash address, data structure and data length, where the flash address can be considered as the built-in flash address in the optical port test fixture; the data structure and data length can identify the data structure and data length of the optical port test fixture configuration information after construction.
[0173] Furthermore, the legality of the parameters can be judged, especially whether the flash address actually exists. If it does exist, that is, the parameters are legal, then the count_flag in the configuration information of the optical port test fixture after construction stored in the flash address (which can correspond to the first page or the second page) can be read, and the count_flag can be written into the second byte of the data structure, so that the first page count value (or the second page count value) can be updated in time.
[0174] In another embodiment, the checksum from count_flag to the last data in the entire data structure can also be calculated and stored in the first byte, so as to obtain the first page checksum (or the second page checksum). Then, the page (first page or second page) where the addr (address) of the flash is located is erased, and the post-construction optical port test fixture configuration information is written to the page (first page or second page) where the addr (address) of the flash is located. Thus, the erasing and writing process of the non-volatile medium is completed.
[0175] In yet another exemplary embodiment of the present invention, the reading process of the non-volatile medium may be implemented based on a reading function, wherein the reading function may be as follows:
[0176] uint8_t xdata Flash_Read(unsigned int addr, unsigned char num)
[0177] {
[0178] uint8_t i = 0;
[0179] uint16_t checksumA = 0;
[0180] uint16_t checksumB = 0;
[0181] uint8_t count_flagA = 0;
[0182] uint8_t count_flagB = 0;
[0183] uint8_t count = 0;
[0184] uint8_t dataA[num] = {0};
[0185] uint8_t dataB[num] = {0};
[0186] if(addr>0x7FFF || addr<0x7000)
[0187] {
[0188] return NULL;
[0189] }
[0190] if(addr>= 0x7A00&&addr<0x7FFF)
[0191] {
[0192] addr -= 0xa00;
[0193] }
[0194] / / Get the data of A and B in flash
[0195] dataA = Array_Read(addr,num);
[0196] dataB = Array_Read(addr + 0xa00,num);
[0197] / / Calculate checksum
[0198] for(i = 1;i <mun;i++)
[0199] {
[0200] checksumA += dataA[i];
[0201] checksumB += dataB[i];
[0202] }
[0203] checksumA = checksumA % 0xdd;
[0204] checksumB = checksumB % 0xdd;
[0205] / / Get count_flag
[0206] count_flagA = dataA[1];
[0207] count_flagB = dataB[1];
[0208] / / Determine which backup is the latest and valid one, and return the valid backup.
[0209] if(checksumA == dataA[0]&&checksumB != dataB[0])
[0210] {
[0211] return dataA;
[0212] }
[0213] else if(checksumB == dataB[0]&&checksumA != dataA[0])
[0214] {
[0215] return dataB;
[0216] }
[0217] else if(checksumA == dataA[0]&&checksumB == dataB[0])
[0218] {
[0219] if(count_flagA == 0&&count_flagB == 0xff || count_flagA>=count_flagB)
[0220] {
[0221] return dataA;
[0222] }
[0223] else
[0224] {
[0225] return dataB;
[0226] }
[0227] }
[0228] else
[0229] {
[0230] return NULL;
[0231] }
[0232] }
[0233] Among them, in the read function, the data of A and B will be read out, and the latest correct data will be obtained through the checksum and write count and returned. In the parameter of Flash_Read, addr is the first address of the page to be written, num is the data length, and the pointer to the corresponding data structure is returned. First, the legality of addr is judged. If it is legal, addr is processed, and addr is defaulted to the address of the backup of A, the data of A and B are obtained, the checksum of A and B is calculated, and the count_flag of A and B is obtained.
[0234] Compare the calculated checksum with the checksum read from the flash. If only one checksum is equal, then that is the latest data and the data is returned. If both checksums are correct, determine which count_flag is larger. The larger one corresponds to the latest data and the data is returned. If count_flag is 0xff and 0x0 respectively, then 0x0 is the latest data and the data is returned.
[0235] Combination Figure 6 It can be seen that parameters can be input into the function, where the parameters include the flash address and the data length. Further, the legality of the parameters is determined. In the case of legality of the parameters, the flash address (including the first page and the second page) is processed, and one of them is set as A by default and the other as B by default, or the default address is set as A and the other as B by default. Further, the data of A and B are read respectively, that is, the data in the first page and the data in the second page are read, and the check value of each copy is calculated.
[0236] In another embodiment, the specific value of count_flag of each copy, that is, the first page count value and the second page count value, can also be obtained, and data can be returned based on the verification value (including the first page verification value and the second page verification value) and count_flag, that is, the optical port test fixture configuration information finally read is obtained.
[0237] Among them, according to the check value and count_flag, the returned data can be:
[0238] When both the first page check value and the second page check value pass, the magnitude relationship between the first page count value and the second page count value can be determined. When the first page count value is greater than the second page count value, the optical port test fixture configuration information is read from the first page of the non-volatile medium; when the first page count value is less than the second page count value, the optical port test fixture configuration information is read from the second page of the non-volatile medium. Through this embodiment, accurate and latest optical port test fixture configuration information can be efficiently read.
[0239] According to the above description, the optical port test fixture configuration information reading method provided by the present invention constructs the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page; based on the first page optical port test fixture configuration information, calculating a first page check value corresponding to the first page optical port test fixture configuration information, and then based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium. Since the reference check value is calculated before the post-construction optical port test fixture configuration information is written, and the first page check value is calculated after the post-construction optical port test fixture configuration information is written, by comparing the reference check value and the first page check value, it can be determined whether the post-construction optical port test fixture configuration information fails during the writing process, thereby achieving accurate reading of valid optical port test fixture configuration information, thereby not being affected by power failure of the optical port test fixture during operation, and laying a foundation for accurate optical communication port detection of the switch to be tested.
[0240] Based on the same concept, the present invention also provides an optical port testing fixture.
[0241] In another exemplary embodiment of the present invention, the optical port test fixture may include an interface and a non-volatile medium, such as flash. The interface is used to connect to the optical communication port of the switch to be tested; the non-volatile medium has a microcontroller unit, and the microcontroller unit performs any of the above-mentioned methods for reading the configuration information of the optical port test fixture. Through this optical port test fixture, efficient and accurate testing of the optical communication port of the switch to be tested can be achieved.
[0242] Based on the same concept, the present invention also provides an optical port test fixture configuration information reading device.
[0243] The optical port test fixture configuration information reading device provided by the present invention is described below. The optical port test fixture configuration information reading device described below and the optical port test fixture configuration information reading method described above can be referenced to each other.
[0244] Figure 7 It is a structural schematic diagram of the optical port test fixture configuration information reading device provided by the present invention.
[0245] In an exemplary embodiment of the present invention, Figure 7It can be seen that the optical port test fixture configuration information reading device may include a construction module 710, a determination module 720, a writing module 730, a calculation module 740, and a reading module 750, and each module will be introduced below.
[0246] The construction module 710 may be configured to construct the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value position and an optical port test fixture configuration information position;
[0247] The determination module 720 may be configured to determine a reference check value corresponding to the post-construction optical port test fixture configuration information before writing the post-construction optical port test fixture configuration information into a non-volatile medium;
[0248] The writing module 730 may be configured to write the constructed optical port test fixture configuration information into a first page of a non-volatile medium, and obtain the first page optical port test fixture configuration information written into the first page;
[0249] The calculation module 740 may be configured to calculate, based on the first page optical port test fixture configuration information, a first page check value corresponding to the first page optical port test fixture configuration information;
[0250] The reading module 750 may be configured to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value.
[0251] In an exemplary embodiment of the present invention, the reading module 750 may read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value in the following manner:
[0252] When the reference check value and the first page check value are the same, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium.
[0253] In an exemplary embodiment of the present invention, the reading module 750 may also be configured to:
[0254] When the reference check value and the first page check value are different, an alarm reminder is issued, wherein the alarm reminder is used to prompt the user that there is an error in the first page optical port test fixture configuration information written into the first page.
[0255] In an exemplary embodiment of the present invention, the writing module 730 may also be configured to:
[0256] Writing the constructed optical port test fixture configuration information into a second page of a non-volatile medium to obtain second-page optical port test fixture configuration information written into the second page, wherein the second page is different from the first page;
[0257] The computing module 740 may also be configured to:
[0258] Based on the second page optical port test fixture configuration information, a second page check value corresponding to the second page optical port test fixture configuration information is calculated;
[0259] The reading module 750 may read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value in the following manner:
[0260] Based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information is read from the non-volatile medium.
[0261] In an exemplary embodiment of the present invention, the reading module 750 may read the optical port test fixture configuration information from the non-volatile medium based on the reference check value, the first page check value, and the second page check value in the following manner:
[0262] When the reference check value is the same as the first page check value, and the reference check value is different from the second page check value, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium.
[0263] In an exemplary embodiment of the present invention, the reading module 750 may read the optical port test fixture configuration information from the non-volatile medium based on the reference check value, the first page check value, and the second page check value in the following manner:
[0264] When the reference check value is the same as the second page check value and the reference check value is different from the first page check value, the optical port test fixture configuration information is obtained by reading the second page of the non-volatile medium.
[0265] In an exemplary embodiment of the present invention, the preset data structure further includes a write count bit, wherein the write count bit stores a count value representing the number of times the first page optical port test fixture configuration information and / or the second page optical port test fixture configuration information is written into the non-volatile medium;
[0266] The computing module 740 may also be configured to:
[0267] Based on the first page optical port test fixture configuration information, a first page number count value corresponding to the first page optical port test fixture configuration information is calculated;
[0268] Based on the second page optical port test fixture configuration information, a second page number count value corresponding to the second page optical port test fixture configuration information is calculated;
[0269] The reading module 750 may adopt the following method to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value, the first page check value and the second page check value:
[0270] When the reference check value is equal to the first page check value, and the reference check value is equal to the second page check value, determining the magnitude of the first page count value and the second page count value;
[0271] When the count value of the first page number is greater than the count value of the second page number, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium;
[0272] When the first page count value is less than the second page count value, the optical port test fixture configuration information is obtained by reading the second page of the non-volatile medium.
[0273] In an exemplary embodiment of the present invention, the determination module 720 may determine the reference check value in the following manner:
[0274] Acquire verification configuration information of the post-construction optical port test fixture configuration information, wherein the verification configuration information is information located within the verification value position interval in the post-construction optical port test fixture configuration information;
[0275] Based on the verification configuration information, processing is performed according to a preset verification processing method to obtain a reference verification value corresponding to the constructed optical port test fixture configuration information.
[0276] In an exemplary embodiment of the present invention, the calculation module 740 may determine the first page check value in the following manner:
[0277] Acquire first page verification configuration information of the first page optical port test fixture configuration information, wherein the first page verification configuration information is information located within the verification value position interval in the first page optical port test fixture configuration information;
[0278] Based on the first page verification configuration information, the first page verification value corresponding to the first page optical port test fixture configuration information is obtained by processing in the same preset verification processing manner as the verification configuration information.
[0279] In an exemplary embodiment of the present invention, the calculation module 740 may determine the second page check value in the following manner:
[0280] Acquire second page verification configuration information of the second page optical port test fixture configuration information, wherein the second page verification configuration information is information located in the verification value position interval in the second page optical port test fixture configuration information;
[0281] Based on the second page verification configuration information, processing is performed in accordance with the same preset verification processing method as the verification configuration information to obtain the second page verification value corresponding to the second page optical port test fixture configuration information.
[0282] In an exemplary embodiment of the present invention, the optical port test fixture configuration information includes plug count value configuration information, production date configuration information and production serial number configuration information.
[0283] In an exemplary embodiment of the present invention, the post-construction optical port test fixture configuration information includes post-construction plug-in count value configuration information, post-construction production date configuration information, and post-construction production serial number configuration information; the first page includes a plurality of different first sub-pages;
[0284] The writing module 730 may write the constructed optical port test fixture configuration information into the first page of the non-volatile medium in the following manner to obtain the first page optical port test fixture configuration information written into the first page:
[0285] The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different first sub-pages to obtain the first page plug-in count value configuration information, the first page production date configuration information and the first page production serial number configuration information written into different first sub-pages.
[0286] In an exemplary embodiment of the present invention, the post-construction optical port test fixture configuration information includes post-construction plug-in count value configuration information, post-construction production date configuration information, and post-construction production serial number configuration information; the second page includes a plurality of different second sub-pages;
[0287] The writing module 730 may write the constructed optical port test fixture configuration information into the second page of the non-volatile medium in the following manner to obtain the second page optical port test fixture configuration information written into the second page:
[0288] The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different second sub-pages to obtain the second page plug-in count value configuration information, the second page production date configuration information and the second page production serial number configuration information written into different second sub-pages.
[0289] In an exemplary embodiment of the present invention, the calculation module 740 may also be configured to:
[0290] When it is monitored that the plug count value in the first page plug count value configuration information written into the first subpage is greater than or equal to the plug count value, an alarm reminder is issued, wherein the alarm reminder is used to remind the user that the usage frequency of the optical port test fixture exceeds the service life.
[0291] In an exemplary embodiment of the present invention, the reading module 750 may also be configured to:
[0292] When the switch to be detected is connected to the optical port test fixture, and the optical communication port of the switch to be detected can access the configuration information of the optical port test fixture read by the non-volatile medium, determining that the optical communication port of the switch to be detected is normal;
[0293] When the switch to be detected is connected to the optical port test fixture and the optical communication port of the switch to be detected cannot access the optical port test fixture configuration information read from the non-volatile medium, it is determined that the optical communication port of the switch to be detected is abnormal.
[0294] Figure 8 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 8As shown, the electronic device may include: a processor (processor) 810, a communication interface (Communications Interface) 820, a memory (memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the optical port test fixture configuration information reading method, which includes: constructing the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value site and an optical port test fixture configuration information site; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page; based on the first page optical port test fixture configuration information, calculating a first page check value corresponding to the first page optical port test fixture configuration information; based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium.
[0295] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0296] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the optical port test fixture configuration information reading method provided by the above methods, the method including: constructing the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value site and an optical port test fixture configuration information site; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain a first page of optical port test fixture configuration information written into the first page; based on the first page of optical port test fixture configuration information, calculating a first page check value corresponding to the first page of optical port test fixture configuration information; based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium.
[0297] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the optical port test fixture configuration information reading method provided by the above-mentioned methods, the method comprising: constructing the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value site and an optical port test fixture configuration information site; before writing the constructed optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the constructed optical port test fixture configuration information; writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain a first page of optical port test fixture configuration information written into the first page; based on the first page of optical port test fixture configuration information, calculating a first page check value corresponding to the first page of optical port test fixture configuration information; based on the reference check value and the first page check value, reading the optical port test fixture configuration information from the non-volatile medium.
[0298] The device embodiments described above are merely 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 they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0299] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0300] It is further understood that, although the operations are described in a specific order in the accompanying drawings in the embodiments of the present invention, it should not be understood as requiring the operations to be performed in the specific order or serial order shown, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.
[0301] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for reading configuration information of an optical port test fixture, characterized in that: The method comprises: According to a preset data structure, the optical port test fixture configuration information is constructed to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value position and an optical port test fixture configuration information position, wherein the constructed optical port test fixture configuration information includes the constructed plug-in count value configuration information; Before writing the post-construction optical port test fixture configuration information into a non-volatile medium, determining a reference check value corresponding to the post-construction optical port test fixture configuration information; Writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain first page optical port test fixture configuration information written into the first page; Based on the first page optical port test fixture configuration information, a first page check value corresponding to the first page optical port test fixture configuration information is calculated; Based on the reference check value and the first page check value, the optical port test fixture configuration information is read from the non-volatile medium, wherein: After writing the constructed optical port test fixture configuration information into the first page of the non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page, the method further includes: Writing the constructed optical port test fixture configuration information into a second page of a non-volatile medium to obtain second-page optical port test fixture configuration information written into the second page, wherein the second page is different from the first page; After calculating the first page check value corresponding to the first page optical port test fixture configuration information based on the first page optical port test fixture configuration information, the method further includes: Based on the second page optical port test fixture configuration information, a second page check value corresponding to the second page optical port test fixture configuration information is calculated; The step of obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value and the first page check value specifically includes: Based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information is read from the non-volatile medium, wherein: The preset data structure further includes a write count bit, wherein the write count bit stores a count value representing the number of times the first page optical port test fixture configuration information and / or the second page optical port test fixture configuration information are written into the non-volatile medium; The method further comprises: Based on the first page optical port test fixture configuration information, a first page number count value corresponding to the first page optical port test fixture configuration information is calculated; Based on the second page optical port test fixture configuration information, a second page number count value corresponding to the second page optical port test fixture configuration information is calculated; The step of obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value, the first page check value, and the second page check value specifically includes: When the reference check value is equal to the first page check value, and the reference check value is equal to the second page check value, determining the magnitude of the first page count value and the second page count value; When the count value of the first page number is greater than the count value of the second page number, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium; When the first page count value is less than the second page count value, the optical port test fixture configuration information is obtained by reading the second page of the non-volatile medium, wherein the first page check value is determined in the following manner: Acquire first page verification configuration information of the first page optical port test fixture configuration information, wherein the first page verification configuration information is information located within the verification value position interval in the first page optical port test fixture configuration information; Based on the first page verification configuration information, the first page verification value corresponding to the first page optical port test fixture configuration information is obtained by performing the same preset verification processing method as the verification configuration information, wherein the first page verification value is encrypted in the same manner as the reference verification value is encrypted; or The second page check value is determined in the following manner: Acquire second page verification configuration information of the second page optical port test fixture configuration information, wherein the second page verification configuration information is information located in the verification value position interval in the second page optical port test fixture configuration information; Based on the second page verification configuration information, the second page verification value corresponding to the second page optical port test fixture configuration information is obtained by processing in accordance with the same preset verification processing method as the verification configuration information, wherein the second page verification value is encrypted in the same manner as the reference verification value.
2. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: The step of obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value and the first page check value specifically includes: When the reference check value and the first page check value are the same, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium.
3. The method for reading configuration information of an optical port test fixture according to claim 2, characterized in that: The method further comprises: When the reference check value and the first page check value are different, an alarm reminder is issued, wherein the alarm reminder is used to prompt the user that there is an error in the first page optical port test fixture configuration information written into the first page.
4. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: The step of obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value, the first page check value, and the second page check value specifically includes: When the reference check value is the same as the first page check value, and the reference check value is different from the second page check value, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium.
5. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: The step of obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value, the first page check value, and the second page check value specifically includes: When the reference check value is the same as the second page check value and the reference check value is different from the first page check value, the optical port test fixture configuration information is obtained by reading the second page of the non-volatile medium.
6. The method for reading configuration information of an optical port test fixture according to any one of claims 1 to 5, characterized in that: The reference check value is determined in the following manner: Acquire verification configuration information of the post-construction optical port test fixture configuration information, wherein the verification configuration information is information located within the verification value position interval in the post-construction optical port test fixture configuration information; Based on the verification configuration information, processing is performed according to a preset verification processing method to obtain a reference verification value corresponding to the constructed optical port test fixture configuration information.
7. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: The optical port test fixture configuration information includes plug-in count value configuration information, production date configuration information and production serial number configuration information.
8. The method for reading configuration information of an optical port test fixture according to claim 7, characterized in that: The post-construction optical port test fixture configuration information includes post-construction production date configuration information and post-construction production serial number configuration information; the first page includes a plurality of different first sub-pages; The step of writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium to obtain the first page optical port test fixture configuration information written into the first page specifically includes: The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different first sub-pages to obtain the first page plug-in count value configuration information, the first page production date configuration information and the first page production serial number configuration information written into different first sub-pages.
9. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: The post-construction optical port test fixture configuration information includes post-construction production date configuration information and post-construction production serial number configuration information; the second page includes a plurality of different second sub-pages; The step of writing the constructed optical port test fixture configuration information into a second page of the non-volatile medium to obtain the second page optical port test fixture configuration information written into the second page specifically includes: The post-construction plug-in count value configuration information, the post-construction production date configuration information and the post-construction production serial number configuration information are respectively written into different second sub-pages to obtain the second page plug-in count value configuration information, the second page production date configuration information and the second page production serial number configuration information written into different second sub-pages.
10. The method for reading configuration information of an optical port test fixture according to claim 9, characterized in that: The method further comprises: When it is monitored that the plug count value in the first page plug count value configuration information written into the first subpage is greater than or equal to the plug count value, an alarm reminder is issued, wherein the alarm reminder is used to remind the user that the usage frequency of the optical port test fixture exceeds the service life.
11. The method for reading configuration information of an optical port test fixture according to claim 1, characterized in that: After obtaining the optical port test fixture configuration information by reading the non-volatile medium based on the reference check value and the first page check value, the method further includes: When the switch to be detected is connected to the optical port test fixture, and the optical port test fixture configuration information read from the non-volatile medium can be accessed based on the optical communication port of the switch to be detected, determining that the optical communication port of the switch to be detected is normal; When the switch to be detected is connected to the optical port test fixture and the optical communication port of the switch to be detected cannot access the optical port test fixture configuration information read from the non-volatile medium, it is determined that the optical communication port of the switch to be detected is abnormal.
12. An optical port test fixture, characterized in that: The optical port test fixture comprises: An interface, wherein the interface is used to connect to an optical communication port of a switch to be detected; A non-volatile medium, wherein the non-volatile medium comprises a micro control unit, and the micro control unit executes the method for reading the configuration information of the optical port test fixture according to any one of claims 1 to 11.
13. An optical port test fixture configuration information reading device, characterized in that: The device comprises: A construction module, used to construct the optical port test fixture configuration information according to a preset data structure to obtain the constructed optical port test fixture configuration information, wherein the preset data structure at least includes a check value site and an optical port test fixture configuration information site, wherein the constructed optical port test fixture configuration information includes the constructed plug-in count value configuration information; A determination module, used for determining a reference check value corresponding to the post-construction optical port test fixture configuration information before writing the post-construction optical port test fixture configuration information into a non-volatile medium; A writing module, used for writing the constructed optical port test fixture configuration information into a first page of a non-volatile medium, and obtaining the first page optical port test fixture configuration information written into the first page; A calculation module, configured to calculate a first page check value corresponding to the first page optical port test fixture configuration information based on the first page optical port test fixture configuration information; A reading module is configured to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value, wherein the writing module is further configured to: Writing the constructed optical port test fixture configuration information into a second page of a non-volatile medium to obtain second-page optical port test fixture configuration information written into the second page, wherein the second page is different from the first page; The computing module is also configured to: Based on the second page optical port test fixture configuration information, a second page check value corresponding to the second page optical port test fixture configuration information is calculated; The reading module uses the following method to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value and the first page check value: Based on the reference check value, the first page check value and the second page check value, the optical port test fixture configuration information is read from the non-volatile medium, wherein: The preset data structure further includes a write count bit, wherein the write count bit stores a count value representing the number of times the first page optical port test fixture configuration information and / or the second page optical port test fixture configuration information are written into the non-volatile medium; The computing module is also configured to: Based on the first page optical port test fixture configuration information, a first page number count value corresponding to the first page optical port test fixture configuration information is calculated; Based on the second page optical port test fixture configuration information, a second page number count value corresponding to the second page optical port test fixture configuration information is calculated; The reading module uses the following method to read the optical port test fixture configuration information from the non-volatile medium based on the reference check value, the first page check value and the second page check value: When the reference check value is equal to the first page check value, and the reference check value is equal to the second page check value, determining the magnitude of the first page count value and the second page count value; When the count value of the first page number is greater than the count value of the second page number, the optical port test fixture configuration information is obtained by reading the first page of the non-volatile medium; When the first page count value is less than the second page count value, the optical port test fixture configuration information is obtained by reading the second page of the non-volatile medium, wherein the first page check value is determined in the following manner: Acquire first page verification configuration information of the first page optical port test fixture configuration information, wherein the first page verification configuration information is information located within the verification value position interval in the first page optical port test fixture configuration information; Based on the first page verification configuration information, the first page verification value corresponding to the first page optical port test fixture configuration information is obtained by performing the same preset verification processing method as the verification configuration information, wherein the first page verification value is encrypted in the same manner as the reference verification value is encrypted; or The second page check value is determined in the following manner: Acquire second page verification configuration information of the second page optical port test fixture configuration information, wherein the second page verification configuration information is information located in the verification value position interval in the second page optical port test fixture configuration information; Based on the second page verification configuration information, the second page verification value corresponding to the second page optical port test fixture configuration information is obtained by processing in accordance with the same preset verification processing method as the verification configuration information, wherein the second page verification value is encrypted in the same manner as the reference verification value.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for reading configuration information of an optical port test fixture as described in any one of claims 1 to 11 is implemented.
15. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for reading configuration information of an optical port test fixture according to any one of claims 1 to 11 is implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for reading configuration information of an optical port test fixture according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Flash memory data protection method, device, electronic equipment and storage medium
CN112347007A