A JsonRPC-based serial communication method between downhole devices

By designing a JsonRPC serial communication method between downhole equipment and adopting a frame-based transmission of Json data, the problem of communication between downhole equipment using JsonRPC was solved, and efficient data transmission between downhole equipment was achieved.

CN116781760BActive Publication Date: 2025-11-21TIANDI CHANGZHOU AUTOMATION +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310763604.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-26
Publication Date
2025-11-21
Estimated Expiration
2043-06-26

AI Technical Summary

Technical Problem

The JsonRPC server and client implementation is difficult to apply to serial communication between downhole equipment.

Method used

This paper proposes a serial communication method between downhole devices based on JsonRPC. The method uses request and response frames between the client and server to transmit JSON data in frames, including the frame processing of request and response frames, to ensure the orderliness and accuracy of data transmission.

Benefits of technology

It enables the JsonRPC server and client to operate between downhole devices based on serial communication, improving the orderliness, accuracy and transmission efficiency of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116781760B_ABST
    Figure CN116781760B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of communication methods, in particular to a JsonRPC-based serial communication method between downhole devices, which comprises the following steps: step 1: a client sends a request frame to a server; step 2: the server sends a response frame to the client according to the received request frame; and step 3: the client analyzes the received response frame and returns the result to an upper-layer application. The application has the beneficial effect that a JsonRPC-based serial communication method between downhole devices is designed, so that the JsonRPC server and client can run on downhole devices based on serial communication. Long Json data is divided into frames for transmission, so that the order, accuracy and transmission efficiency of serial communication are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of communication methods, in particular to a serial communication method between underground devices based on JsonRPC. BACKGROUND

[0002] With the continuous development of underground communication technology in coal mines, various underground communication devices are more and more, the communication between devices is frequent, and the amount of data transmission is also more and more large. At present, the devices in the coal mine mainly transmit data through the Ethernet and serial port.

[0003] JSON-RPC is a stateless and lightweight remote procedure call (RPC) transmission protocol, which transmits content mainly through JSON. Compared with the general REST through the URL (such as GET / user) to call the remote server, JSON-RPC directly defines the function name to be called in the content (such as {"method":"getUser"}), which also makes the developer not fall into the problem of using PUT or PATCH.

[0004] The physical communication layer relied on by the existing JsonRPC server and client implementation mode is mostly Ethernet, and the communication protocol relied on is mostly TCP / IP protocol, which is difficult to apply to the serial communication scene between underground devices. SUMMARY

[0005] The technical problem to be solved by the application is that the JsonRPC server and client implementation mode is difficult to apply to the serial communication between underground devices.

[0006] To this end, the application provides a serial communication method between underground devices based on JsonRPC.

[0007] The technical scheme adopted by the application to solve the technical problem is:

[0008] A serial communication method between underground devices based on JsonRPC, comprising the following steps:

[0009] Step 1: the client sends a request frame to the server;

[0010] Step 2: the server sends a response frame to the client according to the received request frame;

[0011] Step 3: the client parses the received response frame and returns the result to the upper layer application.

[0012] By adopting the above technical scheme, a serial communication method between underground devices based on JsonRPC is designed, so that the JsonRPC server and client can run on the underground devices based on serial communication.

[0013] Further, the server receives the request frame sent by the client in step 2, parses the received Json data, executes the call function, and sends the result to the client as a response frame.

[0014] Further, the frame information in the request frame includes the Json data offset, the total length of the Json data, the Json data check CRC, and the Json data, wherein the Json data offset represents the offset position of the Json data transmitted in the frame in the complete Json data.

[0015] Further, the frame information of the response frame mainly includes the Json data offset, the total length of the Json data, the Json data check CRC, and the Json data, wherein the Json data offset represents the offset position of the Json data transmitted in the frame in the complete Json data.

[0016] Further, before step 2, the client sends the request frame in frames, the server responds to the request frame after framing, and the information in the response frame includes the Json data offset in the next request frame.

[0017] Further, after the client receives the response frame sent by the server for the request frame after framing, the client updates the Json data offset and the Json data in the request frame according to the Json data offset in the response frame, and sends the request frame.

[0018] Further, the response frame in step 3 is framed, the client sends the request frame after receiving the response frame sent by the server, and the frame information in the request frame includes the Json data offset in the next response frame.

[0019] Further, after the server receives the request frame sent by the client, the server updates the Json data offset and the Json data in the response frame according to the Json data offset in the request frame, and sends the response frame to the client.

