A method for fast and stable serial port batch data reading based on .NET platform

By using encoding queues and instruction queues on the .NET platform, combined with the technology of reading buffers, the problem of inefficiency in serial communication when reading large amounts of data is solved, and fast and stable serial batch data reading is achieved.

CN118779261BActive Publication Date: 2025-04-22LISHUI BOYUAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411269000.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2025-04-22
Estimated Expiration
2044-09-11

AI Technical Summary

Technical Problem

In the prior art, serial port communication can easily lead to excessive reading time and low efficiency when reading a large amount of data.

Method used

Using a method based on the .NET platform, by generating an encoded queue and an instruction queue, the data is pre-read and verified using the read buffer, and the operation of reading data and verification data is separated to reduce the time to wait for a response.

Benefits of technology

It improves the efficiency of serial port reading, reduces the time to wait for response, and enhances the stability of serial port communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779261B_ABST
    Figure CN118779261B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for realizing fast and stable serial port batch data reading based on .NET platform, and relates to the field of serial port communication. The present invention first reads serial port data and establishes a reading buffer, and then reads the unresponded data in the reading buffer for a second time, thereby reducing the waiting time for response and improving the reading efficiency of the serial port. The present application has the effect of improving the efficiency of serial port reading and reducing the waiting time for response.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of serial port communication, and in particular to a method for realizing fast and stable serial port batch data reading based on a .NET platform. Background Art

[0002] A serial port is a computer hardware interface used to implement serial communication, that is, sending and receiving data in bit sequence.

[0003] In the prior art, serial port communication generally adopts a single-threaded method, that is, first sending a downlink instruction and then waiting for a response. If there is no response, the downlink instruction is sent again and waits for a response. This is repeated several times until the maximum number of times, so that the serial port read and write sequence is stable and controllable.

[0004] When a large amount of data needs to be read, waiting for a response to all the data one by one can easily cause the serial port reading time to be too long, thereby resulting in low serial port reading efficiency. Summary of the invention

[0005] In order to improve the efficiency of serial port reading and reduce the time of waiting for response, the present invention provides a method for realizing fast and stable serial port batch data reading based on .NET platform.

[0006] A method for realizing fast and stable serial port batch data reading based on .NET platform, comprising:

[0007] Generate a code queue and an instruction queue in response to a tool mode, the code queue includes a plurality of instruction codes, the instruction queue includes a plurality of read instructions, the instruction codes correspond to the read instructions one by one, and the read instructions are used to read data in the serial port;

[0008] Sending the command queue to the serial port;

[0009] In response to the instruction queue, a read buffer is established according to a preset read buffer method, wherein the read buffer includes response data and unresponse data;

[0010] Generate a read command according to the amount of data in the read buffer, and read the buffered data in the read buffer according to the read command;

[0011] Based on the fact that the buffered data is response data, generating display data according to the buffered data, wherein the display data is used to control a preset display device to display the buffered data;

[0012] Display data is sent to the display device.

[0013] By adopting the above technical solution, the data is first pre-read into the read buffer according to the instruction queue through the read buffer method, and then the data status in the read buffer is checked to decide whether to output the data, so that the operations of reading data and verifying data are divided and can be carried out in parallel, thereby reducing the waiting time for response and improving the efficiency of serial port reading.

[0014] Optionally, also include:

[0015] Based on the fact that the buffered data is unresponse data, the instruction code in the encoding queue is read according to the read command;

[0016] Generate a coding instruction corresponding to the instruction coding according to the instruction coding;

[0017] Sending a coding instruction to the serial port;

[0018] acquiring response data in response to the encoded instruction;

[0019] Update the buffered data according to the response data.

[0020] By adopting the above technical solution, the type of buffered data is determined by the data length of the buffered data. Therefore, when the data length of the buffered data is 0, it is determined that the reading of the buffered data by the reading buffer method has failed, and the buffered data needs to be further read by repeatedly sending encoding instructions, thereby reducing the situation of reading failure.

[0021] Optionally, an error display method is also included, and the error display method includes:

[0022] obtaining response data in response to the coded instruction and obtaining the response time;

[0023] Update buffered data according to response data;

[0024] generating an unresponse command according to the response time, and generating error data based on the unresponse command, wherein the error data is used to control a preset display device to display an erroneous coded instruction;

[0025] Error data is sent to the display device.

[0026] By adopting the above technical solution, when the response data cannot be read, it is judged that the reading has failed. At this time, the coding instruction is converted into error data and sent to the display device for display to remind the staff of the reading failure, thereby improving the interactivity of the serial port reading.

