/**
  ******************************************************************************
  * @file    BLV_485_Dev_LEDFun.c
  * @author  BLW RCU  development Team
  * @version SongHan
  * @date    2021年12月08日
  * @brief  
	*    RGB调光  跟普通调光方法方式一样
	* @log  202205121137 SongHan  增加长按循环调光 停止调光 读取调光亮度
	* @log  202205261640 SongHan  增加调光回路限制
  ******************************************************************************
  */

#include "BLV_485_Dev_RGB_Light_BeltFun.h"
#include "SPI_SRAM.h"
#include "check_fun.h"
#include "string.h"
#include "usart.h"
#include "DBG.h"
#include "CH57x_common.h"
#include "rw_logging.h"
#include "SRAM_Variable_Address.h"

#include "includes.h"

#define RGB_OUT_CH_MAX  0x04   //RGB调光有4路
#define RGB_Light_Belt_REPEATSENDTIMEMAX			0x03  	//本设备重发次数上限

#define BLWRGBGRADUALTIME         30   //30  即300ms

void BLW_RGB_Control_State(uint32_t CfgDevAddIn, uint16_t DevInputAddr,uint32_t devaddr, uint16_t loop,uint16_t start);
void BLW_RGB_Light_Way_Ctrl(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info); 
void BLV_RGB_Light_Belt_Light_Inquire_Datasend(Device_Public_Information_G *BUS_Public, RS485_LED_INFO *Dev_Info);

uint8_t BLV_RGB_Light_Belt_Cycle_Call(uint32_t DevAdd);  
uint8_t BLV_RGB_Light_Belt_Data_Processing(uint32_t dev_addr,uint32_t data_addr,uint16_t len);
void BLV_RGB_Light_Belt_Light_Control_Datasend(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info);
void BLW_RGB_GlobalValue_Set(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Rs485LEDInfo);   //全局亮度设置

#define Dev_RGBLight_RecvData_Len_Max	0x18

/*******************************************************************************
* Function Name  : BLV_485_Dev_RGB_Light_Belt_Init 
* Description    : RGB灯带设备信息初始化函数
*******************************************************************************/
//void BLV_485_Dev_RGB_Light_Belt_Init(uint8_t devaddr)
//{
//	Device_Public_Information_G BUS_Public;
//	RS485_LED_INFO Light_belt_info;

//	memset(&BUS_Public,0,sizeof(Device_Public_Information_G));
//	memset(&Light_belt_info,0,sizeof(RS485_LED_INFO));
//	
//	
//	BUS_Public.addr = devaddr;						//设备地址
//	BUS_Public.type = DEV_RGB_LIGHT_BELT_Type;			//设备类型
//	BUS_Public.port = Polling_Port;						//设备发送端口
//	BUS_Public.baud = 9600;					//设备发送波特率
//	BUS_Public.retry_num = RGB_Light_Belt_REPEATSENDTIMEMAX;		//设备数据重发次数
//	BUS_Public.wait_time = 0x64;		//设备数据发送等待回复时间 - 100ms
//	BUS_Public.polling_cf = (uint32_t)&BLV_RGB_Light_Belt_Cycle_Call;  
//	BUS_Public.processing_cf = (uint32_t)&BLV_RGB_Light_Belt_Data_Processing;
//	
//	BUS_Public.DevFunInfo.Dev_Output_Ctrl = BLW_RGB_Control_State;
//	BUS_Public.DevFunInfo.Dev_Output_Loop_State_Get = Get_BLV_RGB_Light_Loop_Value; 
//	
//	Light_belt_info.LEDLoopValidNum = RGB_LIGHT_BELT_CH_MAX;
//	
//	Add_POLL_Device_To_List2(&BUS_Public,(uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO));
//}
/*******************************************************************************
* Function Name  : BLW_RS485_LED_Data_Init 
* Description    : 添加设备到链表 - 轮询设备
* Input          : 
	type	: 添加的设备类型
	addr	: 添加的设备地址
	polling_cf		：设备的轮询数据发送回调函数
	processing_cf	：设备的数据处理回调函数
* Return         : None
*******************************************************************************/
void BLW_RS485_RGB_Data_Init(Device_Public_Information_G *BUS_Public, RS485_LED_INFO *Rs485LED, uint16_t LoopNum)
{

	BUS_Public->polling_cf = (uint32_t)&BLV_RGB_Light_Belt_Cycle_Call;
	BUS_Public->processing_cf = (uint32_t)&BLV_RGB_Light_Belt_Data_Processing;
	
	if(LoopNum >= RGB_OUT_CH_MAX)   //输出回路超过范围
	{
		Rs485LED->LEDLoopValidNum = RGB_OUT_CH_MAX;
	}
	else if(0x00 == LoopNum)
	{
		Rs485LED->LEDLoopValidNum = 0x01;
	}
	else              //未超过范围
	{
		Rs485LED->LEDLoopValidNum = LoopNum;
	}
	
	Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"添加RGB设备，回路:%d", Rs485LED->LEDLoopValidNum);
	
}


/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_CycleDis 
* Description    : RGB灯带485数据发送处理函数，包括重发

* Return         : 
	0x01：有数据需要发送
	0x00：没有数据需要发送
