#include "includes.h"


uint8_t BLVP2_Rotary_SwitchCycleDis(uint32_t DevAdd);  
uint8_t BLVP2_Rs485_Rotary_Swi_Check(uint32_t DevAdd ,uint32_t Data_addr, uint16_t DataLen); 

#define ROTARYSENDTIMEMAX			0x03  	//本设备重发次数上限

#define Dev_RotarySwitch_RecvData_Len_Max	0x18

/*******************************************************************************
* Function Name  : BLVP2_485_Dev_Rotary_Switch_Init 
* Description    : BLVP2旋钮开关初始化函数
* Return         : NULL
*******************************************************************************/
void BLVP2_485_Dev_Rotary_Switch_Init(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
{
	BUS_Public->polling_cf = (uint32_t)&BLVP2_Rotary_SwitchCycleDis;
	BUS_Public->processing_cf = (uint32_t)&BLVP2_Rs485_Rotary_Swi_Check;
	
	DevActionGlobal.DimGlobalValue = 100;
//    DevActionGlobal.CCTValue = 50;
	Rs485SwiInfo->RotaryBL = 0x01;
	
	Rs485SwiInfo->Rotary_PageEn = 0x09;      //默认启用亮度调节和空气质量页面
	
//	Rs485SwiInfo->RL_Lower_limit = DevActionGlobal.Dim_Lower_limit;
//	Rs485SwiInfo->RL_Upper_limit = DevActionGlobal.Dim_Upper_limit;
	
	Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"增加BLVP2旋钮开关 地址: %d",BUS_Public->addr);										
	
}



/*******************************************************************************
* Function Name  : BLVP2_Rotary_Rs485_Swi_Pro 
* Description    : BLVP2旋钮开关485接收处理函数
* Return         : NULL
*******************************************************************************/
void BLVP2_Rotary_Rs485_Swi_Pro(Device_Public_Information_G* BUS_Public, uint8_t *data, RS485_SWI_INFO  *Switch_Info)
{
	uint8_t i;
	uint16 temp  = 0x00;

	if(Switch_Info->DevOffline == DEV_IS_OFFLINE)
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"%s Device_Online",__func__);
		LOG_Device_Online_Record(DEV_SWI_TYPE,BUS_Public->addr,LogInfo_Device_Online);	//记录设备在线
	}
	
	BLV_Communication_Record(&Switch_Info->comm_record,0x02,0x01);		//记录通讯成功
	Switch_Info->DevSendCnt = 0x00;             		//收到回复就清计数
	Switch_Info->DevOffline = DEV_IS_ONLINE;    		//设备在线
	if(Switch_Info->DevOffline != Switch_Info->DevOfflineLast)	//当前在线状态不等于上一次在线状态
	{
		Switch_Info->DevOfflineLast = Switch_Info->DevOffline;	//更新上一次在线状态
		Write_Device_Fault_State(BUS_Public->type,BUS_Public->addr,In_ErrFun_LineState,DEV_IS_ONLINE);	//保存设备在线状态到SRAM
	}

	
	Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"BLV P2 Rotary switch Input Num:%02X\r\n", Switch_Info->SwtInputValidNum);
	switch(data[1])   
	{
		case 0x09:      
			if(data[2] == 0x05)
			{
				if(data[3] == 0x01)     //亮度调节
				{
					i = data[2] - 1;
					Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"switch%d Dev%02X KeyRotary Coord:%d",BUS_Public->addr, i, BUS_Public->DevCoord);
					Switch_Info->DevReadBuf[i] = RotaryLight;          //地址从1开始
					DevActionGlobal.Devi = BUS_Public->DevCoord;     //直接跳到指定的下标去处理
					if(data[4] == 0x02) //绝对调节
					{
						temp = data[5] + (data[6] << 8);
						if((temp >= DevActionGlobal.Dim_Lower_limit) && (temp <=DevActionGlobal.Dim_Upper_limit))     //2024-11-01   全局亮度限制输入
						{
							Switch_Info->RotaryValue[data[3] - 1] = temp;
							DevActionGlobal.DimGlobalValue = Switch_Info->RotaryValue[data[3] - 1];//1-1=0
						}
					}
				}
				else if(data[3] == 0x04)    //色温调节
				{
					i = data[2] - 1;
					Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"switch%d Dev%02X KeyRotary Coord:%d",BUS_Public->addr, i, BUS_Public->DevCoord);
					Switch_Info->DevReadBuf[i] = RotaryCCT;          //地址从1开始
					DevActionGlobal.Devi = BUS_Public->DevCoord;     //直接跳到指定的下标去处理
					if(data[4] == 0x02) //绝对调节
					{
						temp = data[5] + (data[6] << 8);
//						if(temp > 0)
						{
							Switch_Info->RotaryValue[data[3] - 1] = temp;
							DevActionGlobal.CCTValue = Switch_Info->RotaryValue[data[3] - 1];//4-1=3
						}
					}
				}
			}
			break;
		default:
			break;
	}
}