[0027] Optionally, the read buffer method includes:

[0028] Generate an extraction command according to the number of read instructions in the instruction queue, and extract the read instructions in the instruction queue according to the extraction command;

[0029] Sending a read instruction to the serial port;

[0030] Responding to the read instruction, obtaining read data and obtaining the response time;

[0031] Generate a write command according to the read data, and write the read data into the read buffer according to the write command;

[0032] A non-response command is generated according to the response time, and non-response data is written into the read buffer according to the non-response command.

[0033] By adopting the above technical solution, data is pre-read according to the instruction order of the instruction queue, and the data is pushed into the read buffer when the data is read. When the data is not read, the unresponse data, that is, the data with a length of 0, is pushed into the read buffer, thereby reducing the situation where repeated reading when the data is not read causes the serial port reading time to be too long, and improving the efficiency of serial port reading.

[0034] Optionally, a data verification method is also included, and the data verification method includes:

[0035] Matching the inverted data from a preset data inversion model according to the read data;

[0036] Matching left-shifted data from a preset data left-shift model according to the inverted data;

[0037] Matching the modulo-2 remainder from a preset modulo-2 division calculation model according to the left-shifted data and the preset divisor;

[0038] Matching the inversion remainder from a preset data inversion model according to the modulo-2 remainder;

[0039] Calculating a check value from a preset XOR calculation model according to the inverted remainder and a preset XOR value;

[0040] Matching the merged data from a preset data merging model according to the read data and the check value;

[0041] The merged data is written into the read buffer according to a write command.

[0042] By adopting the above technical solution, after reading data according to the instruction queue, a check value is generated according to the read data, and the check value is merged with the read data and the new merged data is pushed into the read buffer, so that the read data is checked when reading data from the read buffer, thereby reducing the situation of data sending errors during transmission and improving the stability of serial port reading.

[0043] Optionally, the data verification method further includes:

[0044] Based on the fact that the buffered data belongs to the response data, a check remainder is matched from a preset modulo-2 division calculation model according to the buffered data and a preset divisor;

[0045] When the check remainder is not 0, read the check code in the code queue according to the read command;

[0046] Generate a verification instruction corresponding to the verification code according to the verification code;

[0047] Sending a verification instruction to the serial port;

[0048] acquiring verification data in response to the verification instruction;

[0049] Update the buffer data according to the verification data.

[0050] By adopting the above technical solution, it is possible to check whether the buffered data is erroneous, and if the buffered data is erroneous, re-read the buffered data from the serial port, thereby reducing the situation where data is sent incorrectly during transmission and improving the stability of serial port reading.

[0051] Optionally, a method for generating an unresponsive command is further included, and the method for generating an unresponsive command includes:

[0052] Get serial port temperature;

[0053] Match the response time from the preset response time matching model according to the serial port temperature;

[0054] Matching a response interval from a preset response interval matching model according to the response time and a preset response error interval;

[0055] When the response time exceeds the response interval, a non-response command is generated.

[0056] By adopting the above technical solution, when the serial port temperature is too high, it is easy to cause the serial port response time to become longer. The corresponding response error interval is matched according to the temperature of the serial port, thereby reducing the situation where the temperature causes the response speed to slow down and then cause the generation of unresponsive commands.

[0057] Optionally, a serial port heat dissipation method is also included, and the serial port heat dissipation method includes:

[0058] When the serial port temperature exceeds the preset operating temperature range, the cooling wind force is matched from the preset cooling wind force matching model according to the serial port temperature;

[0059] According to the cooling wind force, the power demand and speed change demand are matched from the preset wind force regulation model;

[0060] supplying power to a preset driving device to drive a preset cooling device according to power demand;

[0061] The connection state of the preset speed change device and the driving device is controlled according to the speed change demand to adjust the output wind force of the preset heat dissipation device.

[0062] By adopting the above technical solution, when the temperature of the serial port is high, it is easy to cause errors in the serial port reading process. The driving device drives the heat sink to accelerate the heat dissipation of the serial port. When the temperature of the serial port is too high, the speed change device increases the driving effect of the driving device on the heat sink, thereby improving the heat dissipation effect of the heat sink on the serial port.

[0063] Optionally, a humidity control method is also included, and the humidity control method includes:

[0064] Get the ambient humidity;

[0065] When the ambient humidity exceeds the preset working humidity range, the dehumidification temperature is matched from the preset dehumidification temperature matching model according to the ambient humidity;

[0066] Matching the heating power from a preset heating power matching model according to the dehumidification temperature and the serial port temperature;

[0067] The preset serial port reading device is controlled to read data according to the heating power.