*******************************************************************************/
uint8_t BLV_RGB_Light_Belt_Cycle_Call(uint32_t DevAdd)  
{
	Device_Public_Information_G BUS_Public;
	RS485_LED_INFO Light_belt_info;       //灯带局部变量
	uint8_t Ret = RS485OCCUPYNOTIME;
//	uint8_t val_check = 0;
	uint8_t i;          //用于遍历所有回路
	
	/*拷贝设备私有信息*/
	SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),DevAdd);	//拷贝所有共有数据
	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),DevAdd+Dev_Privately);
	
	for(i = 0; i < Light_belt_info.LEDLoopValidNum; i++)
	{
		if(Light_belt_info.DevSendBuf_last[i] != Light_belt_info.DevSendBuf[i])
		{
			Light_belt_info.LEDCtrlFlag = 0x01;
			Light_belt_info.LEDCtrlCnt = RGB_Light_Belt_REPEATSENDTIMEMAX;
//			Light_belt_info.LEDUpFlag = 0x01;
//			Light_belt_info.DevReadBuf[i] = 0x01;         //状态变化置一
			memcpy(Light_belt_info.DevSendBuf_last, Light_belt_info.DevSendBuf, Light_belt_info.LEDLoopValidNum);   //同步这组数据

			break;
		}
	}
		
	for(i = 0; i < Light_belt_info.LEDLoopValidNum; i++)
	{
		if(Light_belt_info.DevCtrlWayBuf_last[i] != Light_belt_info.DevCtrlWayBuf[i])  //Light_belt_info.DevCtrlWayBuf_last[i] 
		{
			Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"灯带方式控制置位，下标:%d 状态:%04X 上一个状态:%04X\r\n", i, Light_belt_info.DevCtrlWayBuf[i], Light_belt_info.DevCtrlWayBuf_last[i]);  //
			Light_belt_info.DevCtrlWayBuf_last[i] = Light_belt_info.DevCtrlWayBuf[i];//方式控制，只能一路一路控制
			Light_belt_info.LEDWayCtrlFlag = 0x01;
			Light_belt_info.LEDWayCtrlCnt = RGB_Light_Belt_REPEATSENDTIMEMAX;
//			Light_belt_info.DevCtrlWayBuf[i] = 0x00;  
			Light_belt_info.WayCtrli = i;
//			memcpy(Light_belt_info.DevCtrlWayBuf_last, Light_belt_info.DevCtrlWayBuf, Light_belt_info.LEDLoopValidNum);   //同步这组数据
			break;
		} 
	}	
	
//	if(0x00 != Light_belt_info.light_Control_Flag)
//	{
	if(Light_belt_info.Dim_Global_Value_Last != Light_belt_info.Dim_Global_Value)     //全局亮度
	{
		Light_belt_info.Dim_Global_Value_Last = Light_belt_info.Dim_Global_Value;
		Light_belt_info.Dim_GV_Flag |= (0x01<<7);
	}
	
	
	if((Light_belt_info.LEDUpLightLimitLast != Light_belt_info.LEDUpLightLimit) || (Light_belt_info.LEDDownLightLimitLast != Light_belt_info.LEDDownLightLimit))         //可调上限
	{	
		Light_belt_info.LEDUpLightLimitLast = Light_belt_info.LEDUpLightLimit;
		Light_belt_info.Dim_GV_Flag |= (0x01<<6);
		
		Light_belt_info.LEDDownLightLimitLast = Light_belt_info.LEDDownLightLimit;
		Light_belt_info.Dim_GV_Flag |= (0x01<<5);
	}
	
//	if(Light_belt_info.LEDDownLightLimitLast != Light_belt_info.LEDDownLightLimit)    //可调下限
//	{
//		Light_belt_info.LEDDownLightLimitLast = Light_belt_info.LEDDownLightLimit;
//		Light_belt_info.Dim_GV_Flag |= (0x01<<5);
//	}
	

	
	if(0x00 != Light_belt_info.Dim_GV_Flag)                               //2024-1-30
	{
		BLW_RGB_GlobalValue_Set(&BUS_Public, &Light_belt_info);           //全局亮度设置
		Ret = RS485OCCUPYTIME;
	}
	else if(0x01 == Light_belt_info.LEDCtrlFlag)
	{
		if(0x00 != Light_belt_info.LEDCtrlCnt)
		{
			Light_belt_info.LEDCtrlCnt--; 
		}
		else
		{
			Light_belt_info.LEDCtrlFlag = 0x00;
		}
		BLV_RGB_Light_Belt_Light_Control_Datasend(&BUS_Public, &Light_belt_info);           //4路控制，状态控制
		Ret = RS485OCCUPYTIME;
	}	
	else if(0x01 == Light_belt_info.LEDWayCtrlFlag)
	{
		if(0x00 != Light_belt_info.LEDWayCtrlCnt)
		{
			Light_belt_info.LEDWayCtrlCnt--; 
		}
		else
		{
			Light_belt_info.LEDWayCtrlFlag = 0x00;
		}
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"灯带方式控制发送，下标:%d",Light_belt_info.WayCtrli);  //
		BLW_RGB_Light_Way_Ctrl(&BUS_Public, &Light_belt_info);  
//		BLW_Rs485_LED_4LOOP_Way_Ctrl(CfgDevAdd, Light_belt_info.WayCtrli);	 //方式控制
		Ret = RS485OCCUPYTIME;		
	}
	else if(0x01 == Light_belt_info.LEDLightnessReadFlag)
	{
		if(0x00 != Light_belt_info.LEDLightnessReadCnt)
		{
			Light_belt_info.LEDLightnessReadCnt--; 
		}
		else
		{
			Light_belt_info.LEDLightnessReadFlag = 0x00;
		}
		BLV_RGB_Light_Belt_Light_Inquire_Datasend(&BUS_Public, &Light_belt_info);
//		BLW_Rs485_LED_4LOOP_Read(CfgDevAdd);           //4路调光亮度读取
		Ret = RS485OCCUPYTIME;
	}	
