Files
chrg/apps/chrg/applications/utils/chrg_sink.c
T
2025-11-18 00:40:02 +08:00

43 lines
1.1 KiB
C

/****************************************************************************
文件名称 : chrg_sink.c
完成日期 :
当前版本号 : V1.0
主要功能 : 北向数据sink请求数据填充及发送。
版本历史 : 创建原始版本
说明 :
******************************************************************************/
#include <rtthread.h>
#include "chrg_sink.h"
#include "chrg_north.h"
#include "chrg_north_pkg.h"
#include "chrg_utils.h"
/*****************************************************************
函数名称: sink_get_vc
函数描述: sink电压电流查询请求
输入参数: vol:电压 cur:电流
输出参数: -
返回说明: <0: 错误 >0:发送长度
其它说明: -
*****************************************************************/
int sink_get_vc (rt_uint16_t vol, rt_uint16_t cur)
{
rt_uint16_t len = 0;
rt_uint8_t data[12] = {0};
rt_uint8_t frame[16] = {0};
u16_to_u8v(vol, &data[0]);
u16_to_u8v(cur, &data[2]);
data[4] = 0x00;
data[5] = 0x00;
chrg_north_pkg_encode(ID_SINK, SINK_CMD_GET_VOLTAGE, data, 6, frame, &len);
return chrg_north_send(frame, len);
}