2024-07-13 02:22:47 +00:00
|
|
|
|
/*
|
|
|
|
|
* communication_protocol.h
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2024<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>18<EFBFBD><EFBFBD>
|
|
|
|
|
* Author: 34509
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef SOFTWARE_PROTOCOL_COMMUNICATION_PROTOCOL_H_
|
|
|
|
|
#define SOFTWARE_PROTOCOL_COMMUNICATION_PROTOCOL_H_
|
|
|
|
|
|
2024-07-13 03:43:10 +00:00
|
|
|
|
#include "inc/UART.h"
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-13 05:59:56 +00:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
SL_Function_Code_Read_Register = 0x30, /* <20><><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Function_Code_Write_Register = 0x10, /* д<>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Function_Code_Broadcast_Scan = 0xA0, /* <20>㲥ɨ<E3B2A5><C9A8> */
|
|
|
|
|
SL_Function_Code_Registration_request = 0xA1, /* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
}SL_MsgFunctionCode;
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-15 09:22:55 +00:00
|
|
|
|
/* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
SL_Register_Registration_Status = 0x0000, /* ע<><D7A2>״̬ */
|
|
|
|
|
SL_Register_address = 0x0001, /* <20><>ַ */
|
|
|
|
|
SL_Register_Access_Node_Type = 0x0002, /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Communication_Methods = 0x0003, /* ͨ<>ŷ<EFBFBD>ʽ */
|
|
|
|
|
|
|
|
|
|
SL_Register_Battery_Voltage = 0x0100, /* <20><><EFBFBD>ص<EFBFBD>ѹ */
|
|
|
|
|
SL_Register_Battery_temperature = 0x0101, /* <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> */
|
|
|
|
|
SL_Register_Remaining_Battery_Bower = 0x0102, /* <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Solar_Open_Circuit_Voltage1 = 0x0103, /* ̫<><CCAB><EFBFBD>ܿ<EFBFBD>·<EFBFBD><C2B7>ѹ1 */
|
|
|
|
|
SL_Register_Solar_Open_Circuit_Voltage2 = 0x0104, /* ̫<><CCAB><EFBFBD>ܿ<EFBFBD>·<EFBFBD><C2B7>ѹ2 */
|
|
|
|
|
|
|
|
|
|
SL_Register_Ambient_Temperature = 0x0200, /* <20><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD> */
|
|
|
|
|
SL_Register_Ambient_Humidity = 0x0201, /* <20><><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA> */
|
|
|
|
|
SL_Register_Barometric_Pressure = 0x0202, /* <20><><EFBFBD><EFBFBD>ѹ */
|
|
|
|
|
SL_Register_Wind_Speed = 0x0203, /* <20><><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Wind_Direction = 0x0204, /* <20><><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Rainfall = 0x0205, /* <20><><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Optical_Radiation = 0x0206, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
SL_Register_Leakage_Current_Value = 0x0220, /* й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵ */
|
|
|
|
|
SL_Register_Leakage_Current_MaxValue = 0x0221, /* <20><><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵ */
|
|
|
|
|
SL_Register_Pulse_Frequency = 0x0222, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Zero_Leakage_Current_MaxValue_Statistics = 0x0223, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>й©<D0B9><C2A9><EFBFBD><EFBFBD>ֵͳ<D6B5><CDB3> */
|
|
|
|
|
SL_Register_Zero_Pulse_Frequency_Statistics = 0x0224, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> */
|
|
|
|
|
|
|
|
|
|
SL_Register_Inclination_AngleX = 0x0230, /* X<><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Inclination_AngleY = 0x0231, /* Y<><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
SL_Register_Zero_Inclination_Angle = 0x0232, /* У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
}SL_MsgRegister;
|
|
|
|
|
|
|
|
|
|
/* ע<><D7A2>״̬ */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
UNREGISTER = 0, /* δע<CEB4><D7A2> */
|
|
|
|
|
REGISTER_FAIL = 1, /* ע<><D7A2>ʧ<EFBFBD><CAA7> */
|
|
|
|
|
REGISTER_SUCCESS = 2, /* ע<><D7A2><EFBFBD>ɹ<EFBFBD> */
|
|
|
|
|
}SL_REGISTERSTATUS;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
POWERBOX = 1, /* <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> */
|
|
|
|
|
MICROMETEOROLOGY = 2, /* <><CEA2><EFBFBD><EFBFBD> */
|
|
|
|
|
}SL_ACCESSNODETYPE;
|
|
|
|
|
|
|
|
|
|
/* ͨ<>ŷ<EFBFBD>ʽ */
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
RS485 = 1,
|
|
|
|
|
RJ45 = 2,
|
|
|
|
|
}SL_COMMUNICATIONMETHODS;
|
|
|
|
|
|
|
|
|
|
/* ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>뷽ʽΪ1<CEAA>ֽ<EFBFBD> */
|
|
|
|
|
#pragma pack(push,1)
|
|
|
|
|
|
|
|
|
|
/* <20><>ʱ<EFBFBD><CAB1><EFBFBD>͵<EFBFBD>֡<EFBFBD><D6A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD><EFBFBD>ڵ㣩 */
|
|
|
|
|
typedef struct _SL_Mppt_Rorecv_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t read_Register_Start_Address_H; /* <20><>ȡ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ<EFBFBD><D6B7>8λ */
|
|
|
|
|
uint8_t read_Register_Start_Address_L; /* <20><>ȡ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t read_Register_Number_H; /* <20><>ȡ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t read_Register_Number_L; /* <20><>ȡ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_H; /* У<><D0A3>λ<EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_L; /* У<><D0A3>λ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
|
|
|
|
}SL_Mppt_Rorecv_pack;
|
|
|
|
|
#define SL_MPPT_RORECV_PACK_SIZE (sizeof(SL_Mppt_Rorecv_pack))
|
|
|
|
|
|
|
|
|
|
/* <20><>ʱ<EFBFBD><CAB1><EFBFBD>յ<EFBFBD><D5B5>Ļظ<C4BB>֡<EFBFBD><D6A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>-><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD> */
|
|
|
|
|
typedef struct _SL_Mppt_ROReply_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t write_Register_Number_H; /* <20>ظ<EFBFBD><D8B8>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȸ߰<C8B8>λ */
|
|
|
|
|
uint8_t write_Register_Number_L; /* <20>ظ<EFBFBD><D8B8>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵͰ<C8B5>λ */
|
|
|
|
|
uint8_t *content; /* <20>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t check_Bit_H; /* У<><D0A3>λ<EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_L; /* У<><D0A3>λ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
|
|
|
|
}SL_Mppt_ROReply_pack;
|
|
|
|
|
#define SL_MPPT_ROReply_PACK_SIZE (sizeof(SL_Mppt_ROReply_pack))
|
|
|
|
|
|
|
|
|
|
/* ɨ<><C9A8><EFBFBD>㲥֡F1<46><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD><EFBFBD>ڵ㣩 */
|
|
|
|
|
typedef struct _SL_Mppt_ScanBroadcast_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t check_Bit_H; /* У<><D0A3>λ<EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_L; /* У<><D0A3>λ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
|
|
|
|
}SL_Mppt_Scan_Broadcast_pack;
|
|
|
|
|
#define SL_MPPT_SCAN_BROADCAST_PACK_SIZE (sizeof(SL_Mppt_Scan_Broadcast_pack))
|
|
|
|
|
|
|
|
|
|
/* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡F2<46><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>-><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD> */
|
|
|
|
|
typedef struct _SL_Mppt_RegistrationRequest_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t register_Length_H; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȸ߰<C8B8>λ */
|
|
|
|
|
uint8_t register_Length_L; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵͰ<C8B5>λ */
|
|
|
|
|
uint8_t registration_Status_H; /* ע<><D7A2>״̬<D7B4>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t registration_Status_L; /* ע<><D7A2>״̬<D7B4>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t access_Node_ID[7]; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ID */
|
|
|
|
|
uint8_t access_Node_Type_H; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>߰<CDB8>λ */
|
|
|
|
|
uint8_t access_Node_Type_L; /* <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>͵Ͱ<CDB5>λ */
|
|
|
|
|
uint8_t check_Bit_H; /* У<><D0A3>λ<EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_L; /* У<><D0A3>λ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
|
|
|
|
}SL_Mppt_RegistrationRequest_pack;
|
|
|
|
|
#define SL_MPPT_REGISTRATIONREQUEST_PACK_SIZE (sizeof(SL_Mppt_RegistrationRequest_pack))
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-15 09:22:55 +00:00
|
|
|
|
/* ע<><D7A2><EFBFBD>ظ<EFBFBD>֡F3<46><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD><EFBFBD>ڵ㣩 */
|
|
|
|
|
typedef struct _SL_Mppt_RegistrationReply_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t register_Length_H; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȸ߰<C8B8>λ */
|
|
|
|
|
uint8_t register_Length_L; /* <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵͰ<C8B5>λ */
|
|
|
|
|
uint8_t registration_Status_H; /* ע<><D7A2>״̬<D7B4>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t registration_Status_L; /* ע<><D7A2>״̬<D7B4>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_H; /* У<><D0A3>λ<EFBFBD>߰<EFBFBD>λ */
|
|
|
|
|
uint8_t check_Bit_L; /* У<><D0A3>λ<EFBFBD>Ͱ<EFBFBD>λ */
|
|
|
|
|
uint8_t end_Flag; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
|
|
|
|
}SL_Mppt_RegistrationReply_pack;
|
|
|
|
|
#define SL_MPPT_REGISTRATIONREPLY_PACK_SIZE (sizeof(SL_Mppt_RegistrationReply_pack))
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-15 09:22:55 +00:00
|
|
|
|
/* */
|
|
|
|
|
#define RECV_LENGTH 20
|
|
|
|
|
typedef struct _SL_Mppt_Recv_pack{
|
|
|
|
|
uint8_t start_Flag[2]; /* <20><>ʼ<EFBFBD><CABC>־ */
|
|
|
|
|
uint8_t address[7]; /* <20><>ַ */
|
|
|
|
|
uint8_t function_Code; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
uint8_t recv_Data[RECV_LENGTH]; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
}SL_Mppt_Recv_pack;
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-15 09:22:55 +00:00
|
|
|
|
/* <20>ָ<EFBFBD>Ĭ<EFBFBD>ϵĶ<CFB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
#pragma pack(pop)
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
2024-07-15 09:22:55 +00:00
|
|
|
|
extern SL_Mppt_Scan_Broadcast_pack g_Scan_Broadcast_pack;
|
2024-07-13 02:22:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SOFTWARE_PROTOCOL_COMMUNICATION_PROTOCOL_H_ */
|