//	else if(Light_belt_info.loop_dimming_Control_Flag != 0x00)  //循环调光
//	{
//		Ret = RS485OCCUPYTIME;
//		BLV_RGB_Light_Belt_loop_dimming_Control_Datasend(DevAdd, &Light_belt_info);
//	}
//	else if(Light_belt_info.stop_dimming_Control_Flag != 0x00)  //停止动作
//	{
//		Ret = RS485OCCUPYTIME;
//		BLV_RGB_Light_Belt_stop_dimming_Control_Datasend(DevAdd, &Light_belt_info);
//	}
	

//	else 
//	{
//		if(Light_belt_info.loop_dimming_flg == 1)    //当前未处于循环调光状态，才查询亮度
//		{
//			return 0;
//		}
//		BLV_RGB_Light_Belt_Light_Inquire_Datasend(DevAdd, &Light_belt_info);
//	}
	


	if(RS485OCCUPYTIME == Ret)
	{	
		if(Light_belt_info.DevSendCnt > RGB_Light_Belt_REPEATSENDTIMEMAX)
		{
			if(Light_belt_info.DevOffline != DEV_IS_OFFLINE)
			{
				Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"DEV_RGB_LIGHT_BELT_Type LogInfo_Device_Offline...........");
				LOG_Device_Online_Record(DEV_RGB_LIGHT_BELT_Type,SRAM_Read_Byte(DevAdd+Dev_Addr),LogInfo_Device_Offline);	//记录设备离线
			}
			Light_belt_info.DevOffline = DEV_IS_OFFLINE;		//判为离线
			if(Light_belt_info.DevOffline != Light_belt_info.DevOfflineLast)	//当前在线状态不等于上一次在线状态
			{
				Light_belt_info.DevOfflineLast = Light_belt_info.DevOffline;	//更新上一次在线状态
				Write_Device_Fault_State(BUS_Public.type,BUS_Public.addr,In_ErrFun_LineState,DEV_IS_OFFLINE);	//保存设备在线状态到SRAM
			}
			
			if(0x00 != Light_belt_info.Dim_GV_Flag)
			{
				Light_belt_info.Dim_GV_Flag = 0x00;
			}
		}else {
			Light_belt_info.DevSendCnt++;   				//发送次数累计
		}
			/*通讯统计记录*/
		Light_belt_info.inquire_tick = SysTick_1ms;
		BLV_Communication_Record(&Light_belt_info.comm_record,0x01,0x00);
		
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"灯带数据保存");  //
		
		BUS_Public.check = 0x00;
		BUS_Public.check = DoubleData_CheckSum((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G), (uint8_t *)&Light_belt_info, sizeof(RS485_LED_INFO));
		SRAM_DMA_Write_Buff((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G),DevAdd);/*将数据保存*/
		SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),DevAdd+Dev_Privately);
						
//		SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),DevAdd+Dev_Privately);
//		/*计算校验值*/
//		SRAM_Write_Byte(0x00,DevAdd+Dev_Check);
//		val_check = Dev_CheckSum(DevAdd, sizeof(RS485_LED_INFO) + Dev_Privately);
//		SRAM_Write_Byte(val_check,DevAdd+Dev_Check);		//校验值重新写入
	}
	
	return Ret;
}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Light_Control_Datasend 
* Description    : RGB灯带 设定亮度数据打包发送函数
*******************************************************************************/
void BLV_RGB_Light_Belt_Light_Control_Datasend(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info)
{
//	uint8_t temp = 0;
	uint8_t send_buff[20];
	memset(send_buff,0,20);

//	memcpy(&send_buff[11], Dev_Info->light, 4);
	
//	for(uint8_t i = 0; i < RGB_LIGHT_BELT_CH_MAX; i++)
//	{
//		if((Dev_Info->light_Control_Flag & (1<<i)))
//		{
//			send_buff[11+i] = Dev_Info->set_light[i];
//		}
//	}
//	
//	Dev_Info->last_light_Control_Flag = Dev_Info->light_Control_Flag;
	
	memcpy(&send_buff[11], &Dev_Info->DevSendBuf[0], Dev_Info->LEDLoopValidNum);  //指示灯控制
	
	send_buff[0] = 0xA6;
	send_buff[1] = RGB_LIGHT_BELT_SET_LIGHT_CMD;
	send_buff[3] = 11;
	send_buff[4] = 0;   //tx
	send_buff[5] = BUS_Public->addr;//SRAM_Read_Byte(dev_addr+Dev_Addr);;   //rx
	send_buff[6] = RGB_LIGHT_BELT_CONTROL_MODE_SET;   //设置亮度
//	send_buff[7] = BLWRGBGRADUALTIME;         //渐变时间
//	send_buff[8] = BLWRGBGRADUALTIME>>8;
    Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB灯带调光渐变时间:%d",Dev_Info->RGB_Set_Time);
	send_buff[7] = Dev_Info->RGB_Set_Time;         //渐变时间
	send_buff[8] = Dev_Info->RGB_Set_Time>>8;
	send_buff[9] = 0;
	send_buff[10] = 4;     //控制4个回路
	send_buff[2] = CheckSum_Overlook_Check(send_buff, 15, 2);
	
//	temp = SRAM_Read_Byte(dev_addr+Dev_port);
	MCU485_SendString(BUS_Public->port, send_buff, 15);
	
	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,send_buff,15);
}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_loop_dimming_Control_Datasend 
* Description    : RGB灯带 循环调光数据打包发送函数
*******************************************************************************/
//void BLV_RGB_Light_Belt_loop_dimming_Control_Datasend(uint32_t dev_addr, RS485_LED_INFO *Dev_Info)
//{
//	uint8_t temp = 0;
//	uint8_t send_buff[20];
//	memset(send_buff,0,20);