#define RECDATALENMAX   10   //接收数据最大长度

/*******************************************************************************
* Function Name  : BLVP2_Rs485_Rotary_Swi_Check 
* Description    : BLVP2旋钮开关485接收处理函数
* Return         : 
	0x01：数据处理失败
	0x00：数据处理成功
*******************************************************************************/
uint8_t BLVP2_Rs485_Rotary_Swi_Check(uint32_t DevAdd ,uint32_t Data_addr, uint16_t DataLen) 
{
//	uint8_t Crc_buf = 0;
	uint8_t ret = 0x01;
	uint8_t data[RECDATALENMAX];	
//	uint32_t SwiDevAdd;    //开关
	Device_Public_Information_G BUS_Public;   //共用	
	RS485_SWI_INFO Rs485SwiInfo;       //开关局部变量
	
	if(DataLen > RECDATALENMAX)
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"%s DataLen Err:%d",__func__,DataLen);
		return ret;     //长度
	}
	
	SRAM_DMA_Read_Buff(data,DataLen,Data_addr);   //拷贝482数据
	
	if((data[1] != 0x09) && (data[1] != 0x0A) && (data[1] != 0x0B) && (data[1] != 0x0C))
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"%s Check Err");
		return ret;    //不是就直接返回
	}
		
	
	if((DataLen < 0x05)||(data[DataLen - 1] != SOR_CRC(data, DataLen-1)))   //匹配开关地址数据  
	{
		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"不是旋钮开关的数据，DevAdd:%d,len:%d\r\n",BUS_Public.addr,DataLen);
		return ret;    //不是就直接返回
	}
	