[0068] By adopting the above technical solution, when the ambient humidity is too high, it is easy to cause faults such as short circuits. By increasing the reading power of the serial port reading device, the temperature of the serial port is increased, and the water vapor around the serial port evaporates to reduce the humidity around the serial port, thereby improving the stability of serial port reading.

[0069] Optionally, a thread switching control method is also included, and the thread switching control method includes:

[0070] Matching the instruction quantity from a preset instruction quantity recognition model according to the instruction queue;

[0071] When the number of instructions falls into a preset fast reading interval, extracting fast instructions in the instruction queue;

[0072] Sending a quick command to the serial port;

[0073] Responding to the fast instruction, acquiring fast data and acquiring fast time;

[0074] generating a repeat command according to the fast time, sending a fast instruction to the serial port according to the repeat command, and initializing the fast time;

[0075] Generate display data based on fast data;

[0076] Generates incorrect data based on fast time.

[0077] By adopting the above technical solution, when the amount of data to be read is large, the serial port is read through a dual-threaded manner, and when the amount of data to be read is small, the serial port is read through a single-threaded manner, thereby improving the efficiency of serial port reading.

[0078] In summary, the present application includes at least one of the following beneficial technical effects:

[0079] 1. First, the data is pre-read into the read buffer according to the instruction queue through the read buffer method, and then the data status in the read buffer is checked to determine whether to output the data, so that the operations of reading data and checking data are divided and can be carried out in parallel, thereby reducing the waiting time for response and improving the efficiency of serial port reading;

[0080] 2. The type of buffered data is determined by the data length of the buffered data. When the data length of the buffered data is 0, it is determined that the buffered data has failed to be read by the buffer reading method. The buffered data needs to be further read by repeatedly sending the encoding instruction, thereby reducing the situation of read failure.

[0081] 3. Pre-read the data according to the instruction sequence of the instruction queue, and push the data into the read buffer when the data is read. If the data is not read, the unresponse data, that is, the data with a length of 0, is pushed into the read buffer, thereby reducing the situation where repeated reading when no data is read causes the serial port reading time to be too long, and improving the efficiency of serial port reading. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] Figure 1 This is a process for a method to quickly and stably read serial port batch data based on the .NET platform. Figure 1 ;

[0083] Figure 2 This is a process for a method to quickly and stably read serial port batch data based on the .NET platform. Figure 2 ;

[0084] Figure 3 is a flow chart of the error display method;

[0085] Figure 4 is a flow chart of the read buffer method;

[0086] Figure 5 This is the process of data verification method Figure 1 ;

[0087] Figure 6 This is the process of data verification method Figure 2 ;

[0088] Figure 7 is a flow chart of a method for generating an unresponsive command;

[0089] Figure 8 It is a flow chart of the serial port heat dissipation method;

[0090] Fig. 9 is a flow chart of the humidity control method;

[0091] Fig.10 It is a flowchart of the thread switching control method. DETAILED DESCRIPTION

[0092] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the following Figure 1 -Attached Fig.10 It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0093] Reference Figure 1 , a method for fast and stable serial port batch data reading based on .NET platform, comprising the following steps:

[0094] Step 100: Generate a coding queue and an instruction queue in response to a tool mode, wherein the coding queue includes a plurality of instruction codes, and the instruction queue includes a plurality of read instructions, wherein the instruction codes correspond to the read instructions one by one, and the read instructions are used to read data in the serial port.

[0095] The read instruction refers to the instruction used to read the data in the serial port, and the instruction code refers to the code generated by converting the read instruction. The read instruction and instruction code are selected by the staff according to the actual situation, and will not be described here. The encoding queue is a set of instruction codes composed of multiple instruction codes, and the instruction queue is a set of read instructions composed of multiple read instructions.

[0096] Step 101: Send the command queue to the serial port.

[0097] By sending a command queue to the serial port to read data.

[0098] Step 102: In response to the instruction queue, a read buffer is established according to a preset read buffer method, wherein the read buffer includes response data and unresponse data.

[0099] The read buffer is a buffer used to store the data fed back by the serial port in response to the command queue. The setting method of the read buffer is selected by the staff according to the actual situation and will not be described here. The read buffer method refers to the method of reading the serial port according to the command queue and pushing the read data into the read buffer, where the response data refers to the data whose data length is not 0, and the unresponse data refers to the data whose data length is 0.

[0100] Step 103: Generate a read command according to the amount of data in the read buffer, and read the buffered data in the read buffer according to the read command.