////	send_buff[7] = SRAM_Read_Byte(dev_addr+Dev_Addr);
////	send_buff[8] = (Dev_Info->loop_dimming_Control_Flag & 0x0F);
//	
//	send_buff[7] = Dev_Info->loop_dimming_control;
//	send_buff[8] = 0x00;
//	
//	Dev_Info->last_loop_dimming_Control_Flag = Dev_Info->loop_dimming_Control_Flag;
//	
//	
//	send_buff[0] = 0xA6;
//	send_buff[1] = RGB_LIGHT_BELT_SET_ACT_CMD;
//	send_buff[3] = 10;
//	send_buff[4] = 0;   //tx
//	send_buff[5] = SRAM_Read_Byte(dev_addr+Dev_Addr);   //rx
//	send_buff[6] = Dev_Info->SN;   //设置亮度
//	
//	send_buff[9] = RGB_LIGHT_BELT_LOOP_DIMMING_CMD;    //动作命令
//	send_buff[10] = RGB_LIGHT_BELT_CONTROL_MODE_LOOP;     //循环调光
//	send_buff[11] = Dev_Info->loop_fade_time;         //渐变时间
//	send_buff[12] = Dev_Info->loop_fade_time>>8;
//	send_buff[13] = Dev_Info->loop_light;          //设定循环调光亮度增量
//	send_buff[2] = CheckSum_Overlook_Check(send_buff, 14, 2);
//	
//	temp = SRAM_Read_Byte(dev_addr+Dev_port);
//	MCU485_SendString(temp, send_buff, 14);
//	
//	/*日志记录*/
//	LOG_Device_COMM_Send_Control_Record2(dev_addr+Dev_port,dev_addr+Dev_baud,send_buff,14);
//}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_stop_dimming_Control_Datasend 
* Description    : RGB灯带 停止循环调光数据打包发送函数
*******************************************************************************/
//void BLV_RGB_Light_Belt_stop_dimming_Control_Datasend(uint32_t dev_addr, RS485_LED_INFO *Dev_Info)
//{
//	uint8_t temp = 0;
//	uint8_t send_buff[10];
//	memset(send_buff,0,10);
//	
//	Dev_Info->last_stop_dimming_Control_Flag = Dev_Info->stop_dimming_Control_Flag;
//	
//	send_buff[0] = 0xA6;
//	send_buff[1] = RGB_LIGHT_BELT_STOP_DIMMING_CMD;
//	send_buff[3] = 2;
//	send_buff[4] = 0;   //tx
//	send_buff[5] = SRAM_Read_Byte(dev_addr+Dev_Addr);   //rx
//	
//	send_buff[2] = CheckSum_Overlook_Check(send_buff, 6, 2);
//	
//	temp = SRAM_Read_Byte(dev_addr+Dev_port);
//	MCU485_SendString(temp, send_buff, 6);
//	
//	/*日志记录*/
//	LOG_Device_COMM_Send_Control_Record2(dev_addr+Dev_port,dev_addr+Dev_baud,send_buff,6);
//}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Light_Inquire_Datasend 
* Description    : RGB灯带 Inching数据打包发送函数
*******************************************************************************/
void BLV_RGB_Light_Belt_Light_Inquire_Datasend(Device_Public_Information_G *BUS_Public, RS485_LED_INFO *Dev_Info)
{
//	uint8_t temp = 0;

	uint8_t send_buff[10];
	memset(send_buff,0,10);
	
	send_buff[0] = 0xA6;
	send_buff[1] = RGB_LIGHT_BELT_READ_LIGHT_CMD;
	send_buff[3] = 4;
	send_buff[4] = 0;   //tx
	send_buff[5] = BUS_Public->addr;//SRAM_Read_Byte(dev_addr+Dev_Addr);;   //rx
	send_buff[6] = 0;   				//索引
	send_buff[7] = 4;         //查询数量
	send_buff[2] = CheckSum_Overlook_Check(send_buff, 8, 2);
	
//	temp = SRAM_Read_Byte(dev_addr+Dev_port);
	MCU485_SendString(BUS_Public->port, send_buff, 8);
}

/*向上循环调光*/
void BLW_Rs485_Strip_Way_Ctrl_CycleUp(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info)
{
//  RS485_STRIP_INFOP Rs485StripInfo;             //调光局部变量
//	static uint8_t WayCtrlSn = 0x00;
		                   //头    命令  校验  长度        地址  计数  编号      自动LED 向上  时间  比例  上限  下限
//	uint8_t SendBuf[15] = {0xA6, 0x44, 0x02, 0x0B, 0x00, 0x00, 0x6F, 0x14, 0x00, 0x15,   0x01, 0x01, 0x0A, 0x64, 0x00}; 
	
		                   //头    命令  校验  长度        地址  计数  编号     自动LED    循环     时间      比例
	uint8_t SendBuf[14] = {0xA6, 0x44, 0x02, 0x0A, 0x00, 0x00, 0x6F, 0x14, 0x00, 0x13,   0x03, 0x20, 0x00 , 0x00}; 	
//	Rs485StripInfo = CfgDevAdd->DevDataStruct;

	SendBuf[5] = BUS_Public->addr;
	SendBuf[6] = BLV_SN_Get(&Dev_Info->LEDSn, 0, 255);

  SendBuf[7] = Dev_Info->WayCtrli;   //StripLoop;     //回路
	switch(Dev_Info->DevCtrlWayBuf[Dev_Info->WayCtrli])
	{
		case CFG_Dev_CtrlWay_Is_Dim_CycleUp:  //向上循环
		case CFG_Dev_CtrlWay_Is_Dim_CycleDown:
			SendBuf[10] = 0x03;									//填入控制方式
			break;
		case CFG_Dev_CtrlWay_Is_Dim_Up:       //调光亮度增加一点
			SendBuf[10] = 0x01;
			break;
		case CFG_Dev_CtrlWay_Is_Dim_Down:	    //调光亮度减少一点
			SendBuf[10] = 0x02;
			break;
	}
	if((0x00 == Dev_Info->DevCtrlWayContect[Dev_Info->WayCtrli]) || (Dev_Info->DevCtrlWayContect[Dev_Info->WayCtrli] > 0x64))
	{
		SendBuf[11] = 0x00;
	}
	else
	{
		SendBuf[11] = 100/Dev_Info->DevCtrlWayContect[Dev_Info->WayCtrli];
	}
//  SendBuf[13] = Rs485StripInfo->DevCtrlWayContect[StripLoop];   //填入比例  测试发现比例没用
	
	SendBuf[2] = CheckSum_Overlook_Check(SendBuf, 14, 2);	//
	MCU485_SendString(BUS_Public->port,SendBuf,14);

	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,SendBuf,14);
}