[0020] Further, if data transmission error or timeout occurs during the sending or receiving of data by the client, the client remotely calls the function to return an error value.

[0021] Further, if data transmission error or timeout occurs during the receiving or sending state of the server, the server clears the internal data transmission and reception, and changes the state to the receiving state.

[0022] The beneficial effect of the present application is that a JsonRPC-based serial communication method between downhole devices is designed, so that the JsonRPC server and client can run on downhole devices based on serial communication. The longer Json data is divided into frames for transmission, improving the orderliness, accuracy and transmission efficiency of serial communication. BRIEF DESCRIPTION OF DRAWINGS

[0023] The present application is further illustrated below in conjunction with the accompanying drawings and examples.

[0024] Figure 1 is a flow chart of the serial communication steps between the client and the server in embodiment 1 of the present application.

[0025] Figure 2 is a schematic diagram of the server state of the present application.

[0026] Figure 3 is a flow chart of the serial communication steps between the client and the server in embodiment 2 of the present application.

[0027] Figure 4 is a flow chart of the serial communication steps between the client and the server in embodiment 3 of the present application.

[0028] Figure 5 is a flow chart of the serial communication steps between the client and the server in embodiment 4 of the present application. DETAILED DESCRIPTION

[0029] The present application will now be further described in conjunction with the accompanying drawings. These drawings are all simplified schematic diagrams, and only illustrate the basic structure of the present application in a schematic manner, and therefore only show the structures related to the present application.

[0030] In the description of the present application, it should be understood that the terms "center", "longitudinal", "transverse", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and therefore cannot be understood as indicating or implying that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application. In addition, the features defined as "first", "second" can be explicitly or implicitly included one or more of the features. In the description of the present application, unless otherwise stated, the meaning of "a plurality of" is two or more.

[0031] In the description of the present application, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connection", "linking" should be understood in a broad sense, for example, it can be fixed connection, or detachable connection, or integral connection; it can be mechanical connection, or electrical connection; it can be direct connection, or indirect connection through intermediate medium, or internal communication of two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0032] Embodiment 1

[0033] Referring to Figure 1 A JsonRPC-based serial communication method between downhole devices, the serial communication between the JsonRPC client and the server includes the following steps:

[0034] Step 1.1: The client sends a request frame A1 to the server, and the frame information mainly includes the Json data offset, the Json data total length, the Json data check CRC and the Json data. The Json data offset indicates the offset position of the Json data in the complete Json data.

[0035] Step 1.2: The server receives the request frame A1 sent by the client, parses the received Json data, executes the calling function and sends the result to the client as a response frame B1. The frame information mainly includes the Json data offset, the Json data total length, the Json data check CRC and the Json data.

[0036] Step 1.3: The client parses the received response frame B1, and returns the result to the upper layer application, and the JsonRPC remote call ends.

[0037] Referring to Figure 2 After the application layer in the JsonRPC client generates a request Json according to the business requirements, the remote calling function is executed, the remote calling function sends the request frame according to the foregoing serial communication steps, after sending the request frame, the response frame sent by the server is received according to the foregoing serial communication steps, after successful reception, the Json is parsed, and the result is returned to the application layer. If data transmission error or timeout occurs during data transmission or reception of the client, the remote calling function returns an error value.

[0038] Referring to Figure 2The JsonRPC server switches the internal state through a state machine. The state machine includes a receiving state and a sending state. After the server is initialized, it enters the receiving state by default. In the receiving state, the server processes the request frame sent by the client according to the foregoing serial communication steps. When the receiving is completed, the server calls a corresponding function, obtains the calling result, and switches the state to the sending state. In the sending state, the server sends the response frame according to the foregoing serial communication steps. If an error occurs in the receiving or sending state, or a timeout occurs, the server clears the internal receiving and sending data, and switches the state to the receiving state.

[0039] With reference to Figure 2 Each time the communication interaction between the JsonRPC server and the client is that the client first sends a request frame. After the server receives the request frame, the server parses the Json data, executes a calling function, and sends the result to the client in the form of a response frame.

[0040] In serial communication, because the effective data length that can be transmitted by one frame of serial data frame is limited, the communication protocol specifies the maximum length of one frame of serial frame. For example, the communication protocol specifies that the maximum length of the serial frame is 255 bytes. When the length of the Json data exceeds 255 bytes, one frame of serial frame cannot be sent completely, and two frames or even more frames are needed to send the Json data completely. At this time, the longer Json data needs to be divided into several frames with a length less than 255 bytes and then sent.