[0101] The read command is a command issued when there is data in the read buffer. The data in the read buffer is detected and the data in the read buffer is extracted in time. The buffered data is the data at the top of the queue in the read buffer read from the read buffer. After the buffered data is extracted from the read buffer, the original buffered data is deleted from the read buffer to reduce repeated reading.

[0102] Step 104: Based on the fact that the buffered data is response data, generate display data according to the buffered data, wherein the display data is used to control a preset display device to display the buffered data.

[0103] The display device refers to a device for displaying data read from the serial port. The display device is selected by the staff according to the actual situation and will not be described in detail here. Display data refers to data converted from buffered data for input into the display device to display buffered data. Buffered data is generally hexadecimal data. When buffered data needs to be displayed, it is generally necessary to convert the buffered data into decimal numbers to facilitate staff viewing. The display data conversion method is selected by the staff according to the actual situation and will not be described in detail here. Buffered data belongs to response data, which means that the buffered data is valid. At this time, the buffered data is converted into display data to display the buffered data, and the instruction code at the top of the encoding queue is deleted to reduce the repeated processing of the same instruction code.

[0104] Step 105: Send display data to the display device.

[0105] The display device displays the buffer data according to the display data, and the display device can display the data in different display modes such as pie charts and bar charts according to the type of data, so as to facilitate the staff to view the data.

[0106] Reference Figure 2 , a method for realizing fast and stable serial port batch data reading based on .NET platform also includes the following steps:

[0107] Step 106: Based on the fact that the buffered data is unresponsive data, read the instruction code in the code queue according to the read command.

[0108] The buffer data is unresponsive data, which means that the buffer data cannot be correctly obtained, and the buffer data needs to be obtained again. The instruction code refers to the code corresponding to the read instruction for reading the buffer data at the top of the encoding queue, and the instruction code is obtained by reading the read command.

[0109] Step 107: Generate a coding instruction corresponding to the instruction code according to the instruction code.

[0110] Encoded instructions refer to read instructions obtained by encoding and decoding instructions.

[0111] Step 108: Send a coding instruction to the serial port.

[0112] Retrieve the buffered data by sending coded instructions to the serial port.

[0113] Step 109: Obtain response data in response to the encoding instruction.

[0114] The response data is the data fed back by the serial port in response to the coded command.

[0115] Step 110: Update the buffer data according to the response data.

[0116] When non-empty response data is obtained, the buffered data is updated to the response data, thereby reducing the situation where the buffered data reading fails.

[0117] Reference Figure 3 , the error display method includes the following steps:

[0118] Step 200: Obtain response data in response to the encoding instruction, and obtain the response time.

[0119] The response time refers to the length of time that has passed after a coded instruction is issued. The response time can be obtained through a timer. The method for obtaining the response time is selected by the staff based on actual conditions and will not be elaborated here.

[0120] Step 201: Update buffer data according to response data.

[0121] When non-empty response data is obtained, the buffered data is updated to the response data, thereby reducing the situation where the buffered data reading fails.

[0122] Step 202: Generate a non-response command according to the response time, and generate error data based on the non-response command, wherein the error data is used to control a preset display device to display an erroneous coded instruction.

[0123] When the response time exceeds the preset response time, it is determined that the hardware is not designed with the corresponding function, and the next instruction is directly skipped. The coded instruction can be sent multiple times to reduce the situation where the response data is not obtained. Among them, the response time refers to the maximum time that can wait for a response after issuing a coded instruction. The response time is generally 300ms. The response time is selected by the staff according to the actual situation and will not be elaborated here. The unresponded command is the command issued when the response time exceeds the preset response time. The error data refers to the data converted from the coded instruction after receiving the unresponded command. The error data is used to send to the display device to display the coded instruction that did not obtain the response data through the display device.

[0124] Step 203: Send error data to the display device.

[0125] The coding instructions to which no response is obtained are displayed through the display device, so that the staff can check the erroneous data conveniently, thereby improving the accuracy of serial port reading.

[0126] Reference Figure 4 , the read buffer method comprises the following steps:

[0127] Step 300: Generate an extraction command according to the number of read instructions in the instruction queue, and extract the read instructions in the instruction queue according to the extraction command.

[0128] When there is a read instruction in the instruction queue, the serial port is read according to the read instruction in the instruction queue. The extraction command is the command generated when there is a read instruction in the instruction queue. The read instruction refers to the read instruction at the top of the queue extracted from the instruction queue according to the extraction command. After the read instruction is extracted from the instruction queue, the original read instruction is cleared from the instruction queue to reduce the situation of repeated processing of the read instruction.

[0129] Step 301: Send a read instruction to the serial port.