/*停止调光*/
void BLW_Rs485_Strip_Way_Ctrl_Stop(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info)
{
	uint8_t SendBuf[6] = {0xA6, 0x46, 0x11, 0x02, 0x00, 0x00};
	
	SendBuf[5] = BUS_Public->addr; 
		
	SendBuf[2] = CheckSum_Overlook_Check(SendBuf, 6, 2); //BLW_SOR_Negate(SendBuf, 6, 2);	
	MCU485_SendString(BUS_Public->port,SendBuf, 6); //

	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,SendBuf, 6); //
}


/**
	* @name BLW 24路 集中调光控制函数
	* @para
	*   CfgDevAdd     设备节点 
  *   StripLoop       回路地址   0~23
	* @return         无
  * @attention      发送循环里调用，变量已经被判断
	*/
void BLW_RGB_Light_Way_Ctrl(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Dev_Info)
{
	
	switch(Dev_Info->DevCtrlWayBuf[Dev_Info->WayCtrli])
	{
		case CFG_Dev_CtrlWay_Is_Dim_CycleUp:  //向上循环
		case CFG_Dev_CtrlWay_Is_Dim_CycleDown:
		case CFG_Dev_CtrlWay_Is_Dim_Up:
		case CFG_Dev_CtrlWay_Is_Dim_Down:			
			BLW_Rs485_Strip_Way_Ctrl_CycleUp(BUS_Public, Dev_Info);
			break;
		case CFG_Dev_CtrlWay_Is_Dim_Stop:    //停止
			BLW_Rs485_Strip_Way_Ctrl_Stop(BUS_Public, Dev_Info);
			break;
	}				
}	


#define IsMyData     0x00
#define IsNotMyData  0x01
/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Data_Processing 
* Description    : 灯带数据处理函数
* Input          : 
	dev_addr	: 设备信息地址
	data_addr	: 数据地址
	len			：数据长度
* Return         : 
	0x00：处理成功
	0x01：处理失败
*******************************************************************************/
uint8_t BLV_RGB_Light_Belt_Data_Processing(uint32_t dev_addr,uint32_t data_addr,uint16_t len)
{
//	uint8_t crc_val = 0;temp = 0,
	uint16_t temp1 = 0;
//	uint8_t temp_dev_addr = 0;
	Device_Public_Information_G BUS_Public;
	uint8_t data[Dev_RGBLight_RecvData_Len_Max];
	uint8_t rev = IsNotMyData;
	
	RS485_LED_INFO Light_belt_info;       //灯带局部变量
	
	if(len > Dev_RGBLight_RecvData_Len_Max)
	{
//		Dbg_Print(DBG_BIT_DEVICE_STATUS_bit,"PWM接收数据长度超出范围!!\r\n");
		return rev;     //长度
	}
	
	SRAM_DMA_Read_Buff(data,len,data_addr);   //拷贝485数据
	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);	
	SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),dev_addr);				
	
	if(data[0] != 0x6A)    //头不对
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Head Fail!");
		return rev;
	}
	if(CheckSum(data,len) != 0x00) 
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Check Fail!");
		return rev;	//和校验
	}
	
	
