|
@@ -214,6 +214,7 @@ static void process0AppTask(void* arg)
|
|
|
{
|
|
|
UINT8 Can_index = 0;
|
|
|
UINT8 Uart_index = 0;
|
|
|
+ UINT8 NB_index = 0;
|
|
|
uint32_t sleep_index = 0;
|
|
|
PROC_Task_STATE_SWITCH(PROCESS_STATE_IDLE);
|
|
|
NetSocDisplay(LED_SOC_0,LED_TURN_OFF);
|
|
@@ -262,6 +263,7 @@ static void process0AppTask(void* arg)
|
|
|
osDelay(10);//10ms
|
|
|
Can_index++;
|
|
|
Uart_index++;
|
|
|
+ NB_index++;
|
|
|
if (Uart_index >10)//Uart 100ms 调用一次
|
|
|
{
|
|
|
PROC_Uart_STATE_SWITCH(PROCESS_Uart_STATE_WORK);
|
|
@@ -270,9 +272,13 @@ static void process0AppTask(void* arg)
|
|
|
if (Can_index >=100)//Can 1000ms 调用一次
|
|
|
{
|
|
|
PROC_Can_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
- PROC_NB_STATE_SWITCH(PROCESS_NB_STATE_WORK);
|
|
|
Can_index = 0;
|
|
|
}
|
|
|
+ if (NB_index >=1000)//NB 10s 调用一次
|
|
|
+ {
|
|
|
+ PROC_NB_STATE_SWITCH(PROCESS_NB_STATE_CONNECT);
|
|
|
+ NB_index = 0;
|
|
|
+ }
|
|
|
if((Uart_Rece_BattI==0x0000)&&(Can_Rece_buffer[0]==0xff))
|
|
|
{
|
|
|
sleep_index++;
|
|
@@ -282,7 +288,7 @@ static void process0AppTask(void* arg)
|
|
|
sleep_index = 0;
|
|
|
}
|
|
|
|
|
|
- if (sleep_index >=60000)
|
|
|
+ if (sleep_index >=6000)
|
|
|
{
|
|
|
PROC_Task_STATE_SWITCH(PROCESS_STATE_SLEEP);
|
|
|
sleep_index = 0;
|
|
@@ -337,7 +343,7 @@ static void process1AppTask(void* arg)
|
|
|
case PROCESS_Uart_STATE_CHECK://检查电流数值
|
|
|
{
|
|
|
#ifdef USING_PRINTF
|
|
|
- printf("监测电流:%x\n ");
|
|
|
+ printf("Check_Current!\n ");
|
|
|
#endif
|
|
|
Uart_Receive_Msg.Reg_Begin_H = 0x00;
|
|
|
Uart_Receive_Msg.Reg_Begin_L= 0x02+Batt_Cell_Num;
|
|
@@ -363,8 +369,6 @@ static void process1AppTask(void* arg)
|
|
|
Uart_Receive_Msg.Reg_Num_L = 0x01;
|
|
|
Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg,Uart_Rece_buffer);
|
|
|
Uart_Rece_BattI = *(Uart_Reve_Point+0)<<8 |*(Uart_Reve_Point+1);
|
|
|
- battbuffer[17] = *(Uart_Reve_Point+0);
|
|
|
- battbuffer[18] = *(Uart_Reve_Point+1);
|
|
|
break;
|
|
|
}
|
|
|
case 1://读取单体电压
|
|
@@ -589,7 +593,7 @@ static void process2AppTask(void* arg)
|
|
|
// #endif
|
|
|
HAL_Can_Transmit(Can_TxMsg);
|
|
|
#ifdef USING_PRINTF
|
|
|
- printf("CAN发送:%x\n ",Can_ID);
|
|
|
+ printf("CANsend :%x\n ",Can_ID);
|
|
|
#endif
|
|
|
send_index ++;
|
|
|
break;
|
|
@@ -649,6 +653,21 @@ void Tcp_Data_Assemble(uint8_t datatype)
|
|
|
battbuffer[14] = 0x00;//故障等级
|
|
|
battbuffer[15] = 0x00;//故障代码高
|
|
|
battbuffer[16] = 0x00;//故障代码低
|
|
|
+ //电流适应性更改,从int转换到uint,加1000的偏移量,100mA的单位
|
|
|
+ if (Uart_Rece_BattI>0x8000)
|
|
|
+ {
|
|
|
+ Uart_Rece_BattI = Uart_Rece_BattI|0x7fff;
|
|
|
+ Uart_Rece_BattI = 0x2710 - Uart_Rece_BattI;
|
|
|
+ Uart_Rece_BattI = Uart_Rece_BattI/10;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Uart_Rece_BattI = Uart_Rece_BattI+0x2710;
|
|
|
+ Uart_Rece_BattI = Uart_Rece_BattI/10;
|
|
|
+ }
|
|
|
+
|
|
|
+ battbuffer[17] = Uart_Rece_BattI>>8;
|
|
|
+ battbuffer[18] = Uart_Rece_BattI;
|
|
|
|
|
|
data_index = 32+Batt_Cell_Num_2+Batt_Temp_Num;
|
|
|
battbuffer[data_index] = 0x00;//电池状态
|
|
@@ -720,20 +739,17 @@ static void process3AppTask(void* arg)
|
|
|
// #ifdef USING_PRINTF
|
|
|
// printf("[%d]Tcpchk:%#X \r\n",__LINE__,*(TcpSendBuffer+91));
|
|
|
// #endif
|
|
|
- // #ifdef USING_PRINTF
|
|
|
- // printf("TcpSend:");
|
|
|
- // for (int i = 0; i < NB_send_len; i++)
|
|
|
- // {
|
|
|
- // printf("%x ",*(TcpSendBuffer+i));
|
|
|
- // }
|
|
|
- // #endif
|
|
|
- // #ifdef USING_PRINTF
|
|
|
- // printf("\n ");
|
|
|
- // #endif
|
|
|
- TcpSendID = tcpipConnectionSend(TcpConnectID,TcpSendBuffer,NB_send_len,PNULL,PNULL,PNULL);
|
|
|
#ifdef USING_PRINTF
|
|
|
- printf("网络发送:%d\n ",TcpSendID);
|
|
|
+ printf("TcpSend:");
|
|
|
+ for (int i = 0; i < NB_send_len; i++)
|
|
|
+ {
|
|
|
+ printf("%x ",*(TcpSendBuffer+i));
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("\n ");
|
|
|
#endif
|
|
|
+ TcpSendID = tcpipConnectionSend(TcpConnectID,TcpSendBuffer,NB_send_len,PNULL,PNULL,PNULL);
|
|
|
PROC_NB_STATE_SWITCH(PROCESS_STATE_IDLE);
|
|
|
free(TcpSendBuffer);
|
|
|
break;
|