//	if(data[0] == SRAM_Read_Byte(DevAdd+Dev_Addr))   //地址刚好匹配上BUS_Public.addr
//	{
//		Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"旋钮开关地址匹配上 DevAdd:%d,len:%d\r\n",data[0],DataLen);
//		SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),DevAdd);		
//	}
//	else       //地址没有匹配上
	{
		DevAdd = Find_AllDevice_List_Information2(Active_Port, 0x25, data[0]);   //地址重新赋值
		if(NULL != DevAdd)
		{
			SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),DevAdd);		
		}
		else
		{
			return ret;
		}
	}
	 

	SRAM_DMA_Read_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),DevAdd+Dev_Privately);
	
	Dbg_Print_Buff(DBG_BIT_DEVICE_STATUS_bit,"Rotary Input Buff:",data,DataLen);
	
	switch(data[1])
	{
		case 0x09:
			ret = 0x00;
			BLVP2_Rotary_Rs485_Swi_Pro(&BUS_Public, data, &Rs485SwiInfo);
			break;
		case 0x0A:

            if(data[3] == 0x01)
            {
                ret = 0x00;
                Rs485SwiInfo.DevSendCnt = 0x00;  
                Rs485SwiInfo.RotaryValue_Flag = 0x00;
            }else if(data[3] == 0x04)
            {
                ret = 0x00;
                Rs485SwiInfo.DevSendCnt = 0x00;  
                Rs485SwiInfo.RotaryCCTValue_Flag = 0x00;//2025-07-10，YYW,旋钮色温设置的回复
            }
			break;
		case 0x0B:
			ret = 0x00;
			Rs485SwiInfo.DevSendCnt = 0x00;
		    Rs485SwiInfo.RL_Limit_Flag = 0x00;
			break;
		case 0x0C:
			ret = 0x00;
			Rs485SwiInfo.DevSendCnt = 0x00;
			Rs485SwiInfo.RotaryBL_Flag = 0x00;
			break;
		case 0x0D:
			ret = 0x00;
			Rs485SwiInfo.DevSendCnt = 0x00;
			Rs485SwiInfo.Rotary_PageFlag = 0x00;
			break;
	}
	
	/*日志记录*/
	LOG_Device_COMM_Control_Reply_Record(BUS_Public.port,BUS_Public.baud,data,DataLen);
	
	BUS_Public.check = 0x00;
	BUS_Public.check = DoubleData_CheckSum((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G), (uint8_t *)&Rs485SwiInfo, sizeof(RS485_SWI_INFO));
	SRAM_DMA_Write_Buff((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G),DevAdd);/*将数据保存*/
	SRAM_DMA_Write_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),DevAdd+Dev_Privately);
		
	return ret;
}



void BLVP2_Rotary_Switch_Ctrl(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
{
	uint8_t SendLen = 0x07;							
	uint8_t BLW_swt_buf[SendLen]; 
	
	memset(BLW_swt_buf,0,sizeof(BLW_swt_buf));

	BLW_swt_buf[0] = BUS_Public->addr;
	BLW_swt_buf[1] = 0x0A;   //写
	BLW_swt_buf[2] = 0x05;   //回路
	BLW_swt_buf[3] = 0x01;   //亮度调节
	BLW_swt_buf[4] = DevActionGlobal.DimGlobalValue & 0xff;
	BLW_swt_buf[5] = (DevActionGlobal.DimGlobalValue >> 8) & 0xff;   //全局亮度
	

	BLW_swt_buf[SendLen-1] = SOR_CRC(BLW_swt_buf,SendLen-1);
	/*发送函数*/
	//Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"Rotary switch send data---\r\n");
	MCU485_SendString(BUS_Public->port,BLW_swt_buf,SendLen);
	
	
	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,BLW_swt_buf,SendLen);

}

//旋钮调光设备，色温设置下发,2025-07-10,YYW
void BLVP2_Rotary_CCTValue_Ctrl(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
{
	uint8_t SendLen = 0x07;							
	uint8_t BLW_swt_buf[SendLen]; 
	
	memset(BLW_swt_buf,0,sizeof(BLW_swt_buf));

	BLW_swt_buf[0] = BUS_Public->addr;
	BLW_swt_buf[1] = 0x0A;   //写
	BLW_swt_buf[2] = 0x05;   //回路
	BLW_swt_buf[3] = 0x04;   //色温调节
	BLW_swt_buf[4] = DevActionGlobal.CCTValue & 0xff;
	BLW_swt_buf[5] = (DevActionGlobal.CCTValue >> 8) & 0xff;   //全局亮度
	

	BLW_swt_buf[SendLen-1] = SOR_CRC(BLW_swt_buf,SendLen-1);
	/*发送函数*/
	//Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"Rotary CCTValue send data---\r\n");
	MCU485_SendString(BUS_Public->port,BLW_swt_buf,SendLen);
	
	
	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,BLW_swt_buf,SendLen);

}