//	temp_dev_addr = SRAM_Read_Byte(dev_addr+ Dev_Addr);
	if(data[4] != BUS_Public.addr)	
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt PKT_ADD_FM Fail!");
		return 0x01;						//发送地址不对
	}
	
	if(data[5] != 0x00)	
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt PKT_ADD_TO Fail!");
		return 0x01;						//接收地址不对
	}

	if(data[3] != (len-4))		
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt PKT_LEN Fail!");
		return 0x01;						//长度不对
	}	
	
	switch(data[1])
	{
		
		case RGB_LIGHT_BELT_READ_LIGHT_REPLY:         //读亮度回复
			if(data[6] == 0xE0)   //无错误
			{   
				memcpy(Light_belt_info.LEDLightRelease, &data[7], Light_belt_info.LEDLoopValidNum);//松开保存亮度
				memcpy(Light_belt_info.DevSendBuf, &data[7], Light_belt_info.LEDLoopValidNum);
				Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt 读取到亮度:%d", Light_belt_info.DevSendBuf[0]);
				Light_belt_info.LEDLightnessReadFlag = 0x00;   
//				if(memcmp(&deal_buff[7], Light_belt_info.light, 4) != 0)   //亮度改变
//				{
//					memcpy(Light_belt_info.light, &deal_buff[7], 4);     //拷贝亮度
//					temp1++;
//					
//					/*查询回来的状态,有改变 - 记录日志*/
					LOG_Device_COMM_ASK_TO_Reply_Record(BUS_Public.port,BUS_Public.baud,(SysTick_1ms - Light_belt_info.inquire_tick),data,len);
//				}
			}
			else Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Fail：%02X", SRAM_Read_Byte(data_addr + 6));
			
			break;
		case RGB_LIGHT_BELT_SET_LIGHT_REPLY:            //设置亮度回复
			
			if(SRAM_Read_Byte(data_addr + 6) == 0xE0)   //无错误
			{
				Light_belt_info.LEDCtrlFlag = 0x00;
//				Light_belt_info.loop_dimming_flg = 0;    //循环调光标记清零
//				Light_belt_info.light_Control_Flag &= ~(Light_belt_info.last_light_Control_Flag);
			}
			else Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Fail：%02X", SRAM_Read_Byte(data_addr + 6));
			
			LOG_Device_COMM_Control_Reply_Record(BUS_Public.port,BUS_Public.baud,data,len);
			break;
		case RGB_LIGHT_BELT_SET_ACT_REPLY:     //循环调光动作命令回复
			if(SRAM_Read_Byte(data_addr + 6) == 0xE0)   //无错误
			{
				Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Receive CycleDim Cmd! Clear WayCtrlFlag");
				Light_belt_info.LEDWayCtrlFlag = 0x00;

				temp1++;
			}
			else Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Fail：%02X", SRAM_Read_Byte(data_addr + 6));
			
			LOG_Device_COMM_Control_Reply_Record(BUS_Public.port,BUS_Public.baud,data,len);
			break;
		case RGB_LIGHT_BELT_STOP_DIMMING_REPLY:     //停止动作命令回复
			if(SRAM_Read_Byte(data_addr + 6) == 0xE0)   //无错误
			{
				Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Receive StopDim Cmd! Clear WayCtrlFlag");
				Light_belt_info.LEDWayCtrlFlag = 0x00;

				temp1++;
			}
			else Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB_Light_Belt Fail：%02X", SRAM_Read_Byte(data_addr + 6));
			
			LOG_Device_COMM_Control_Reply_Record(BUS_Public.port,BUS_Public.baud,data,len);
			break;
		case 0xAA:
			Light_belt_info.Dim_GV_Flag = 0x00;
			break;
		default: return 0x01;
	}
	
	if(Light_belt_info.DevOffline == DEV_IS_OFFLINE)
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"%s Device_Online........",__func__);
		LOG_Device_Online_Record(DEV_RGB_LIGHT_BELT_Type,BUS_Public.addr,LogInfo_Device_Online);	//记录设备在线
	}
	BLV_Communication_Record(&Light_belt_info.comm_record,0x02,0x01);		//记录通讯成功
	Light_belt_info.DevSendCnt = 0x00;
	Light_belt_info.DevOffline = DEV_IS_ONLINE;    //设备在线
	if(Light_belt_info.DevOffline != Light_belt_info.DevOfflineLast)	//当前在线状态不等于上一次在线状态
	{
		Light_belt_info.DevOfflineLast = Light_belt_info.DevOffline;	//更新上一次在线状态
		Write_Device_Fault_State(BUS_Public.type,BUS_Public.addr,In_ErrFun_LineState,DEV_IS_ONLINE);	//保存设备在线状态到SRAM
	}
	BUS_Public.check = 0x00;
	BUS_Public.check = DoubleData_CheckSum((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G), (uint8_t *)&Light_belt_info, sizeof(RS485_LED_INFO));
	SRAM_DMA_Write_Buff((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G),dev_addr);/*将数据保存*/
	SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
					
	/*数据解析完毕,保存SRAM中*/     
//	SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	/*计算校验值*/
//	SRAM_Write_Byte(0x00,dev_addr+Dev_Check);
//	temp = sizeof(RS485_LED_INFO) + Dev_Privately;
//	crc_val = Dev_CheckSum(dev_addr,temp);
//	SRAM_Write_Byte(crc_val,dev_addr+Dev_Check);		//校验值重新写入
	
	return 0x00;
}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Control_Light 
* Description    : 灯带 控制亮度
* Input          : 
	dev_addr	:设备地址
Control_Flag		:控制回路 bit0~3: ch1~ch4
	chx		: 回路亮度
	fadeTime：渐变
*******************************************************************************/
//void BLW_RGB_Control_State(uint32_t CfgDevAddIn, uint16_t DevInputAddr,uint32_t devaddr, uint16_t loop,uint16_t start)
//{
////	uint16_t temp = 0;
//	uint8_t temp1 = 0; //crc_val = 0,
//	uint8_t CtrlMode;   //控制模式
//	uint8_t CtrlContect;
//	Device_Public_Information_G BUS_Public;
//	
//	if(devaddr == 0x00)	return;
//	
//	RS485_LED_INFO Light_belt_info;       //灯带局部变量