[0130] Read the data in the serial port according to the read instruction.

[0131] Step 302: Obtain read data in response to a read instruction, and obtain a response time.

[0132] The read data is the data fed back by the serial port in response to the read command. The response time is the length of time that has passed after the read command is sent. The response time can be obtained through a timer. The method for obtaining the response time is selected by the staff according to the actual situation and will not be described here.

[0133] Step 303: Generate a write command according to the read data, and write the read data into the read buffer according to the write command.

[0134] When the read data is obtained, the read data is written into the read buffer, and the write command is the command issued when the read data is obtained.

[0135] Step 304: Generate a non-response command according to the response time, and write the non-response data into the read buffer according to the non-response command.

[0136] When the response time exceeds the preset response time, it is determined that the read data cannot be obtained, and the next instruction is directly skipped. The response time refers to the maximum time that can be waited for a response after issuing a read instruction. The response time is generally 300ms. The response time is selected by the staff according to the actual situation and will not be elaborated here. An unresponse command is a command issued when the response time exceeds the preset response time. Unresponse data refers to data with a length of 0. After receiving an unresponse command, the response data will be pushed into the read buffer to mark the unresponse situation, so as to facilitate subsequent secondary response and other processing of the unresponse data.

[0137] Reference Figure 5 , the data verification method includes the following steps:

[0138] Step 400: Match inversion data from a preset data inversion model according to the read data.

[0139] The data inversion model refers to a neural network model obtained through sample training in advance. The data inversion model can invert the original data to form inverted data.

[0140] Step 401: Match left-shifted data from a preset data left-shift model according to the inverted data.

[0141] The divisor refers to a binary polynomial set in advance for obtaining a check value. The data left-shift model refers to a neural network model obtained in advance through sample training. The data left-shift model can shift the inverted data to the left by a corresponding number of bits according to the highest power of the divisor to form left-shifted data.

[0142] Step 402: Match the modulo-2 remainder from a preset modulo-2 division calculation model according to the left-shifted data and the preset divisor.

[0143] The modulo-2 division calculation model refers to a neural network model obtained in advance through sample training. The modulo-2 division calculation model can calculate the modulo-2 remainder of the left-shifted data and the divisor according to the modulo-2 division.

[0144] Step 403: Match the inversion remainder from a preset data inversion model according to the modulo-2 remainder.

[0145] The inverted remainder refers to the value obtained by inverting the modulo-2 remainder through a data inversion model.

[0146] Step 404: Calculate a check value from a preset XOR calculation model according to the inverted remainder and the preset XOR value.

[0147] The XOR value refers to a binary number that is set in advance and used to perform an XOR operation with the inverted remainder to form a check value. The XOR calculation model refers to a neural network model obtained in advance through sample training, and the XOR calculation model can perform an XOR operation on the inverted remainder and the XOR value to calculate the check value.

[0148] Step 405: Match the merged data from the preset data merging model according to the read data and the check value.

[0149] The data merging model refers to a neural network model obtained through sample training in advance. The data merging model can add a check value to the low bit of the read data to form merged data.

[0150] Step 406: Write the merged data into the read buffer according to the write command.

[0151] By adding a check value to the read data and then pushing it into the read buffer, errors in the process of storing and reading the read data from the read buffer are reduced, thereby improving the accuracy of serial port reading.

[0152] Reference Figure 6 , the data verification method also includes the following steps:

[0153] Step 407: Based on the fact that the buffered data is response data, a check remainder is matched from a preset modulo-2 division calculation model according to the buffered data and a preset divisor.

[0154] The check remainder is the remainder of the buffer data and the divisor calculated by the modulo-2 division calculation model.

[0155] Step 408: When the check remainder is not 0, read the check code in the code queue according to the read command.

[0156] If the checksum remainder is not 0, it means that the buffered data is wrong, and the buffered data needs to be read again. The checksum code is the instruction code at the top of the queue obtained from the code queue according to the read command.

[0157] Step 409: Generate a verification instruction corresponding to the verification code according to the verification code.

[0158] The verification instruction is a read instruction corresponding to the verification code obtained by decoding the verification code.

[0159] Step 410: Send a verification instruction to the serial port.

[0160] Retrieve the buffered data by sending a verification command to the serial port.

[0161] Step 411: Obtain verification data in response to the verification instruction.

[0162] The verification data is the data fed back by the serial port in response to the verification instruction.

[0163] Step 412: Update the buffer data according to the verification data.

[0164] When non-empty verification data is obtained, the buffered data is updated to the verification data to reduce the possibility of buffered data errors and improve the accuracy of serial port reading.