void BLVP2_Rotary_BL_Ctrl(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
{
	uint8_t SendLen = 0x07;							
	uint8_t data[SendLen]; 
	
	memset(data,0,sizeof(data));

	data[0] = BUS_Public->addr;
	data[1] = 0x0C;   //背光状态设置
	data[2] = 0x05;   //回路
	data[3] = 0x01;   //亮度调节
	
	if(Rs485SwiInfo->RotaryBL == 0x01)
	{
		data[4] = 0x02;   //氛围灯
		data[5] = 0x64;   //屏幕亮度
	}
	else
	{
		data[4] = 0x02;   //氛围灯
		data[5] = 0x00;   //屏幕亮度
	}
	
	data[SendLen-1] = SOR_CRC(data,SendLen-1);
	/*发送函数*/
	//Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"Rotary BL send data---\r\n");
	MCU485_SendString(BUS_Public->port,data,SendLen);
	
	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,data,SendLen);

}

//void BLVP2_Rotary_LightLimit_Ctrl(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
//{
//	uint8_t SendLen = 0x08;							
//	uint8_t data[SendLen]; 
//	
//	memset(data,0,sizeof(data));

//	data[0] = BUS_Public->addr;
//	data[1] = 0x0B;   //范围设置
//	data[2] = 0x01;   //亮度调节
//	data[3] = Rs485SwiInfo->RL_Lower_limit;
//	data[4] = 0x00;   

//	data[5] = Rs485SwiInfo->RL_Upper_limit;
//	data[6] = 0x00;   //屏幕亮度
//	
//	data[SendLen-1] = SOR_CRC(data,SendLen-1);
//	/*发送函数*/
//	Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"Rotary_LightLimit send data---\r\n");
//	MCU485_SendString(BUS_Public->port,data,SendLen);
//	
//	/*日志记录*/
//	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,data,SendLen);

//}



void BLVP2_Rotary_PageEn_Ctrl(Device_Public_Information_G *BUS_Public, RS485_SWI_INFO *Rs485SwiInfo)
{
	uint8_t SendLen = 0x07;							
	uint8_t data[SendLen]; 
	
	memset(data,0,sizeof(data));

	data[0] = BUS_Public->addr;
	data[1] = 0x0D;   //页面启用
	
	data[2] = Rs485SwiInfo->Rotary_PageEn & 0xff;   
	data[3] = (Rs485SwiInfo->Rotary_PageEn >> 8) & 0xff;   
	data[4] = (Rs485SwiInfo->Rotary_PageEn >> 16) & 0xff;      
	data[5] = (Rs485SwiInfo->Rotary_PageEn >> 24) & 0xff;   
	
	data[SendLen-1] = SOR_CRC(data,SendLen-1);
	/*发送函数*/
	Dbg_Print_Buff(DBG_BIT_DEVICE_STATUS_bit,"BLVP2_Rotary_PageEn_Ctrl:",data,SendLen);
	MCU485_SendString(BUS_Public->port,data,SendLen);
	
	/*日志记录*/
	LOG_Device_COMM_Send_Control_Record(BUS_Public->port,BUS_Public->baud,data,SendLen);

}