//	SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),devaddr);				
//	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),devaddr+Dev_Privately);
//	
//	if(loop >= RGB_LIGHT_BELT_CH_MAX)    //有效回路
//	{
//		return ;
//	}
//	CtrlMode = start&0x00ff;    //控制模式
//	CtrlContect = start>>8;     //控制内容
//	
//	switch(CtrlMode)
//	{
//		case CFG_Dev_CtrlWay_Is_Dim_Stop:
//		case CFG_Dev_CtrlWay_Is_Dim_Up:
//		case CFG_Dev_CtrlWay_Is_Dim_Down:
//			Light_belt_info.LEDLightnessReadFlag = 0x01;    //唯有停止，向上向下，才会发送读取命令
//			Light_belt_info.LEDLightnessReadCnt = RGB_Light_Belt_REPEATSENDTIMEMAX;
//			Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"灯带调光读取置位，触发模式:%d\r\n", CtrlMode);  //
//			temp1++;
//			break;
//	}
//	switch(CtrlMode)
//	{
//		case CFG_Dev_CtrlWay_Is_Dim_CycleUp:   //方式控制
//		case CFG_Dev_CtrlWay_Is_Dim_CycleDown:
//		case CFG_Dev_CtrlWay_Is_Dim_Stop:
//			Light_belt_info.DevCtrlWayBuf[loop] = CtrlMode;  // - CFG_Dev_CtrlWay_Is_PWM_START + 1
//			Light_belt_info.DevCtrlWayContect[loop] = CtrlContect;  //保存控制内容
//			temp1++;
//			break;
//		case CFG_Dev_CtrlWay_Is_Open:         //状态控制
//		case CFG_Dev_CtrlWay_Is_Close:
//				Light_belt_info.DevSendBuf[loop] = CtrlContect; //亮度赋值

////			Light_belt_info.light_Control_Flag |= 1<<loop;
////			Light_belt_info.LEDCtrlCnt = RGB_Light_Belt_REPEATSENDTIMEMAX;

////			Light_belt_info.set_light[loop] = CtrlContect; //亮度赋值
//			temp1++;
//			break;
//		case CFG_Dev_CtrlWay_Is_Dim_Open:   //记忆开
//			if(0x00 != Light_belt_info.LEDLightRelease[loop])  //如果存在保存的值
//			{
//				CtrlContect = Light_belt_info.LEDLightRelease[loop];   //改   开
//			}
//			else if(0x00 != CtrlContect)   //如果不存在
//			{
//				CtrlContect = CtrlContect;   //以配置为准
//			}
//			else 
//			{
//				CtrlContect = 0x64;      //默认最亮
//			}
//			Light_belt_info.DevSendBuf[loop] = CtrlContect; //亮度赋值
//			temp1++;
//			break;
//		case CFG_Dev_CtrlWay_Is_Dim_Up:         //向上调光
//			Light_belt_info.light_Control_Flag |= 1<<loop;
//			if(Light_belt_info.DevSendBuf[loop] + CtrlContect <= 100)
//			{
//				Light_belt_info.DevSendBuf[loop] += CtrlContect;
//			}
//			else
//			{
//				Light_belt_info.DevSendBuf[loop] = 100;     //如果超过100即是最亮
//			}
//			temp1++;
//			break;
//		case CFG_Dev_CtrlWay_Is_Dim_Down:       //向下调光
//			Light_belt_info.light_Control_Flag |= 1<<loop;
//			if(Light_belt_info.DevSendBuf[loop]  >= CtrlContect)
//			{
//				Light_belt_info.DevSendBuf[loop] -= CtrlContect;
//			}
//			else
//			{
//				Light_belt_info.DevSendBuf[loop] = 0;     //如果减不够，即是0
//			}
//			temp1++;
//			break;
//		case CFG_Dev_CtrlWay_Is_Dim_Up_Limit:         //向上调光
//			if(0x00 != Light_belt_info.DevSendBuf[loop])
//			{
//				Light_belt_info.light_Control_Flag |= 1<<loop;
//				if(Light_belt_info.DevSendBuf[loop] + CtrlContect <= 100)
//				{
//					Light_belt_info.DevSendBuf[loop] += CtrlContect;
//				}
//				else
//				{
//					Light_belt_info.DevSendBuf[loop] = 100;     //如果超过100即是最亮
//				}
//				temp1++;
//			}
//			break;
//		case CFG_Dev_CtrlWay_Is_Dim_Down_Limit:       //向下调光
//			Light_belt_info.light_Control_Flag |= 1<<loop;
//			if(Light_belt_info.DevSendBuf[loop]  > CtrlContect)
//			{
//				Light_belt_info.DevSendBuf[loop] -= CtrlContect;
//				temp1++;
//			}
//			
//			break;
//	}	
//	Light_belt_info.fade_time = DEV_Dimming_Time;  


//	
//	if(temp1 != 0x00)
//	{
//		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"RGB DevSendBuf loop:%d,start:%04X\r\n",loop,start);
//		
//		BUS_Public.check = 0x00;
//		BUS_Public.check = DoubleData_CheckSum((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G), (uint8_t *)&Light_belt_info, sizeof(RS485_LED_INFO));
//		SRAM_DMA_Write_Buff((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G),devaddr);/*将数据保存*/
//		SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),devaddr+Dev_Privately);
//				
//	}	
//}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Control_Light 
* Description    : 灯带 控制亮度
* Input          : 
	dev_addr	:设备地址
Control_Flag		:控制回路 bit0~3: ch1~ch4
	chx		: 回路亮度
	fadeTime：渐变