[0165] Reference Figure 7 , the unresponse command generation method includes the following steps:

[0166] Step 500: Obtain serial port temperature.

[0167] The serial port temperature refers to the real-time temperature of the serial port. The serial port temperature can be obtained through a temperature sensor. The method for obtaining the serial port temperature is selected by the staff according to the actual situation and will not be described here.

[0168] Step 501: Match the response time from a preset response time matching model according to the serial port temperature.

[0169] The response time matching model refers to a neural network model obtained in advance through sample training. The response time matching model can match the shortest response time for the serial port to respond after receiving a read instruction according to the serial port temperature.

[0170] Step 502: Match a response interval from a preset response interval matching model according to the response time and a preset response error interval.

[0171] The response error interval refers to the time interval of the serial port response delay that is allowed to exist. The response error interval is selected by the staff according to the actual situation and will not be described here. The response interval matching model refers to a neural network model obtained through sample training in advance. The response interval matching model can match the response interval of the serial port response time that is allowed to exist.

[0172] Step 503: When the response time exceeds the response interval, a non-response command is generated.

[0173] If the response time exceeds the response interval, it means that the response time of the serial port is too long, and it is judged that the read data cannot be obtained, and a non-response command is generated, thereby reducing the situation where the serial port temperature is too high and the read data cannot be obtained, and improving the stability of the serial port reading.

[0174] Reference Figure 8 , the serial port heat dissipation method includes the following steps:

[0175] Step 600: When the serial port temperature exceeds a preset operating temperature range, the heat dissipation wind force is matched from a preset heat dissipation wind force matching model according to the serial port temperature.

[0176] The heat dissipation device refers to a device used to blow air to the serial port to speed up the heat dissipation of the serial port. The heat dissipation device is selected by the staff according to the actual situation and will not be described in detail here. The operating temperature range refers to the temperature range in which the serial port can read at a normal speed. The operating temperature range is selected by the staff according to the actual situation and will not be described in detail here. If the serial port temperature exceeds the operating temperature range, it means that the serial port temperature is too high, which may easily lead to a slow serial port reading speed or even a serial port failure.

[0177] The heat dissipation wind force matching model refers to a neural network model obtained through sample training in advance. The heat dissipation wind force matching model can match the heat dissipation wind force required to reduce the excessively high serial port temperature to within the working temperature range through the heat dissipation device.

[0178] Step 601: Match the power demand and speed change demand from a preset wind force regulation model according to the heat dissipation wind force.

[0179] The driving device refers to a device used to drive the heat sink to rotate so that the heat sink blows air. The driving device generally adopts a motor, and the driving device and the heat sink are generally meshed with gears. The speed change device refers to a device used to increase the driving effect of the driving device on the heat sink to increase the wind force blown by the heat sink. The speed change device generally increases the driving effect of the driving device on the heat sink by changing the tooth ratio of the gears between the driving device and the heat sink. The driving device and the speed change device are selected by the staff according to actual conditions and will not be elaborated here.

[0180] The wind power regulation model refers to a neural network model obtained in advance through sample training. The wind power regulation model can match the power demand and speed change demand required for driving the heat sink to rotate through the driving device to emit heat dissipation wind. The power demand refers to the intensity of the power required by the driving device, and the speed change demand refers to whether a speed change device is needed to improve the driving effect of the driving device on the heat sink.

[0181] Step 602: Supply power to a preset driving device according to power demand to drive a preset heat dissipation device.

[0182] Power is supplied according to power demand so that the driving device drives the heat dissipation device to emit heat dissipation wind force.

[0183] Step 603: Control the connection state between the preset speed change device and the driving device according to the speed change requirement to adjust the output wind force of the preset heat dissipation device.

[0184] The connection state of the speed change device and the drive device is controlled according to the speed change requirement. When the speed change device is needed, the engagement state of the drive device and the heat sink is separated, and one end of the speed change device is engaged with the drive device, and the other end of the speed change device is engaged with the heat sink. When the speed change device is not needed, the heat sink is directly driven by the drive device.

[0185] Reference Fig. 9 , the humidity control method comprises the following steps:

[0186] Step 700: Obtain ambient humidity.

[0187] Ambient humidity refers to the humidity value of the space where the serial port is located. The ambient humidity can be obtained through a humidity sensor. The method for obtaining the ambient humidity is selected by the staff according to the actual situation and will not be elaborated here.

[0188] Step 701: When the ambient humidity exceeds a preset working humidity range, a dehumidification temperature is matched from a preset dehumidification temperature matching model according to the ambient humidity.