[0041] Therefore, when the length of the Json data is relatively long, the server or the client needs to send the Json data in frames. Therefore, there are four serial communication scenarios between the JsonRPC server and the client.

[0042] The serial communication scenario in the embodiment is that the request frame is not divided into frames, and the response frame is not divided into frames.

[0043] Embodiment 2

[0044] With reference to Figure 3 The difference between the embodiment and embodiment 1 is that the serial communication scenario in the embodiment is that the request frame is divided into frames, and the response frame is not divided into frames.

[0045] Step 2.1: The client sends a request frame A20 to the server. The frame information mainly includes a Json data offset, a total length of the Json data, a Json data check CRC, and the Json data.

[0046] Step 2.2: After the server receives the request frame A20 sent by the client, the server sends a response frame B20. The frame information includes a Json data offset in the next request frame A21.

[0047] Step 2.3: The client receives the response frame B20 sent by the server, updates the Json data offset and the Json data in the request frame A21 according to the Json data offset in the response frame B20 in step 2.2, and sends the request frame A21 to the client.

[0048] Step 2.4: Repeat steps 2.2 and 2.3, the server sends the response frame B21 after receiving the request frame A21 sent by the client, and the frame information contains the Json data offset in the next frame request frame A22; the client receives the response frame B21 sent by the server, updates the Json data offset and the Json data in the request frame A22 according to the Json data offset in the response frame B21, and sends the request frame A22 to the client, and so on until the last frame request frame A2n is sent.

[0049] Step 2.5: The server receives the last frame request frame A2n sent by the client, parses the received Json data, executes the call function and packs the result as the response frame B2n, and sends it to the client.

[0050] Step 2.6: The client parses the received response frame B2n, and returns the result to the upper layer application, and the JsonRPC remote call ends.

[0051] Embodiment 3

[0052] Reference Figure 4 In this embodiment, the serial communication scenario is that the request frame is not framed, and the response frame is framed.

[0053] Step 3.1: The client sends the request frame A30 to the server, and the frame information mainly contains the Json data offset, the total length of the Json data, the Json data check CRC and the Json data. The Json data offset represents the offset position of the json data transmitted in this frame in the complete Json data.

[0054] Step 3.2: The server receives the request frame A30 sent by the client, parses the received Json data, executes the call function and packs the result as the response frame B30, and sends it to the client.

[0055] Step 3.3: The client receives the response frame B30 sent by the server, and sends the request frame A31, and the frame information contains the Json data offset in the next frame response frame B31.

[0056] Step 3.4: The server receives the request frame A31 sent by the client, updates the Json data offset and the Json data in the response frame B31 according to the Json data offset in the request frame A31 in step 3.3, and sends the response frame B31.

[0057] Step 3.5: Repeat step 3.3 and step 3.4, the client sends a request frame A32 after receiving the response frame B31 sent by the server, and the frame information contains the Json data offset in the next response frame B32; the server receives the request frame A32 sent by the client, updates the Json data offset and the Json data in the response frame B32 according to the Json data offset in the request frame A32, and sends the response frame B32, and so on until the last response frame B3n is sent.

[0058] Step 3.6: The client parses the received response frame B3n and returns the result to the upper layer application, and the current JsonRPC remote call ends.

[0059] Embodiment 4

[0060] Reference Figure 5 In this embodiment, the serial communication scenario is: the request frame is divided into frames, and the response frame is divided into frames.

[0061] Step 4.1: The client sends a request frame A40 to the server, and the frame information mainly includes the Json data offset, the total length of the Json data, the Json data check CRC and the Json data. The Json data offset indicates the offset position of the Json data transmitted in the frame in the complete Json data.

[0062] Step 4.2: The server sends a response frame B40 after receiving the request frame A40 sent by the client, and the frame information contains the Json data offset in the next request frame A41.

[0063] Step 4.3: The client receives the response frame B40 sent by the server, updates the Json data offset and the Json data in the request frame A41 according to the Json data offset in the response frame B40, and sends the request frame A41 to the client.