*******************************************************************************/
//void BLV_RGB_Light_Belt_Control_Light(uint32_t dev_addr, uint8_t Control_Flag, uint8_t ch1, uint8_t ch2, uint8_t ch3, uint8_t ch4, uint16_t fadeTime)
//{
//	uint8_t crc_val = 0;
//	uint16_t temp = 0;
//	RS485_LED_INFO Light_belt_info;       //灯带局部变量
//	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	
//	for(uint8_t i=0; i< RGB_LIGHT_BELT_CH_MAX; i++)
//	{
//		if(Control_Flag & (1<<i))
//		{
//			Light_belt_info.light_Control_Flag |= 1<<i;
//			switch(i)
//			{
//				case 0:
//					Light_belt_info.set_light[i] = ch1;
//				break;
//				case 1:
//					Light_belt_info.set_light[i] = ch2;
//				break;
//				case 2:
//					Light_belt_info.set_light[i] = ch3;
//				break;
//				case 3:
//					Light_belt_info.set_light[i] = ch4;
//				break;
//				default: break;
//			}
//			
//		}
//	}
//	Light_belt_info.fade_time = fadeTime;  
//	
//	SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	/*计算校验值*/
//	SRAM_Write_Byte(0x00,dev_addr+Dev_Check);
//	temp = sizeof(RS485_LED_INFO) + Dev_Privately;
//	crc_val = Dev_CheckSum(dev_addr,temp);
//	SRAM_Write_Byte(crc_val,dev_addr+Dev_Check);		//校验值重新写入
//	
//}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Control_Loop_Dimming 
* Description    : 灯带 控制循环调光
* Input          : 
	dev_addr	     :设备地址
  Control_Flag	:控制回路 0~2
	light		      : 亮度增量
	fadeTime      ：渐变时间
*******************************************************************************/
//void BLV_RGB_Light_Belt_Control_Loop_Dimming(uint32_t dev_addr, uint8_t Control_CH, uint8_t light, uint16_t fadeTime)
//{
//	uint8_t crc_val = 0;
//	uint16_t temp = 0;
//	RS485_LED_INFO Light_belt_info;       //灯带局部变量
//	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	
////	for(uint8_t i=0; i< RGB_LIGHT_BELT_CH_MAX; i++)
////	{
////		if(Control_Flag & (1<<i))
////		{
////			Light_belt_info.loop_dimming_Control_Flag |= 1<<i;
////		}
////	}
//	
//	Light_belt_info.loop_dimming_Control_Flag = 0x01;
//	Light_belt_info.loop_dimming_control = Control_CH;
//	
//	
//	Light_belt_info.loop_fade_time = fadeTime;
//	Light_belt_info.loop_light = light;
//	Light_belt_info.SN++;
//	
//	SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	/*计算校验值*/
//	SRAM_Write_Byte(0x00,dev_addr+Dev_Check);
//	temp = sizeof(RS485_LED_INFO) + Dev_Privately;
//	crc_val = Dev_CheckSum(dev_addr,temp);
//	SRAM_Write_Byte(crc_val,dev_addr+Dev_Check);		//校验值重新写入
//	
//}

/*******************************************************************************
* Function Name  : BLV_RGB_Light_Belt_Control_Stop_Dimming 
* Description    : 灯带 停止循环调光
* Input          : 
	dev_addr	     :设备地址
*******************************************************************************/
//void BLV_RGB_Light_Belt_Control_Stop_Dimming(uint32_t dev_addr)
//{
//	uint8_t crc_val = 0;
//	uint16_t temp = 0;
//	RS485_LED_INFO Light_belt_info;       //灯带局部变量
//	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	
//	Light_belt_info.stop_dimming_Control_Flag = 1;
//	
//	SRAM_DMA_Write_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	/*计算校验值*/
//	SRAM_Write_Byte(0x00,dev_addr+Dev_Check);
//	temp = sizeof(RS485_LED_INFO) + Dev_Privately;
//	crc_val = Dev_CheckSum(dev_addr,temp);
//	SRAM_Write_Byte(crc_val,dev_addr+Dev_Check);		//校验值重新写入
//	
//}

/*******************************************************************************
* Function Name  : Get_BLV_RGB_Light_Loop_Value 
* Description    : 获取RGB灯光回路亮度
* Input          : 
	dev_addr	:设备地址
	ch			：灯光回路
*******************************************************************************/
//uint16_t Get_BLV_RGB_Light_Loop_Value(uint32_t dev_addr,uint16_t ch)  
//{
//	if(dev_addr == 0x00)	return 0;
//	RS485_LED_INFO Light_belt_info;       //灯带局部变量
//	SRAM_DMA_Read_Buff((uint8_t *)&Light_belt_info,sizeof(RS485_LED_INFO),dev_addr+Dev_Privately);
//	
//	if(ch < RGB_LIGHT_BELT_CH_MAX)
//	{
////		return Light_belt_info.light[ch];
////		Dbg_Print(DBG_BIT_DEVICE_STATUS_bit,"RGB回路:%d 亮度:%d! \r\n", ch, Light_belt_info.set_light[ch]);
//		
//		return Light_belt_info.DevSendBuf[ch];
//	}else {
//		return 0;
//	}
//}


//全局亮度设置
void BLW_RGB_GlobalValue_Set(Device_Public_Information_G *BUS_Public, RS485_LED_INFO* Rs485LEDInfo)
{
	uint8_t lens = 0x0B;
	uint8_t SendBuf[lens];
	memset(SendBuf,0,sizeof(SendBuf));
	
	SendBuf[0] = 0xA6;                                               //头	
	SendBuf[1] = 0x0A;                                               //CMD
	SendBuf[3] = lens;  
	SendBuf[4] = 0x00;                                               //Tx_Addr
	SendBuf[5] = BUS_Public->addr;                                   //Rx_Addr
	
	SendBuf[6] = Rs485LEDInfo->Dim_GV_Flag;
	SendBuf[7] = Rs485LEDInfo->Dim_Global_Value;                     //全局亮度
	SendBuf[8] = Rs485LEDInfo->LEDUpLightLimit;                      //可调上限
	SendBuf[9] = Rs485LEDInfo->LEDDownLightLimit;                   //可调下限
	SendBuf[10] = 0x00;                   
	
	SendBuf[2] = CheckSum_Overlook_Check(SendBuf, lens, 2); 
		
	MCU485_SendString(BUS_Public->port,SendBuf,lens);	

}
