#include "common_include.h"
uint8_t zhenduansendStep = 0;;
uint32_t R485_Send_0x40(void)
{
    memset(R485_ID40h.Msg, 0xFF, 64);
    uint32_t u32sendendflag = 0;
    // R485_ID40h.Sig.AlarmStatus = 0; // 报警器报警状态
    switch (HJ_OtherKeyCurrent.count)
    {
    case  0:
        break;
    case  1:
        break;
    case  2:
        break;
    case  3:
        break;
    case  4:
        break;
    case  5:
        break;
    case  6:
        break;
    case  7:
        break;  
    case  8:
        break;  
    case  9:
        
        break;
    default:
        break;
    }
    u32sendendflag = R485_Send(0x40, R485_ID40h.Msg, sizeof(R485_ID40h.Msg));
    return u32sendendflag;
}

uint32_t R485_Send_0x41(void)
{
                    /**************0.437*********** */
                /*wtemp *= 9177l;
                wtemp /= 100;
                wtemp *= 157;
                wtemp /= 1000;*/
    uint32_t u32sendendflag = 0;
    memset(R485_ID41h.Msg, 0xFF, 64);
    R485_ID41h.Sig.VehicleStatus = 0x2;
    R485_ID41h.Sig.MetricImperialSetting = 0;
    R485_ID41h.Sig.CartMode = 0;
    R485_ID41h.Sig.ReverseMode = 0;
    R485_ID41h.Sig.RecuperationStatusFeedback = 0;
    R485_ID41h.Sig.EngineSymbolIndicatior = 0;
    // R485_ID41h.Sig.AlarmStatus = 0; // 报警器报警状态
    R485_ID41h.Sig.IOTRealTime_Year = 0x1; //时间：年
    R485_ID41h.Sig.IOTRealTime_Month = 0x1; //时间：月
    R485_ID41h.Sig.IOTRealTime_Day = 0x1;   //时间：日
    switch (HJ_OtherKeyCurrent.count)
    {
    case 0:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航

        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30
        // R485_ID41h.Sig.TotalBatterySOC = 0x0; //电量
        // R485_ID41h.Sig.VehicleStatus = 0x0;   //整车状态
        // R485_ID41h.Sig.SpeedGear = 0x2;     //挡位
        
        

        R485_ID41h.Sig.IOTRealTime_Hour = 0;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒

        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  1:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航


        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30
        R485_ID41h.Sig.TotalBatterySOC = 0x2; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x2;     //挡位
        
        R485_ID41h.Sig.TotalBatteryVoltage = 0x4B;   //总电池电压

        R485_ID41h.Sig.IOTRealTime_Hour = 0;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒


        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  2:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航



    
        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x46;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30  11km
        R485_ID41h.Sig.TotalBatterySOC = 0x1E; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x3;     //挡位
        
        R485_ID41h.Sig.TotalBatteryVoltage = 0x4B;   //总电池电压

        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x1; // 自动大灯
        R485_ID41h.Sig.IOTRealTime_Hour = 0xB;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0xB;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒


        R485_ID41h.Sig.CartMode = 0;
        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  3:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x1; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航


        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x95;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 22km
        R485_ID41h.Sig.TotalBatterySOC = 0x2C; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        
        R485_ID41h.Sig.TotalBatteryVoltage = 0x4B;   //总电池电压

        R485_ID41h.Sig.IOTRealTime_Hour = 0x16;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x16;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒


        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  4:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航




        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0xE2;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 33km
        R485_ID41h.Sig.TotalBatterySOC = 0x42; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        

        R485_ID41h.Sig.IOTRealTime_Hour = 0xD;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x21;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x1;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x1;    //巡航


        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        
        break;
    case  5:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x0; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航

        R485_ID41h.Sig.RecuperationStatusFeedback = 0x1;    //能量回收设置
        R485_ID41h.Sig.TotalBatteryVoltage = 0xC8;   //总电池电压

        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x12F;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 44km
        R485_ID41h.Sig.TotalBatterySOC = 0x58; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        //功率暂空一会做
        R485_ID41h.Sig.IOTRealTime_Hour = 0xE;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x2C;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x1;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x0;   //座桶开关


        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        
        break;
    case  6:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航


        R485_ID41h.Sig.RecuperationStatusFeedback = 0x1;    //能量回收设置
        R485_ID41h.Sig.TotalBatteryVoltage = 0xC8;   //总电池电压

        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x17A;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 55km
        R485_ID41h.Sig.TotalBatterySOC = 0x6E; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        //功率暂空一会做

        R485_ID41h.Sig.IOTRealTime_Hour = 0xF;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x37;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒
        R485_ID41h.Sig.CushionSensorStatus = 0x0;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x1;    //陡坡缓降


        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  7:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航

        R485_ID41h.Sig.RecuperationStatusFeedback = 0x1;    //能量回收设置
        R485_ID41h.Sig.TotalBatteryVoltage = 0xC8;   //总电池电压


        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x1C4;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30  66km
        R485_ID41h.Sig.TotalBatterySOC = 0x84; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        //功率暂空一会做
        R485_ID41h.Sig.IOTRealTime_Hour = 0x10;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x6;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒
        R485_ID41h.Sig.SlopePattern = 0x1;   //跛行

        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    case  8:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航


        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x210;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30  77km
        R485_ID41h.Sig.TotalBatterySOC = 0x9A; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        //功率暂空一会做
        R485_ID41h.Sig.IOTRealTime_Hour = 0x11;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x7;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒

        R485_ID41h.Sig.HandlebarFaultIndicator = 0x1;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;

        break;  
    case  9:

        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航

        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x25F;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 88km
        R485_ID41h.Sig.TotalBatterySOC = 0xB0; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0x1;     //挡位
        //功率暂空一会做
        R485_ID41h.Sig.IOTRealTime_Hour = 0x12;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x8;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒
        R485_ID41h.Sig.ChargeState = 0x1;   //充电状态
        

        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;  
    case  10:
        R485_ID41h.Sig.ICMCalculatesVehicleSpeed = 0x300;   //速度 = (X * 0.512 * 3.14 * 1.05) / 30 88km
        R485_ID41h.Sig.TotalBatterySOC = 0xC6; //电量
        R485_ID41h.Sig.VehicleStatus = 0x3;   //整车状态
        R485_ID41h.Sig.SpeedGear = 0;     //挡位
        //功率暂空一会做
        R485_ID41h.Sig.IOTRealTime_Hour = 0x13;    //时间：时
        R485_ID41h.Sig.IOTRealTime_Minute = 0x9;  //时间：分
        R485_ID41h.Sig.IOTRealTime_Second = 0;  //时间：秒

        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x1; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x1;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x1;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x1;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x1;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x0;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x1;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x1;    //巡航

        R485_ID41h.Sig.HandlebarFaultIndicator = 1;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    default:
        R485_ID41h.Sig.EleHeadlightFunctionSettings = 0x0; // 自动大灯
        R485_ID41h.Sig.ChargeState = 0x0;   //充电状态
        R485_ID41h.Sig.SlopePattern = 0x0;   //跛行
        R485_ID41h.Sig.CushionSensorStatus = 0x1;   //坐垫压力
        R485_ID41h.Sig.SlopeDescentFunctionStatus = 0x0;    //陡坡缓降
        R485_ID41h.Sig.TCSActivation = 0x1; //TCS激活
        R485_ID41h.Sig.TCSFunctionalStatus = 0x0;   //TCS状态
        R485_ID41h.Sig.ElectronicCushionStatus = 0x1;   //座桶开关
        R485_ID41h.Sig.SupportSwitchSignalFeedback = 0x0;   //边撑
        R485_ID41h.Sig.CruiseMode = 0x0;    //巡航

        R485_ID41h.Sig.HandlebarFaultIndicator = 0;
        R485_ID41h.Sig.UUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.UDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.VUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.VDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.WUpBridgeArmMosFault = 0;
        R485_ID41h.Sig.WDownBridgeArmMosFault = 0;
        R485_ID41h.Sig.MCUFaultStateU_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateV_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStateW_PhaseHallFault = 0;
        R485_ID41h.Sig.MCUFaultStatus_HandlebarFault = 0;
        R485_ID41h.Sig.BMS_0CommunicationStatus = 0;
        R485_ID41h.Sig.MCUCommunicationStatus = 0;
        R485_ID41h.Sig.ALMCommunicationStatus = 0;
        R485_ID41h.Sig.ICMCommunicationStatus = 0;
        R485_ID41h.Sig.BrakeLeverFault = 0;
        R485_ID41h.Sig.PhaseLossFault = 0;
        R485_ID41h.Sig.MCUOverTempProtection = 0;
        R485_ID41h.Sig.MotorOvertempProtection = 0;
        R485_ID41h.Sig.RotorLocked = 0;
        break;
    }
    u32sendendflag = R485_Send(0x41, R485_ID41h.Msg, sizeof(R485_ID41h.Msg));
    return u32sendendflag;
}