/*******************************************************************************
* Function Name  : BLVP2_Rotary_SwitchCycleDis 
* Description    : BLVP2旋钮开关485数据发送处理函数，包括重发

* Return         : 
	0x01：有数据需要发送
	0x00：没有数据需要发送
*******************************************************************************/
uint8_t BLVP2_Rotary_SwitchCycleDis(uint32_t DevAdd)  
{
	Device_Public_Information_G BUS_Public;
	RS485_SWI_INFO Rs485SwiInfo;       //开关局部变量

//	uint8_t i;
	uint8_t Ret = RS485OCCUPYNOTIME;
	
	SRAM_DMA_Read_Buff((uint8_t *)&BUS_Public,sizeof(Device_Public_Information_G),DevAdd);			
	SRAM_DMA_Read_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),DevAdd+Dev_Privately);/*拷贝设备私有信息*/
	
	
	if(DevActionGlobal.DevActionU64Cond.EleState == 0x01)
	{
		if( DevActionGlobal.SleepMode_State == 0x01 )
		{
			Rs485SwiInfo.RotaryBL = 0x02;   //睡眠模式关背光
		}
		else
		{
			Rs485SwiInfo.RotaryBL = 0x01;   //插卡开背光
		}
	}
	else if(DevActionGlobal.DevActionU64Cond.EleState == 0x02)
	{
		Rs485SwiInfo.RotaryBL = 0x02;       //拔卡关背光
	}
	else
	{
		if( DevActionGlobal.SleepMode_State == 0x01 )
		{
			Rs485SwiInfo.RotaryBL = 0x02;  //睡眠模式关背光
		}
		else
		{
			Rs485SwiInfo.RotaryBL = 0x01;
		} 
	}
	
	
    //2025-07-10，YYW,比对保存的旋钮亮度上报值和当前主机的全局亮度
	if(Rs485SwiInfo.RotaryValue[0] != DevActionGlobal.DimGlobalValue)
	{
		Rs485SwiInfo.RotaryValue[0] = DevActionGlobal.DimGlobalValue;
		Rs485SwiInfo.RotaryValue_Flag = 0x01;
	}

    //2025-07-10，YYW,比对保存的旋钮色温上报值和当前主机的全局色温
	if(Rs485SwiInfo.RotaryValue[3] != DevActionGlobal.CCTValue)
	{
		Rs485SwiInfo.RotaryValue[3] = DevActionGlobal.CCTValue;
		Rs485SwiInfo.RotaryCCTValue_Flag = 0x01;
	}	
    
    
	if(Rs485SwiInfo.RotaryBL != Rs485SwiInfo.RotaryBL_Last)
	{
		Rs485SwiInfo.RotaryBL_Last = Rs485SwiInfo.RotaryBL;
		Rs485SwiInfo.RotaryBL_Flag = 0x01;
	}
	
//	if(Rs485SwiInfo.RL_Upper_limit != DevActionGlobal.Dim_Upper_limit)
//	{
//		Rs485SwiInfo.RL_Upper_limit = DevActionGlobal.Dim_Upper_limit;
//	}
//	
//	if(Rs485SwiInfo.RL_Lower_limit != DevActionGlobal.Dim_Lower_limit)
//	{
//		Rs485SwiInfo.RL_Lower_limit = DevActionGlobal.Dim_Lower_limit;
//	}
	
//	if(Rs485SwiInfo.RL_Upper_limit != Rs485SwiInfo.RL_Upper_limit_Last)
//	{
//		Rs485SwiInfo.RL_Upper_limit_Last = Rs485SwiInfo.RL_Upper_limit;
//		Rs485SwiInfo.RL_Limit_Flag = 0x01;
//	}
//	
//	if(Rs485SwiInfo.RL_Lower_limit != Rs485SwiInfo.RL_Lower_limit_Last)
//	{
//		Rs485SwiInfo.RL_Lower_limit_Last = Rs485SwiInfo.RL_Lower_limit;
//		Rs485SwiInfo.RL_Limit_Flag = 0x01;
//	}


	if(Rs485SwiInfo.Rotary_PageEn != Rs485SwiInfo.Rotary_PageEnLast)
	{
		Rs485SwiInfo.Rotary_PageEnLast = Rs485SwiInfo.Rotary_PageEn;
		Rs485SwiInfo.Rotary_PageFlag = 0x01;
	}
	
	

	if(0x01 == Rs485SwiInfo.RotaryValue_Flag)
	{
		BLVP2_Rotary_Switch_Ctrl(&BUS_Public, &Rs485SwiInfo);
		Ret = RS485OCCUPYTIME;
	}
	else if(0x01 == Rs485SwiInfo.RotaryBL_Flag)
	{
		BLVP2_Rotary_BL_Ctrl(&BUS_Public, &Rs485SwiInfo);
		Ret = RS485OCCUPYTIME;
	}
    else if(Rs485SwiInfo.RotaryCCTValue_Flag == 0x01)   //2025-07-10，YYW,比对保存的旋钮色温上报值和当前主机的全局色温
    {
        BLVP2_Rotary_CCTValue_Ctrl(&BUS_Public, &Rs485SwiInfo);
        Ret = RS485OCCUPYTIME;
    }