[0189] The working humidity range refers to the humidity range in which the serial port can work normally. The working humidity range is selected by the staff according to the actual situation and will not be described here. If the humidity of the serial port exceeds the working humidity range, it means that the humidity of the environment where the serial port is located is too high, which may easily lead to a short circuit of the serial port.

[0190] The dehumidification temperature matching model refers to a neural network model obtained through sample training in advance. The dehumidification temperature matching model can match the dehumidification temperature required by reducing the excessive serial port humidity to the working humidity range.

[0191] Step 702: Match the heating power from a preset heating power matching model according to the dehumidification temperature and the serial port temperature.

[0192] The serial port reading device refers to a device for reading the serial port. The serial port reading device is selected by the staff according to the actual situation and will not be described in detail here. The heating power matching model refers to a neural network model obtained through sample training in advance. The heating power matching model can match the additional power required to increase the serial port temperature from the serial port temperature to the dehumidification temperature through the serial port reading device, and superimpose the additional power on the normally read power to form the heating power.

[0193] Step 703: Control the preset serial port reading device to read data according to the heating power.

[0194] The temperature of the serial port is increased by increasing the working power of the serial port reading device, thereby reducing the humidity around the serial port. When the temperature of the serial port is high, the heat dissipation device is started to blow air to the serial port to further reduce the humidity around the serial port, thereby improving the stability of serial port reading.

[0195] Reference Fig.10 , the thread switching control method includes the following steps:

[0196] Step 800: Match the instruction quantity from a preset instruction quantity identification model according to the instruction queue.

[0197] The instruction quantity recognition model refers to a neural network model obtained in advance through sample training. The instruction quantity recognition model can recognize the instruction quantity of the read instructions contained in the instruction queue.

[0198] Step 801: When the number of instructions falls into a preset fast read interval, extract the fast instructions in the instruction queue.

[0199] The fast reading interval refers to the pre-set instruction quantity interval that can quickly read serial port data. The fast reading interval is selected by the staff according to the actual situation and will not be described here. The number of instructions falling into the fast reading interval means that data can be quickly read through a single-threaded method at this time. The fast instruction refers to the read instruction at the top of the position queue extracted from the instruction queue. After the fast instruction is extracted, the original fast instruction is cleared from the instruction queue to reduce the situation of repeated processing of fast instructions.

[0200] Step 802: Send a quick command to the serial port.

[0201] Send fast commands to the serial port to read data.

[0202] Step 803: Acquire fast data in response to the fast instruction, and acquire fast time.

[0203] Fast data is the data fed back by the serial port in response to the fast command. Fast time refers to the length of time that has passed after the fast command is sent to the serial port. The fast time can be obtained through the timer. The method of obtaining the fast time is selected by the staff according to the actual situation, so it will not be described here.

[0204] Step 804: Generate a repeat command according to the fast time, send a fast instruction to the serial port according to the repeat command, and initialize the fast time.

[0205] When the fast time exceeds the preset fast time, it is judged that the data reading fails. At this time, it is necessary to send a fast instruction again to re-read. Among them, the fast time refers to the maximum time that can wait for the fast after issuing a fast instruction. The fast time is generally 300ms. The fast time is selected by the staff according to the actual situation and will not be repeated here. The repeat command is the command issued when the fast time exceeds the preset fast time. The fast data is re-read by repeatedly sending the fast instruction. Initializing the fast time means resetting the fast time to zero and re-acquiring it.

[0206] Step 805: Generate display data according to the fast data.

[0207] When non-empty fast data is successfully acquired, the fast data is converted into display data, and the display data is sent to a display device to display the fast data.

[0208] Step 806: Generate error data according to the fast time.

[0209] When the fast time exceeds the preset fast time again, it is determined that the read data cannot be obtained and the next instruction is directly skipped. At this time, the fast instruction that the serial port failed to respond to in time is converted into error data and displayed through the display device, so as to facilitate the staff to process the fast instruction that failed to respond in time.