uint32_t R485_Send_0x42(void)
{
    memset(R485_ID42h.Msg, 0xFF, 64);
    uint32_t u32sendendflag = 0;
    R485_ID42h.Sig.TPower = 0;        //T动力状态
    R485_ID42h.Sig.TotalBatteryCurrent = 0; 
        switch (HJ_OtherKeyCurrent.count)
    {
    case  0:
        
        break;
    case  1:
        R485_ID42h.Sig.TotalBatteryCurrent = 0x34;  //母线电流
        break;
    case  2:
        R485_ID42h.Sig.TotalBatteryCurrent = 0x96;  //母线电流
        break;
    case  3:
        R485_ID42h.Sig.TotalBatteryCurrent = 0xFA;  //母线电流
        break;
    case  4:
        
        R485_ID42h.Sig.SuperTPower = 0x0;   //超级T动力模式
        R485_ID42h.Sig.TPower = 0x1;        //T动力状态
        break;
    case  5:
        R485_ID42h.Sig.TotalBatteryCurrent = 0x31;
        break;
    case  6:
        R485_ID42h.Sig.TotalBatteryCurrent = 0x2F;
        break;
    case  7:
        R485_ID42h.Sig.TotalBatteryCurrent = 0x1;
        break;  
    case  8:
        break;  
    case  9:
        
        break;
    default:
        break;
    }
    u32sendendflag = R485_Send(0x42, R485_ID42h.Msg, sizeof(R485_ID42h.Msg));
    return u32sendendflag;
}
uint8_t R485_zhenduan_Msg[64];
uint32_t R485_Send_0x47(void)
{
    uint8_t length;
    uint32_t u32sendendflag = 0;
    if(RS485_TX_finish == 0)
    {
        if(RS485_send_time > 3000)
        {
        Port_SetPortPinLevel(1, 4, PortGpioHigh);
        Delay(10);
        switch (zhenduansendStep)
        {
        case  0:
            length = 2;
            break;
        case 1:
            length = 2;
        break;
        case 2:
            length = 6;
            break;
        case 3:
            length = 37;
            break;
        case 5:
            break;
        case 6:
            length = 3;
            break;
        default:
            break;
        }
        
        switch (zhenduansendStep)
        {
        case  0:
            // R485_zhenduan_Msg[0] = 0x2;
            R485_zhenduan_Msg[0] = 0x10;
            R485_zhenduan_Msg[1] = 0x03;
            break;
        case 1:
            // R485_zhenduan_Msg[0] = 0x2;
            R485_zhenduan_Msg[0] = 0x27;
            R485_zhenduan_Msg[1] = 0x1;
        break;
        case 2:
            // R485_zhenduan_Msg[0] = 0x6;
            R485_zhenduan_Msg[0] = 0x27;
            R485_zhenduan_Msg[1] = 0x2;
            R485_zhenduan_Msg[2] = key_array[0];
            R485_zhenduan_Msg[3] = key_array[1];
            R485_zhenduan_Msg[4] = key_array[2];
            R485_zhenduan_Msg[5] = key_array[3];
            break;
        case 3:
            R485_zhenduan_Msg[0] = 0x2E;
            R485_zhenduan_Msg[1] = 0x50;
            R485_zhenduan_Msg[2] = 0x0;
            memcpy(R485_zhenduan_Msg+3,barcode_Msg,34);
            break;
        case 4:
            // zhenduanflag = 0;
            // Port_SetPinConfig(1, 19, &stc_OUT_pin_config); // VBAT~
            // Port_SetPinConfig(1, 20, &stc_OUT_pin_config); // VBAT
            // Port_SetPinConfig(1, 21, &stc_OUT_pin_config); //DC12V
            // Port_SetPinConfig(1, 15, &stc_OUT_pin_config); // ACC1

            Port_SetPortPinLevel(1, 19, PortGpioLow);
            Port_SetPortPinLevel(1, 20, PortGpioLow);
            Port_SetPortPinLevel(1, 21, PortGpioLow);
            Port_SetPortPinLevel(1, 15, PortGpioLow);
            g_Stage = 1;
            // zhenduansendStep = 0;
            // zhenduanflag = 0;
            break;
        default:
            break;
        }
        RS485_TX_finish = 1;
        u32sendendflag = R485_Send(0x47, R485_zhenduan_Msg, length);
        RS485_send_time = 0;
        Delay(10);
        Port_SetPortPinLevel(1, 4, PortGpioLow);
        Delay(10);
        RS485_TX_finish = 1;
    }
    }
    RS485_TX_finish = 1;
    Port_SetPortPinLevel(1, 4, PortGpioLow);
    return u32sendendflag;
}
uint8_t Send_Lineget_Msg[64];
uint32_t R485_Send_Line_0x47(uint8_t n)
{
    uint8_t num = n;
    uint8_t length;
    uint32_t u32sendendflag = 0;
    if(RS485_TX_finish == 0)
    {
        if(RS485_send_time > 3000)
        {
        Port_SetPortPinLevel(1, 4, PortGpioHigh);
        Delay(10);
        switch (n)
        {
            case 0:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x0;
                break;
            case 1:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x01;
                break;
            case 2:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x02;
                break;
            case 3:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x03;
                break;
            case 4:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x04;
                break;
            case 5:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x05;
                break;
            case 6:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x06;
                break;
            case 7:
                Send_Lineget_Msg[0] = 0x22;
                Send_Lineget_Msg[1] = 0xF2;
                Send_Lineget_Msg[2] = 0x07;
                break;
            default:
            break;
                
        }
        RS485_TX_finish = 1;
        u32sendendflag = R485_Send(0x47, Send_Lineget_Msg, 3);
        RS485_send_time = 0;
        Delay(10);
        Port_SetPortPinLevel(1, 4, PortGpioLow);
        Delay(10);
        RS485_TX_finish = 1;
    }
    }
    RS485_TX_finish = 1;
    Port_SetPortPinLevel(1, 4, PortGpioLow);
    return u32sendendflag;
}