//	else if(0x01 == Rs485SwiInfo.RL_Limit_Flag)
//	{
//		BLVP2_Rotary_LightLimit_Ctrl(&BUS_Public, &Rs485SwiInfo);
//		Ret = RS485OCCUPYTIME;
//	}
	else if(Rs485SwiInfo.Rotary_PageFlag == 0x01)
	{
		BLVP2_Rotary_PageEn_Ctrl(&BUS_Public, &Rs485SwiInfo);
		Ret = RS485OCCUPYTIME;
	}
	
	
	if(Ret == RS485OCCUPYTIME)
	{
		if(Rs485SwiInfo.DevSendCnt > ROTARYSENDTIMEMAX)
		{
			if(Rs485SwiInfo.DevOffline != DEV_IS_OFFLINE)
			{
				Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"%s Device_Offline",__func__);
				LOG_Device_Online_Record(Dev_Rs458_RotaryCtrl, BUS_Public.addr,LogInfo_Device_Offline);	//记录设备离线
			}

			Rs485SwiInfo.DevOffline = DEV_IS_OFFLINE;   //判为离线
			if(Rs485SwiInfo.DevOffline != Rs485SwiInfo.DevOfflineLast)	//当前在线状态不等于上一次在线状态
			{
				Rs485SwiInfo.DevOfflineLast = Rs485SwiInfo.DevOffline;	//更新上一次在线状态
				Write_Device_Fault_State(BUS_Public.type,BUS_Public.addr,In_ErrFun_LineState,DEV_IS_OFFLINE);	//保存设备在线状态到SRAM
			}
			
			if(0x01 == Rs485SwiInfo.RotaryValue_Flag)
			{
				Rs485SwiInfo.RotaryValue_Flag = 0x00;
			}
			else if(0x01 == Rs485SwiInfo.RotaryBL_Flag)
			{
				Rs485SwiInfo.RotaryBL_Flag = 0x00;
			}
			else if(0x01 == Rs485SwiInfo.RL_Limit_Flag)
			{
				Rs485SwiInfo.RL_Limit_Flag = 0x00;
			}
			else if(Rs485SwiInfo.Rotary_PageFlag == 0x01)
			{
				Rs485SwiInfo.Rotary_PageFlag = 0x00;
			}else if(Rs485SwiInfo.RotaryCCTValue_Flag == 0x01)
            {
                Rs485SwiInfo.RotaryCCTValue_Flag = 0x00;
            }
			
			Rs485SwiInfo.DevSendCnt = 0x00;
		}
		else
		{
			Rs485SwiInfo.DevSendCnt++;   //发送次数累计
		}
		
		/*通讯统计记录*/
		BLV_Communication_Record(&Rs485SwiInfo.comm_record,0x01,0x00);
		
		BUS_Public.check = 0x00;
		BUS_Public.check = DoubleData_CheckSum((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G), (uint8_t *)&Rs485SwiInfo, sizeof(RS485_SWI_INFO));
		SRAM_DMA_Write_Buff((uint8_t *)&BUS_Public, sizeof(Device_Public_Information_G),DevAdd);/*将数据保存*/
		SRAM_DMA_Write_Buff((uint8_t *)&Rs485SwiInfo,sizeof(RS485_SWI_INFO),DevAdd+Dev_Privately);
	}
	
	return Ret;
}