[0064] Step 4.4: Repeat step 4.2 and step 4.3, the server sends a response frame B41 after receiving the request frame A41 sent by the client, and the frame information contains the Json data offset in the next request frame A42; the client receives the response frame B41 sent by the server, updates the Json data offset and the Json data in the request frame A42 according to the Json data offset in the response frame B41, and sends the request frame A42 to the client, and so on until the last request frame A4n is sent.

[0065] Step 4.5: The server receives the request frame A4n sent by the client, parses the received Json data, executes the calling function and sends the response frame B4n to the client after packaging the result.

[0066] Step 4.6: After receiving the response frame B4n sent by the server, the client sends a request frame A4n+1, and the frame information contains the Json data offset in the next frame response frame B4n+1.

[0067] Step 4.7: After receiving the request frame A4n+1 sent by the client, the server updates the Json data offset and the Json data in the response frame B4n+1 according to the Json data offset in the request frame A4n+1, and sends the response frame B4n+1. + 1

[0068] Step 4.8: Repeat steps 4.6 and 4.7. After receiving the response frame B4n+1 sent by the server, the client sends a request frame A4n+2, and the frame information contains the Json data offset in the next frame response frame B4n+2; after receiving the request frame A4n+2 sent by the client, the server updates the Json data offset and the Json data in the response frame B4n+2 according to the Json data offset in the request frame A4n+2, and sends the response frame B4n+2, and so on, until the last frame response frame B4n+n is sent.

[0069] Step 4.9: The client parses the received response frame B4n+n and returns the result to the upper layer application, and the current JsonRPC remote call ends.

[0070] In summary, a serial communication method between downhole devices based on JsonRPC is designed, so that the JsonRPC server and client can run on downhole devices based on serial communication. When the length of the Json data is long, the server or client sends the Json data in frames, which improves the orderliness, accuracy and transmission efficiency of serial communication.

[0071] Based on the above ideal embodiments according to the present application, through the above description, relevant personnel can make various changes and modifications without deviating from the scope of the present application. The technical scope of the present application is not limited to the contents of the specification, and must be determined by the scope of the claims.​

Claims

1. A serial communication method between downhole equipment based on JsonRPC, characterized in that, Includes the following steps: Step 1: The client sends a request frame to the server; Step 2: The server sends a response frame to the client based on the received request frame; Step 3: The client parses the received response frame and returns the result to the upper-layer application; Before step 2, the client sends the request frame in segments, and the server responds with the segmented request frame. The information in the response frame includes the JSON data offset in the next request frame. The response frame in step 3 is divided into frames. After receiving the response frame sent by the server, the client sends a request frame. The frame information in the request frame includes the JSON data offset in the next response frame.

2. The serial communication method between downhole equipment based on JsonRPC according to claim 1, characterized in that, In step 2, the server receives the request frame sent by the client, parses the received JSON data, executes the function call, and packages the result into a response frame before sending it to the client.

3. The serial communication method between downhole equipment based on JsonRPC according to claim 1, characterized in that, The frame information in the request frame includes JSON data offset, total JSON data length, JSON data checksum CRC, and JSON data, where the JSON data offset represents the offset position of the JSON data transmitted in this frame within the complete JSON data.

4. The serial communication method between downhole equipment based on JsonRPC according to claim 3, characterized in that, The frame information of the response frame mainly includes JSON data offset, total JSON data length, JSON data check CRC, and JSON data. The JSON data offset indicates the offset position of the JSON data transmitted in this frame within the complete JSON data.

5. The serial communication method between downhole equipment based on JsonRPC according to claim 1, characterized in that, After receiving the response frame sent by the server for the segmented request frame, the client updates the JSON data offset and JSON data in the current request frame according to the JSON data offset in the response frame, and then sends the current request frame.

6. A serial communication method between downhole equipment based on JsonRPC according to claim 5, characterized in that, After receiving the request frame sent by the client, the server updates the JSON data offset and JSON data in the current response frame according to the JSON data offset in the request frame, and then sends the current response frame to the client.

7. A serial communication method between downhole equipment based on JsonRPC according to claim 1, characterized in that, If a data transmission error or timeout occurs during data transmission or reception by the client, the client remotely calls a function to return an error value.

8. A serial communication method between downhole equipment based on JsonRPC according to claim 1, characterized in that, If the server encounters a data transmission / reception error or timeout in the receiving or sending state, the server will clear its internal data transmission / reception information and switch the state to the receiving state.

Citation Information

Patent Citations

  • Method of automatically setting protocol in programmable logic controller system

    CN106059990A