[0210] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A method for fast and stable serial port batch data reading based on .NET platform, characterized in that: include: Generate a code queue and an instruction queue in response to a tool mode, the code queue includes a plurality of instruction codes, the instruction queue includes a plurality of read instructions, the instruction codes correspond to the read instructions one by one, and the read instructions are used to read data in the serial port; Sending the command queue to the serial port; In response to the instruction queue, a read buffer is established according to a preset read buffer method, wherein the read buffer includes response data and unresponse data; Generate a read command according to the amount of data in the read buffer, and read the buffered data in the read buffer according to the read command; Based on the fact that the buffered data is response data, generating display data according to the buffered data, wherein the display data is used to control a preset display device to display the buffered data; sending display data to the display device; Also includes: Based on the fact that the buffered data is unresponse data, the instruction code in the encoding queue is read according to the read command; Generate a coding instruction corresponding to the instruction coding according to the instruction coding; Sending a coding instruction to the serial port; acquiring response data in response to the encoded instruction; Update buffered data according to response data; The read buffer method comprises: Generate an extraction command according to the number of read instructions in the instruction queue, and extract the read instructions in the instruction queue according to the extraction command; Sending a read instruction to the serial port; Responding to the read instruction, obtaining read data and obtaining the response time; Generate a write command according to the read data, and write the read data into the read buffer according to the write command; A non-response command is generated according to the response time, and non-response data is written into the read buffer according to the non-response command.

2. According to claim 1, a method for realizing fast and stable serial port batch data reading based on .NET platform, characterized in that: Also included is an error display method, the error display method comprising: obtaining response data in response to the coded instruction and obtaining the response time; Update buffered data according to response data; generating an unresponse command according to the response time, and generating error data based on the unresponse command, wherein the error data is used to control a preset display device to display an erroneous coded instruction; Error data is sent to the display device.

3. According to the method of claim 1, which is characterized in that: Also included is a data verification method, the data verification method comprising: Matching the inverted data from a preset data inversion model according to the read data; Matching left-shifted data from a preset data left-shift model according to the inverted data; Matching the modulo-2 remainder from a preset modulo-2 division calculation model according to the left-shifted data and the preset divisor; Matching the inversion remainder from a preset data inversion model according to the modulo-2 remainder; Calculating a check value from a preset XOR calculation model according to the inverted remainder and a preset XOR value; Matching the merged data from a preset data merging model according to the read data and the check value; The merged data is written into the read buffer according to a write command.

4. According to claim 3, a method for realizing fast and stable serial port batch data reading based on .NET platform, characterized in that: The data verification method further includes: Based on the fact that the buffered data belongs to the response data, a check remainder is matched from a preset modulo-2 division calculation model according to the buffered data and a preset divisor; When the check remainder is not 0, read the check code in the code queue according to the read command; Generate a verification instruction corresponding to the verification code according to the verification code; Sending a verification instruction to the serial port; acquiring verification data in response to the verification instruction; Update the buffer data according to the verification data.

5. According to a method for realizing fast and stable serial port batch data reading based on .NET platform according to claim 1, it is characterized in that: It also includes a method for generating an unresponsive command, the method comprising: Get serial port temperature; Match the response time from the preset response time matching model according to the serial port temperature; Matching a response interval from a preset response interval matching model according to the response time and a preset response error interval; When the response time exceeds the response interval, a non-response command is generated.

6. The method for realizing fast and stable serial port batch data reading based on .NET platform according to claim 5, characterized in that: Also included is a serial port heat dissipation method, the serial port heat dissipation method comprising: When the serial port temperature exceeds the preset operating temperature range, the cooling wind force is matched from the preset cooling wind force matching model according to the serial port temperature; According to the cooling wind force, the power demand and speed change demand are matched from the preset wind force regulation model; supplying power to a preset driving device to drive a preset cooling device according to power demand; The connection state of the preset speed change device and the driving device is controlled according to the speed change demand to adjust the output wind force of the preset heat dissipation device.

7. The method for realizing fast and stable serial port batch data reading based on .NET platform according to claim 6 is characterized in that: Also included is a humidity control method, the humidity control method comprising: Get the ambient humidity; When the ambient humidity exceeds the preset working humidity range, the dehumidification temperature is matched from the preset dehumidification temperature matching model according to the ambient humidity; Matching the heating power from a preset heating power matching model according to the dehumidification temperature and the serial port temperature; The preset serial port reading device is controlled to read data according to the heating power.

8. The method for realizing fast and stable serial port batch data reading based on .NET platform according to claim 1, characterized in that: It also includes a thread switching control method, the thread switching control method comprising: Matching the instruction quantity from a preset instruction quantity recognition model according to the instruction queue; When the number of instructions falls into a preset fast reading interval, extracting fast instructions in the instruction queue; Sending a quick command to the serial port; Responding to the fast instruction, acquiring fast data and acquiring fast time; generating a repeat command according to the fast time, sending a fast instruction to the serial port according to the repeat command, and initializing the fast time; Generate display data based on fast data; Generates incorrect data based on fast time.

Citation Information

Patent Citations

  • Serial batch data transmission method and device and storage medium

    CN108804362A

  • Efficient automatic retransmission method in broadband ad hoc network

    CN115051775A