|
@@ -52,10 +52,10 @@ uint8_t process1SlpHandler = 0xff;
|
|
|
uint8_t process2SlpHandler = 0xff;
|
|
|
uint8_t process3SlpHandler = 0xff;
|
|
|
uint8_t Can_Rece_buffer[8];
|
|
|
-uint16_t Batt_Cell_Num = 14;//默认数值14、17
|
|
|
-uint16_t Batt_Cell_Num_2 ;//默认数值
|
|
|
-uint16_t Batt_Temp_Num = 5;//默认数值5、7
|
|
|
-int16_t Uart_Rece_BattI;
|
|
|
+uint8_t Batt_Cell_Num = 14;//默认数值14、17
|
|
|
+uint8_t Batt_Cell_Num_2 ;//默认数值
|
|
|
+uint8_t Batt_Temp_Num = 5;//默认数值5、7
|
|
|
+int16_t Uart_Rece_BattI=0x0000;
|
|
|
uint8_t battbuffer[73];//电池数据都存在此数组中————电压14,温度5
|
|
|
/**
|
|
|
* 存放规则如下:
|
|
@@ -106,7 +106,7 @@ process_NB gProc3State = PROCESS_NB_STATE_IDLE;
|
|
|
#define PROC_Uart_STATE_SWITCH(a) (gProc1State = a) //uart 状态切换
|
|
|
#define PROC_Can_STATE_SWITCH(a) (gProc2State = a) //can 状态切换
|
|
|
#define PROC_NB_STATE_SWITCH(a) (gProc3State = a) //NB状态切换
|
|
|
-
|
|
|
+uint8_t deepslpTimerID = 7;
|
|
|
//-------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
unsigned int crc_chk(uint8_t* data, uint8_t length)
|
|
|
{
|
|
@@ -164,20 +164,20 @@ uint8_t* Uart_Receive_func(Uart_Receive_Type Uart_Receive_Msg,uint8_t *Uart_Rece
|
|
|
isRecvComplete = false;
|
|
|
CRC_Rece_buffer =*(Uart_Rece_buffer+Rece_Data_Len+4)<<8|*(Uart_Rece_buffer+Rece_Data_Len+3);
|
|
|
CRC_chk_buffer = crc_chk(Uart_Rece_buffer,Rece_Data_Len+3);
|
|
|
- #ifdef USING_PRINTF
|
|
|
- // printf("Uart_Send_buffer: ");
|
|
|
- // for(int i=0;i<8;i++)
|
|
|
- // {
|
|
|
- // printf("%x ",Uart_Send_buffer[i]);
|
|
|
- // }
|
|
|
- // printf("\n");
|
|
|
- // printf("Uart_Rece_buffer: ");
|
|
|
- // for(int i=0;i<Rece_Data_Len+5;i++)
|
|
|
- // {
|
|
|
- // printf("%x ",*(Uart_Rece_buffer+i));
|
|
|
- // }
|
|
|
- printf("uart_check_pass\n");
|
|
|
- #endif
|
|
|
+ // #ifdef USING_PRINTF
|
|
|
+ // // printf("Uart_Send_buffer: ");
|
|
|
+ // // for(int i=0;i<8;i++)
|
|
|
+ // // {
|
|
|
+ // // printf("%x ",Uart_Send_buffer[i]);
|
|
|
+ // // }
|
|
|
+ // // printf("\n");
|
|
|
+ // printf("Uart_Rece_buffer: ");
|
|
|
+ // for(int i=0;i<Rece_Data_Len+5;i++)
|
|
|
+ // {
|
|
|
+ // printf("%x ",*(Uart_Rece_buffer+i));
|
|
|
+ // }
|
|
|
+ // printf("crcchk:%x,%x ",CRC_chk_buffer,CRC_Rece_buffer);
|
|
|
+ // #endif
|
|
|
if (CRC_Rece_buffer == CRC_chk_buffer)//满足校验
|
|
|
{
|
|
|
return Uart_Rece_buffer+3;
|
|
@@ -249,13 +249,13 @@ static void process0AppTask(void* arg)//任务调度程序
|
|
|
#endif
|
|
|
PROC_Uart_STATE_SWITCH(PROCESS_Uart_STATE_CHECK);
|
|
|
NetSocDisplay(LED_SOC_0,LED_TURN_ON);
|
|
|
- osDelay(10);//delay 10ms
|
|
|
+ osDelay(100);//delay 100ms
|
|
|
if(Uart_Rece_BattI!=0x0000)
|
|
|
{
|
|
|
PROC_Task_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
}
|
|
|
sleep_index++;
|
|
|
- if(sleep_index>=200)
|
|
|
+ if(sleep_index>=50)
|
|
|
{
|
|
|
NetSocDisplay(LED_SOC_0,LED_TURN_OFF);
|
|
|
sleep_index=0;
|
|
@@ -279,7 +279,7 @@ static void process0AppTask(void* arg)//任务调度程序
|
|
|
PROC_Can_STATE_SWITCH(PROCESS_STATE_WORK);
|
|
|
Can_index = 0;
|
|
|
}
|
|
|
- if (NB_index >=100)//NB 1s 调用一次
|
|
|
+ if (NB_index >=1000)//NB 10s 调用一次
|
|
|
{
|
|
|
PROC_NB_STATE_SWITCH(PROCESS_NB_STATE_CONNECT);
|
|
|
NB_index = 0;
|
|
@@ -311,7 +311,7 @@ static void process0AppTask(void* arg)//任务调度程序
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("ready to sleep \n");
|
|
|
#endif
|
|
|
- slpManDeepSlpTimerStart(7,10000); // create a 60s timer, DeepSleep Timer is always oneshoot
|
|
|
+ slpManDeepSlpTimerStart(deepslpTimerID,60000); // create a 60s timer, DeepSleep Timer is always oneshoot
|
|
|
while(1) // now app can enter hib, but ps and phy maybe not, so wait here
|
|
|
{
|
|
|
osDelay(3000);
|
|
@@ -351,6 +351,8 @@ static void process1AppTask(void* arg)
|
|
|
}
|
|
|
case PROCESS_Uart_STATE_CHECK://检查电流数值
|
|
|
{
|
|
|
+ Uart_Rece_buffer = (uint8_t *)malloc(16);
|
|
|
+ memset(Uart_Rece_buffer,0xff,8);
|
|
|
Uart_Receive_Msg.Reg_Begin_H = 0x00;
|
|
|
Uart_Receive_Msg.Reg_Begin_L= 0x02+Batt_Cell_Num;
|
|
|
Uart_Receive_Msg.Reg_Num_H = 0x00;
|
|
@@ -358,8 +360,9 @@ static void process1AppTask(void* arg)
|
|
|
Uart_Reve_Point = Uart_Receive_func(Uart_Receive_Msg,Uart_Rece_buffer);
|
|
|
Uart_Rece_BattI = *(Uart_Reve_Point+0)<<8 |*(Uart_Reve_Point+1);
|
|
|
#ifdef USING_PRINTF
|
|
|
- printf("Check_Current! %x\n ",Uart_Rece_BattI);
|
|
|
+ printf("Check_Current!");
|
|
|
#endif
|
|
|
+ free(Uart_Rece_buffer);
|
|
|
PROC_Uart_STATE_SWITCH(PROCESS_Uart_STATE_IDLE);
|
|
|
break;
|
|
|
}
|
|
@@ -700,7 +703,7 @@ void Tcp_Data_Assemble(uint8_t datatype)
|
|
|
}
|
|
|
static void process3AppTask(void* arg)
|
|
|
{
|
|
|
- CHAR SN[] = "GYTEST00000000002";
|
|
|
+ CHAR SN[] = "GYTEST00000000003";
|
|
|
CHAR serverip[] = "47.97.127.222";
|
|
|
UINT16 serverport = 8712;
|
|
|
int TcpConnectID = -1;
|
|
@@ -715,6 +718,7 @@ static void process3AppTask(void* arg)
|
|
|
{
|
|
|
case PROCESS_NB_STATE_IDLE:
|
|
|
{
|
|
|
+ osDelay(100);
|
|
|
break;
|
|
|
}
|
|
|
case PROCESS_NB_STATE_CONNECT:
|
|
@@ -722,6 +726,10 @@ static void process3AppTask(void* arg)
|
|
|
while(TcpConnectID<0)
|
|
|
{
|
|
|
TcpConnectID = tcpipConnectionCreate(1,PNULL,PNULL,serverip,serverport,TcpCallBack);
|
|
|
+ osDelay(100);
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("ConnectID:%d\n ",TcpConnectID);
|
|
|
+ #endif
|
|
|
}
|
|
|
PROC_NB_STATE_SWITCH(PROCESS_NB_STATE_WORK);
|
|
|
break;
|