Disclosure of Invention
The invention provides a remote power supply monitoring method and device based on a CAN bus, which overcome the defects of the prior art, and CAN effectively solve the problem that the existing method for monitoring the power supply data of a host computer by a BMC through an IIC bus cannot monitor an external power supply which is remote and is provided with a CAN interface.
One of the technical schemes of the invention is realized by the following measures: a remote power supply monitoring method based on a CAN bus comprises the following steps:
connecting a CAN interface in the BMC with a CAN interface of an external power supply, and judging whether the CAN interface in the BMC receives data or prepares to send the data;
in response to the received data, a CAN power supply data receiving process is established, a can_uteis module is called to monitor and receive CAN data frames, the CAN data frames are analyzed and stored in a file form, and the CAN data frames are reported by an external power supply with a CAN interface;
and responding to the data to be sent, creating a CAN power supply setting process, acquiring a control instruction, and calling a can_utels module to issue to an external power supply provided with a CAN interface after framing, wherein the control instruction is an instruction agreed according to an external power supply CAN communication protocol.
The following are further optimizations and/or improvements to the above-described inventive solution:
the creating a CAN power supply data receiving process, calling a can_uteils module to monitor and receive a CAN data frame, analyzing and storing and displaying in a file form, and the method comprises the following steps:
creating a CAN power supply data receiving process, and calling a can_uteils module to monitor a CAN data frame received by a CAN interface in the BMC;
judging whether the CAN data frame is a CAN power frame, and analyzing the CAN data frame in response to the CAN power frame;
after analysis, judging whether the CAN data frame is a CAN power supply data frame, and in response, receiving the analyzed CAN data frame and storing the analyzed CAN data frame into an instruction directory in a file form.
When the CAN data frames stored in the file form are displayed, the file is converted into json format and reported to the web page for displaying.
The creating a CAN power supply setting process, issuing a control instruction, including:
creating a CAN power supply setting process, and acquiring a control instruction, wherein the control instruction is an instruction agreed according to an external power supply CAN communication protocol;
framing the control instruction according to the CAN communication protocol to form a control frame;
calling a can_uteils module to send a control frame down to an external power supply provided with a CAN interface;
and judging whether a response frame is received within the set time, and responding to the response frame, and successfully completing the issuing of the control instruction.
The control instruction comprises a power supply control instruction and a parameter setting instruction.
The second technical scheme of the invention is realized by the following measures: the remote power supply monitoring device based on the CAN bus comprises a power supply data monitoring unit and a CAN interface, wherein the power supply data monitoring unit and the CAN interface are arranged in a BMC;
the CAN interface is connected with a CAN interface of an external power supply provided with the CAN interface, and CAN communication is established;
the data reporting module is used for creating a CAN power supply data receiving process, calling the can_utels module to monitor and receive CAN data frames, analyzing and storing the CAN data frames in a file form, wherein the CAN data frames are reported by an external power supply with a CAN interface;
the control instruction issuing module is used for creating a CAN power supply setting process, acquiring a control instruction, and calling the can_uteis module to issue the control instruction to an external power supply provided with a CAN interface after framing, wherein the control instruction is an instruction for controlling the external power supply provided with the CAN interface.
The following are further optimizations and/or improvements to the above-described inventive solution:
the data reporting module comprises:
the CAN data frame receiving and analyzing module is used for creating a CAN power supply data receiving process, calling the can_utels module to monitor and receive the CAN data frame, analyzing and storing the CAN data frame in a file form to an instruction directory, wherein the CAN data frame is reported by an external power supply with a CAN interface;
the first data transfer module is used for converting the file stored in the CAN data frame receiving and analyzing module into json format;
and the Web data display page displays the json format file.
The control instruction issuing module comprises:
the Web control setting page is used for acquiring a control instruction, wherein the control instruction is an instruction agreed according to an external power can communication protocol;
the second data transfer module forwards the control instruction to the CAN data frame framing and sending module;
the CAN data frame framing transmitting module is used for framing the control instruction according to a CAN communication protocol to form a control frame; and calling the can_uteils module to send the control frame down to an external power supply provided with a CAN interface.
The invention provides a remote power supply monitoring method based on a CAN bus, which is used for realizing the power supply monitoring of a BMC (baseboard management controller) on an external power supply provided with a CAN interface through the CAN bus, acquiring CAN data frames or issuing control instructions, solving the problem that the existing method for monitoring the power supply data through an IIC (inter-integrated circuit) bus cannot monitor an external power supply which is remote and provided with the CAN interface, and being capable of monitoring the external power supply which is remote and provided with the CAN interface in real time, and having long communication transmission distance, strong electromagnetic interference resistance and high transmission rate.
Detailed Description
The present invention is not limited by the following examples, and specific embodiments can be determined according to the technical scheme and practical situations of the present invention.
The invention is further described below with reference to examples and figures:
as shown in fig. 1, the embodiment of the invention discloses a remote power supply monitoring method based on a CAN bus, which comprises the following steps:
s1, connecting a CAN interface in the BMC with a CAN interface of an external power supply, and judging whether the CAN interface in the BMC receives data or prepares to send the data;
s2, in response to the received data, a CAN power supply data receiving process is established, a can_uteis module is called to monitor and receive CAN data frames, the CAN data frames are analyzed and stored in a file form, and the CAN data frames are reported by an external power supply with a CAN interface;
and S3, responding to the data to be sent, creating a CAN power supply setting process, acquiring a control instruction, and calling a can_utels module to issue to an external power supply provided with a CAN interface after framing, wherein the control instruction is an instruction agreed according to a CAN communication protocol of the external power supply.
In the above technical scheme, the external power supply provided with the CAN interface CAN be an external power supply which is not on-chip and has a transmission distance of more than 1 meter, and the external power supply is provided with the CAN interface.
In the step S2 of the technical scheme, the CAN data frame is analyzed and stored in an indication directory in a file form; when the CAN data frames stored in the file form are displayed, the file is converted into json format and reported to the web page for display.
The invention operates in an environment comprising a BMC (baseboard management controller) provided with a CAN (controller area network) interface and an external power supply provided with the CAN interface, and provides a remote power supply monitoring method based on a CAN bus.
The following are further optimizations and/or improvements to the above-described inventive solution:
as shown in fig. 2, in the above embodiment, the CAN interface in the BMC is connected with the CAN interface of the external power source, a CAN power source data receiving process is created, the can_uteis module is called to monitor and receive CAN data frames, in the remote power source monitoring method based on the CAN bus in this embodiment, the can_utes module is called to monitor and receive CAN data frames, and the CAN data frames are analyzed and stored in the form of files, which may further include:
s21, creating a CAN power supply data receiving process, and calling a can_utels module to monitor CAN data frames received by a CAN interface in the BMC;
s22, judging whether the CAN data frame is a CAN power frame, analyzing the CAN data frame in response to the CAN power frame, and discarding the CAN data frame in response to the CAN power frame;
s23, judging whether the CAN data frame is a CAN power supply data frame after analysis, receiving the analyzed CAN data frame in response, storing the analyzed CAN data frame in a file form into an instruction directory, and discarding the CAN data frame in response to the analysis.
In step S21 of the above technical solution, after the CAN power data receiving process (for example CAN power receiver) is created, the baud rate is configured and enabled for the CAN interface of the BMC, and then the can_uteils module is called to cyclically monitor the CAN data frame.
In step S22 of the above technical solution, it is determined whether the received CAN data frame is a CAN power supply data frame, that is, whether the received CAN data frame is a CAN data frame required by the BMC is determined by determining the frame ID of the CAN data frame, and if the received CAN data frame is not a CAN power supply data frame, the received CAN data frame is considered to be another frame (for example, a data frame transmitted by a non-external power supply), so that the CAN data frame is discarded.
In step S23 of the above technical solution, if the CAN data frame is determined to be a CAN power supply data frame after parsing, in response to this, the parsed CAN data frame is received, the parsed CAN data frame is stored in the instruction directory in the form of a file, and in response to this, the CAN data frame is considered to be an error frame (for example, an error frame in which signal interference generates a data error), so that the CAN data frame is discarded and error reporting is performed.
In step S23 of the above technical solution, the CAN data frame stored in the form of a file includes data such as voltage value, current value, power temperature value, on-off state, and temperature state of each power supply such as AC220V, DC24V, DC V, DC V in the external power supply provided with the CAN interface.
As shown in fig. 3, in the above embodiment, the CAN interface in the BMC is connected with the CAN interface of the external power source, a CAN power source setting process is created, and a control instruction is issued, and in the remote power source monitoring method based on the CAN bus in this embodiment, the CAN power source setting process is created, and the control instruction is issued, which may further include:
s31, creating a CAN power supply setting process, and acquiring a control instruction, wherein the control instruction is an instruction agreed according to an external power supply CAN communication protocol;
s32, framing the control instruction according to the CAN communication protocol to form a control frame;
s33, calling a can_uteils module to send a control frame down to an external power supply provided with a CAN interface;
s34, judging whether a response frame is received within the set time, if yes, completing the control instruction issuing successfully, and if no, failing to complete the control instruction issuing.
In the above technical solution step S31, the CAN power supply setting process may be a background web page request processing process (bus-sysctl); the control instruction comprises a power supply control instruction and a parameter setting instruction, wherein the parameters comprise parameters such as over-voltage and under-voltage values of all paths of power supplies, over-current and under-current values of all paths of current, over-temperature points of an input power supply and the like in an external power supply with a CAN interface; the power control includes power on/off control.
As shown in fig. 4, correspondingly, the embodiment of the invention also discloses a remote power supply monitoring device based on a CAN bus, which comprises a power supply data monitoring unit and a CAN interface, wherein the power supply data monitoring unit is arranged in a BMC and comprises a process starting module, a data reporting module and a control instruction issuing module;
the CAN interface is connected with a CAN interface of an external power supply provided with the CAN interface, and CAN communication is established;
the data reporting module is used for creating a CAN power supply data receiving process, calling the can_utels module to monitor and receive CAN data frames, analyzing and storing the CAN data frames in a file form, wherein the CAN data frames are reported by an external power supply with a CAN interface;
the control instruction issuing module is used for creating a CAN power supply setting process, acquiring a control instruction, and calling the can_uteis module to issue the control instruction to an external power supply provided with a CAN interface after framing, wherein the control instruction is an instruction for controlling the external power supply provided with the CAN interface.
The following are further optimizations and/or improvements to the above-described inventive solution:
as shown in fig. 4, in the above embodiment, the remote power monitoring device based on the CAN bus includes a power data monitoring unit and a CAN interface, where the power data monitoring unit includes a process starting module, a data reporting module, and a control instruction issuing module, and in the remote power monitoring device based on the CAN bus in this embodiment, the data reporting module may further include:
the CAN data frame receiving and analyzing module is used for creating a CAN power supply data receiving process, calling the can_utels module to monitor and receive the CAN data frame, analyzing and storing the CAN data frame in a file form to an instruction directory, wherein the CAN data frame is reported by an external power supply with a CAN interface;
the first data transfer module is used for converting the file stored in the CAN data frame receiving and analyzing module into json format;
and the Web data display page displays the json format file.
In the technical scheme, when the can_uteis module is called by the CAN data frame receiving and analyzing module to monitor and receive CAN data frames, the CAN data frames received by the CAN interface in the BMC are monitored firstly, whether the CAN data frames are CAN power frames or not and whether the CAN data frames are CAN power frames or not are judged and judged in sequence, so that whether the monitored CAN data frames are normal CAN data frames or not is determined, and the normal CAN data frames are stored in a command directory in a file mode.
As shown in fig. 4, in the above embodiment, the remote power monitoring device based on the CAN bus includes a power data monitoring unit and a CAN interface, where the power data monitoring unit includes a process starting module, a data reporting module, and a control instruction issuing module, and in the remote power monitoring device based on the CAN bus in this embodiment, the control instruction issuing module may further include:
the Web control setting page is used for acquiring a control instruction, wherein the control instruction is an instruction agreed according to an external power can communication protocol;
the second data transfer module forwards the control instruction to the CAN data frame framing and sending module;
the CAN data frame framing transmitting module is used for framing the control instruction according to a CAN communication protocol to form a control frame; and calling the can_uteils module to send the control frame down to an external power supply provided with a CAN interface.
The technical characteristics form the optimal embodiment of the invention, have stronger adaptability and optimal implementation effect, and can increase or decrease unnecessary technical characteristics according to actual needs so as to meet the requirements of different situations.