|
@@ -386,9 +386,10 @@ int InputStringNormalize(char *inputCmdString, char *outputCmdString, unsigned i
|
|
|
|
|
|
if(len > 0)
|
|
|
{
|
|
|
- while(start < len - 1)
|
|
|
+ while(start < len)
|
|
|
{
|
|
|
- if(inputCmdString[start] != ' ' && inputCmdString[start] != '\0')
|
|
|
+ if(inputCmdString[start] != ' ' && inputCmdString[start] != '\0' &&
|
|
|
+ inputCmdString[start] != '\r' && inputCmdString[start] != '\n')
|
|
|
{
|
|
|
cmdLen = ParsingCmd(&inputCmdString[start], &outputCmdString[totalLen]);
|
|
|
|
|
@@ -1733,13 +1734,15 @@ void CleanWiringInfo(void)
|
|
|
|
|
|
void SetSystemSoftRest(void)
|
|
|
{
|
|
|
- printf("********* Set Soft Reset ********\r\n");
|
|
|
+ printf("\r\n");
|
|
|
+ printf("********* Set Soft Reset ********\r\n\r\n");
|
|
|
ShmChargerInfo->Control.SysCtrl.bits.NeedSoftReset = true;
|
|
|
}
|
|
|
|
|
|
void SetSystemHardReboot(void)
|
|
|
{
|
|
|
- printf("******** Set Hard Reboot ********\r\n");
|
|
|
+ printf("\r\n");
|
|
|
+ printf("******** Set Hard Reboot ********\r\n\r\n");
|
|
|
ShmChargerInfo->Control.SysCtrl.bits.NeedHardReset = true;
|
|
|
}
|
|
|
|
|
@@ -2350,10 +2353,10 @@ void ShowCabinetInfo(void)
|
|
|
void SetTestControl(char *v1, char *v2)
|
|
|
{
|
|
|
int testItem = 0;
|
|
|
- int testItemLen = 3;
|
|
|
+ int testItemLen = 4;
|
|
|
int enable = 0;
|
|
|
- char strTest[32][32] = {"tbl", "tfsb", "chgsm"};
|
|
|
- char strItem[32][32] = {"Balance", "Fast Standby Time", "Charging Simulation"};
|
|
|
+ char strTest[32][32] = {"tbl", "tfsb", "chgsm", "fcre"};
|
|
|
+ char strItem[32][32] = {"Balance", "Fast Standby Time", "Charging Simulation", "FCharging Release Extend"};
|
|
|
|
|
|
enable = atoi(v2);
|
|
|
|
|
@@ -2396,14 +2399,14 @@ void SetTestControl(char *v1, char *v2)
|
|
|
printf("\r\n");
|
|
|
}
|
|
|
|
|
|
-// Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading
|
|
|
-// 1 00 00 0 0000 V 000.0 A 0000 A XXX.XX XXX.XX
|
|
|
+// Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading DiffP_Ava DiffP_Cap DiffP_Lim
|
|
|
+// 1 00 00 0 0000 V 000.0 A 0000 A XXX.XX XXX.XX XXX kw XXX kW XXX kW
|
|
|
void ShowGroupingDemand(void)
|
|
|
{
|
|
|
byte target = 0;
|
|
|
unsigned char k1k2 = 0;
|
|
|
|
|
|
- printf("\r\n Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading");
|
|
|
+ printf("\r\n Gun Role Master K1K2 GTVoltage GTCurrent StableCurrent OutputLoading GunLoading DiffP_Ava DiffP_Cap DiffP_Lim");
|
|
|
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
{
|
|
@@ -2428,6 +2431,11 @@ void ShowGroupingDemand(void)
|
|
|
if(ShmChargerInfo->PsuGrouping.GroupCollection[target].TargetGroup == target + 1)
|
|
|
{
|
|
|
printf(" %3d.%02d", (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading / 100), (ShmChargerInfo->PsuGrouping.GroupCollection[target].GunLoading % 100));
|
|
|
+
|
|
|
+ printf(" %3d kW %3d kW %3d kW",
|
|
|
+ (int)ShmPsuGrouping->GroupCollection[target].DiffPower_Available,
|
|
|
+ (int)ShmPsuGrouping->GroupCollection[target].DiffPower_Capability,
|
|
|
+ (int)ShmPsuGrouping->GroupCollection[target].DiffPower_PhysicalLimit);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2448,8 +2456,9 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
|
|
|
if(gun <= 0 || gun > GENERAL_GUN_QUANTITY || _voltage < 0 || _voltage > 1000 || _current < 0 || _current > 1200)
|
|
|
{
|
|
|
- printf("\r\nGun Start Charging Input parameter %s, %s, %s over range", v1, v2, v3);
|
|
|
- printf("\r\n\r\n");
|
|
|
+ printf("\r\n");
|
|
|
+ printf("Gun Start Charging Input parameter %s, %s, %s over range\r\n", v1, v2, v3);
|
|
|
+ printf("\r\n");
|
|
|
return;
|
|
|
}
|
|
|
/*
|
|
@@ -2487,7 +2496,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
struct timespec _Wait_time;
|
|
|
unsigned char PreviousSystemStatus = 0xFF;
|
|
|
unsigned short _targetVoltage = 0, _targetCurrent = 0;
|
|
|
-
|
|
|
+ printf("\r\n");
|
|
|
while(wait)
|
|
|
{
|
|
|
switch(_chargingData[gun - 1]->SystemStatus)
|
|
@@ -2495,8 +2504,8 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_IDLE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_IDLE", gun);
|
|
|
- printf("\r\nSet Gun %d Start Charging > Voltage: %4d, Current: %d", gun, (int)_voltage, (int)_current);
|
|
|
+ printf("Gun %d S_IDLE\r\n", gun);
|
|
|
+ printf("Set Gun %d Start Charging > Voltage: %4d, Current: %d\r\n", gun, (int)_voltage, (int)_current);
|
|
|
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.EnableForceCharging = true;
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.StartForceCharging = true;
|
|
@@ -2509,7 +2518,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_REASSIGN_CHECK:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_REASSIGN_CHECK, Wait For Request Charging", gun);
|
|
|
+ printf("Gun %d S_REASSIGN_CHECK, Wait For Request Charging\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2517,7 +2526,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_REASSIGN:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_REASSIGN, Wait For Grouping", gun);
|
|
|
+ printf("Gun %d S_REASSIGN, Wait For Grouping\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2525,7 +2534,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_PREPARNING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARNING", gun);
|
|
|
+ printf("Gun %d S_PREPARNING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2533,7 +2542,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_PREPARING_FOR_EV:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARING_FOR_EV", gun);
|
|
|
+ printf("Gun %d S_PREPARING_FOR_EV\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2541,7 +2550,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_PREPARING_FOR_EVSE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARING_FOR_EVSE, Wait For EVSE", gun);
|
|
|
+ printf("Gun %d S_PREPARING_FOR_EVSE, Wait For EVSE\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
|
|
@@ -2550,23 +2559,23 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
{
|
|
|
_targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
|
|
|
_targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
|
|
|
- printf("\r\nGun %d Set Voltage: %4d, Current: %d", gun, _targetVoltage, _targetCurrent);
|
|
|
+ printf("Gun %d Set Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case S_CHARGING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_CHARGING", gun);
|
|
|
+ printf("Gun %d S_CHARGING\r\n", gun);
|
|
|
if(PreviousSystemStatus == 0xFF)
|
|
|
{
|
|
|
_targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
|
|
|
_targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
|
|
|
- printf("\r\nGun %d Voltage: %4d, Current: %d", gun, _targetVoltage, _targetCurrent);
|
|
|
+ printf("Gun %d Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
|
|
|
|
|
|
if(ShmChargerInfo->Control.FCharging[gun - 1].FCtrl.bits.EnableForceCharging)
|
|
|
{
|
|
|
- printf("\r\nSet Gun %d Force Charging > Voltage: %4d, Current: %d", gun, (int)_voltage, (int)_current);
|
|
|
+ printf("Set Gun %d Force Charging > Voltage: %4d, Current: %d\r\n", gun, (int)_voltage, (int)_current);
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FTargetVoltage = _voltage * 10;
|
|
|
ShmChargerInfo->Control.FCharging[gun - 1].FTargetCurrent = _current * 10;
|
|
|
}
|
|
@@ -2580,21 +2589,21 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
{
|
|
|
_targetVoltage = (int)_chargingData[gun - 1]->EvBatterytargetVoltage;
|
|
|
_targetCurrent = (int)_chargingData[gun - 1]->EvBatterytargetCurrent;
|
|
|
- printf("\r\nGun %d Set Voltage: %4d, Current: %d", gun, _targetVoltage, _targetCurrent);
|
|
|
+ printf("Gun %d Set Voltage: %4d, Current: %d\r\n", gun, _targetVoltage, _targetCurrent);
|
|
|
}
|
|
|
|
|
|
time = GetTimeoutValue(_Wait_time) / uSEC_VAL;
|
|
|
- if(time >= 3)
|
|
|
+ if(time >= 1)
|
|
|
{
|
|
|
wait = false;
|
|
|
- printf("\r\nDone");
|
|
|
+ printf("Done\r\n");
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case S_TERMINATING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_TERMINATING", gun);
|
|
|
+ printf("Gun %d S_TERMINATING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
wait = false;
|
|
@@ -2603,7 +2612,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_COMPLETE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_COMPLETE", gun);
|
|
|
+ printf("Gun %d S_COMPLETE\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
wait = false;
|
|
@@ -2612,7 +2621,7 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
case S_ALARM:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_ALARM", gun);
|
|
|
+ printf("Gun %d S_ALARM\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
wait = false;
|
|
@@ -2621,10 +2630,10 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
default:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun SystemStatus %d Unknown(%d)", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
+ printf("Gun SystemStatus %d Unknown(%d)\r\n", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
- printf("\r\nGun %d SystemStatus(%d) Is Not Available", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
+ printf("Gun %d SystemStatus(%d) Is Not Available\r\n", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
wait = false;
|
|
|
break;
|
|
|
}
|
|
@@ -2661,14 +2670,14 @@ void SetGunStartCharging(char *v1, char *v2, char *v3)
|
|
|
|
|
|
if(strcmp(newString[0], "c") == 0)
|
|
|
{
|
|
|
- printf("\r\nStop");
|
|
|
+ printf("Stop\r\n");
|
|
|
wait = false;
|
|
|
}
|
|
|
|
|
|
usleep(100000);
|
|
|
}
|
|
|
|
|
|
- printf("\r\n\r\n");
|
|
|
+ printf("\r\n");
|
|
|
}
|
|
|
|
|
|
// v1: gun
|
|
@@ -2680,8 +2689,9 @@ void SetGunStopCharging(char *v1)
|
|
|
|
|
|
if(gun <= 0 || gun > GENERAL_GUN_QUANTITY)
|
|
|
{
|
|
|
- printf("\r\nGun Stop Charging Input parameter %s over range", v1);
|
|
|
- printf("\r\n\r\n");
|
|
|
+ printf("\r\n");
|
|
|
+ printf("Gun Stop Charging Input parameter %s over range\r\n", v1);
|
|
|
+ printf("\r\n");
|
|
|
return;
|
|
|
}
|
|
|
/*
|
|
@@ -2707,7 +2717,7 @@ void SetGunStopCharging(char *v1)
|
|
|
int time = 0;
|
|
|
struct timespec _Wait_time;
|
|
|
unsigned char PreviousSystemStatus = 0xFF;
|
|
|
-
|
|
|
+ printf("\r\n");
|
|
|
while(wait)
|
|
|
{
|
|
|
switch(_chargingData[gun - 1]->SystemStatus)
|
|
@@ -2715,13 +2725,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_IDLE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_IDLE", gun);
|
|
|
+ printf("Gun %d S_IDLE\r\n", gun);
|
|
|
|
|
|
if(PreviousSystemStatus == 0xFF)
|
|
|
{
|
|
|
if(ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].Role == _GROLE_SLAVE)
|
|
|
{
|
|
|
- printf("\r\nSet Group [%02X] Stop", gun - 1);
|
|
|
+ printf("Set Group [%02X] Stop\r\n", gun - 1);
|
|
|
ShmChargerInfo->PsuGrouping.GroupCollection[gun - 1].GroupCtrl.bits.SlavePowerOffRequest = true;
|
|
|
}
|
|
|
}
|
|
@@ -2731,23 +2741,23 @@ void SetGunStopCharging(char *v1)
|
|
|
}
|
|
|
|
|
|
time = GetTimeoutValue(_Wait_time) / uSEC_VAL;
|
|
|
- if(time >= 3)
|
|
|
+ if(time >= 1)
|
|
|
{
|
|
|
wait = false;
|
|
|
- printf("\r\nDone");
|
|
|
+ printf("Done\r\n");
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case S_REASSIGN_CHECK:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_REASSIGN_CHECK, Wait For Request Charging", gun);
|
|
|
+ printf("Gun %d S_REASSIGN_CHECK, Wait For Request Charging\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2755,13 +2765,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_REASSIGN:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_REASSIGN, Wait For Grouping", gun);
|
|
|
+ printf("Gun %d S_REASSIGN, Wait For Grouping\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2769,13 +2779,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_PREPARNING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARNING", gun);
|
|
|
+ printf("Gun %d S_PREPARNING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2783,13 +2793,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_PREPARING_FOR_EV:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARING_FOR_EV", gun);
|
|
|
+ printf("Gun %d S_PREPARING_FOR_EV\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2797,13 +2807,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_PREPARING_FOR_EVSE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_PREPARING_FOR_EVSE, Wait For EVSE", gun);
|
|
|
+ printf("Gun %d S_PREPARING_FOR_EVSE, Wait For EVSE\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2811,13 +2821,13 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_CHARGING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_CHARGING", gun);
|
|
|
+ printf("Gun %d S_CHARGING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
{
|
|
|
_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("\r\nSet Gun %d Stop Charging(ManualStop)", gun);
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -2825,7 +2835,7 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_TERMINATING:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_TERMINATING", gun);
|
|
|
+ printf("Gun %d S_TERMINATING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2833,7 +2843,7 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_COMPLETE:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_COMPLETE", gun);
|
|
|
+ printf("Gun %d S_COMPLETE\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2841,7 +2851,7 @@ void SetGunStopCharging(char *v1)
|
|
|
case S_ALARM:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun %d S_ALARM", gun);
|
|
|
+ printf("Gun %d S_ALARM\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
break;
|
|
@@ -2849,10 +2859,10 @@ void SetGunStopCharging(char *v1)
|
|
|
default:
|
|
|
if(PreviousSystemStatus != _chargingData[gun - 1]->SystemStatus)
|
|
|
{
|
|
|
- printf("\r\nGun SystemStatus %d Unknown(%d)", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
+ printf("Gun SystemStatus %d Unknown(%d)\r\n", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
}
|
|
|
- printf("\r\nGun %d SystemStatus(%d) Is Not Available", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
+ printf("Gun %d SystemStatus(%d) Is Not Available\r\n", gun, _chargingData[gun - 1]->SystemStatus);
|
|
|
wait = false;
|
|
|
break;
|
|
|
}
|
|
@@ -2889,14 +2899,14 @@ void SetGunStopCharging(char *v1)
|
|
|
|
|
|
if(strcmp(newString[0], "c") == 0)
|
|
|
{
|
|
|
- printf("\r\nStop");
|
|
|
+ printf("Stop\r\n");
|
|
|
wait = false;
|
|
|
}
|
|
|
|
|
|
usleep(100000);
|
|
|
}
|
|
|
|
|
|
- printf("\r\n\r\n");
|
|
|
+ printf("\r\n");
|
|
|
}
|
|
|
|
|
|
void SetGunExtend(char *v1)
|
|
@@ -3494,6 +3504,197 @@ void ShowInfo(char *inputCmd, unsigned int opt)
|
|
|
printf("\r\n");
|
|
|
}
|
|
|
|
|
|
+void RtcSyncCmd(char *inputCmd, unsigned int opt)
|
|
|
+{
|
|
|
+ unsigned int paraOpt = 0;
|
|
|
+ int totalCnt = 0, parseCnt = 0, maxPara = 0;
|
|
|
+ char normalString[128];
|
|
|
+ char paraList[2][128];
|
|
|
+ char hostAdd[32];
|
|
|
+ int dispenser = 0, offset = 0;
|
|
|
+
|
|
|
+ memset(hostAdd, 0x00, sizeof(hostAdd));
|
|
|
+ maxPara = 2;
|
|
|
+ totalCnt = InputStringNormalize(inputCmd, normalString, ¶Opt);
|
|
|
+
|
|
|
+ if(totalCnt != 2)
|
|
|
+ {
|
|
|
+ printf("Input cmd fail ------ rtc [dispenser 1-4] [offset minute]\r\n\r\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ printf("\r\n");
|
|
|
+ if(totalCnt > 0)
|
|
|
+ {
|
|
|
+ totalCnt = totalCnt > maxPara ? maxPara : totalCnt;
|
|
|
+
|
|
|
+ int loopLimit = totalCnt > 1 ? totalCnt - 1 : 1;
|
|
|
+
|
|
|
+ for(int i = 0; i < loopLimit; i++)
|
|
|
+ {
|
|
|
+ memset(¶List[parseCnt][0], 0x00, 128);
|
|
|
+ memset(¶List[parseCnt + 1][0], 0x00, 128);
|
|
|
+
|
|
|
+ MainAndSubCommandParsing(normalString, ¶List[parseCnt][0], ¶List[parseCnt + 1][0]);
|
|
|
+ strcpy(normalString, ¶List[parseCnt + 1][0]);
|
|
|
+ parseCnt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dispenser = atoi(¶List[0][0]);
|
|
|
+ offset = atoi(¶List[1][0]);
|
|
|
+
|
|
|
+ if(dispenser <= 0 || dispenser > CONNECTOR_QUANTITY)
|
|
|
+ {
|
|
|
+ printf("dispenser %d over range\r\n\r\n", dispenser);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser - 1].LocalStatus == _DS_None ||
|
|
|
+ ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[dispenser - 1].LocalStatus == _DS_Timeout)
|
|
|
+ {
|
|
|
+ printf("dispenser %d is not available\r\n\r\n", dispenser);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // find dispenser ip address
|
|
|
+ for(int i = 0; i < CONNECTOR_QUANTITY; i++)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].Status == _CNS_DispenserMatched)
|
|
|
+ {
|
|
|
+ if(ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].DispenserIndex == (dispenser - 1))
|
|
|
+ {
|
|
|
+ sprintf(hostAdd, "%d.%d.%d.%d",
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 0) &0xFF),
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 8) &0xFF),
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 16) &0xFF),
|
|
|
+ ((ShmSysConfigAndInfo->SysInfo.DispenserInfo.ConnectionInfo[i].IpAddress >> 24) &0xFF));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(strlen(hostAdd) == 0)
|
|
|
+ {
|
|
|
+ printf("dispenser %d ip is not available\r\n\r\n", dispenser);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ printf("try sycn dispenser %d [%s] rtc, offset: %d minutes\r\n", dispenser, hostAdd, offset);
|
|
|
+
|
|
|
+ // get current time and create offset time
|
|
|
+ time_t timep;
|
|
|
+ struct tm *tm;
|
|
|
+ time(&timep);
|
|
|
+ tm = localtime(&timep);
|
|
|
+
|
|
|
+ printf(" NowTime: %d/%02d/%02d %02d:%02d:%02d\r\n",
|
|
|
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
+ if(offset != 0)
|
|
|
+ {
|
|
|
+ timep += (offset * 60);
|
|
|
+ tm = localtime(&timep);
|
|
|
+ printf("OffsetTime: %d/%02d/%02d %02d:%02d:%02d\r\n\r\n",
|
|
|
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
+ }
|
|
|
+
|
|
|
+ // create send socket
|
|
|
+ int rtcfd = 0;
|
|
|
+ struct sockaddr_in serverInfo;
|
|
|
+ struct timeval tv;
|
|
|
+
|
|
|
+ char rtcTxBuffer[64];
|
|
|
+ char rtcRxBuffer[64];
|
|
|
+ int txLen = 0, rxLen = 0;
|
|
|
+ unsigned char chksum = 0x00;
|
|
|
+
|
|
|
+ rtcfd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
+ if (rtcfd < 0)
|
|
|
+ {
|
|
|
+ printf("create rtc socket fail\r\n\r\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(rtcTxBuffer, 0x00, sizeof(rtcTxBuffer));
|
|
|
+ memset(rtcRxBuffer, 0x00, sizeof(rtcRxBuffer));
|
|
|
+
|
|
|
+ tv.tv_sec = 3;
|
|
|
+ tv.tv_usec = 0;
|
|
|
+ setsockopt(rtcfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)); //設定等待3s
|
|
|
+ setsockopt(rtcfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(struct timeval)); //設定傳送3s
|
|
|
+
|
|
|
+ bzero(&serverInfo,sizeof(serverInfo));
|
|
|
+ serverInfo.sin_family = AF_INET;
|
|
|
+ serverInfo.sin_addr.s_addr = inet_addr(hostAdd);
|
|
|
+ serverInfo.sin_port = htons(8234);
|
|
|
+
|
|
|
+ if(connect(rtcfd, (struct sockaddr *)&serverInfo, sizeof(serverInfo)) < 0)
|
|
|
+ {
|
|
|
+ printf("connect to host: %s fail\r\n\r\n", hostAdd);
|
|
|
+
|
|
|
+ close(rtcfd);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // set tx header & data
|
|
|
+ rtcTxBuffer[0] = 0xAA; // Frame ID
|
|
|
+ rtcTxBuffer[1] = 0x00; // Master address
|
|
|
+ rtcTxBuffer[2] = 0xFF; // Slave address
|
|
|
+ rtcTxBuffer[3] = 0x87; // 0x87
|
|
|
+ rtcTxBuffer[4] = 0x0E; // Length_Low
|
|
|
+ rtcTxBuffer[5] = 0x00; // Length_High
|
|
|
+ sprintf(&rtcTxBuffer[6], "%04d%02d%02d%02d%02d%02d",
|
|
|
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
|
|
+
|
|
|
+ txLen = rtcTxBuffer[4] + (rtcTxBuffer[5] << 8);
|
|
|
+
|
|
|
+ chksum = 0;
|
|
|
+ for(int i = 0; i < txLen; i++)
|
|
|
+ {
|
|
|
+ chksum ^= rtcTxBuffer[6 + i];
|
|
|
+ }
|
|
|
+ rtcTxBuffer[6 + txLen] = chksum;
|
|
|
+
|
|
|
+ send(rtcfd, rtcTxBuffer, txLen + 7, MSG_NOSIGNAL);
|
|
|
+
|
|
|
+ // receive
|
|
|
+ if(recv(rtcfd, &rtcRxBuffer[0], 6, MSG_WAITALL) < 0)
|
|
|
+ {
|
|
|
+ printf("read head fail\r\n\r\n");
|
|
|
+ close(rtcfd);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rxLen = rtcRxBuffer[4] + (rtcRxBuffer[5] << 8);
|
|
|
+
|
|
|
+ if(recv(rtcfd, &rtcRxBuffer[6], rxLen + 1, MSG_WAITALL) < 0)
|
|
|
+ {
|
|
|
+ printf("read data fail\r\n\r\n");
|
|
|
+ close(rtcfd);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ chksum = 0;
|
|
|
+ for(int i = 0; i < rxLen; i++)
|
|
|
+ {
|
|
|
+ chksum ^= rtcRxBuffer[6 + i];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(chksum == rtcRxBuffer[6 + rxLen])
|
|
|
+ {
|
|
|
+ printf("set %s rtc: ", hostAdd);
|
|
|
+ for(int i = 0; i < txLen; i++)
|
|
|
+ {
|
|
|
+ printf("%c", rtcTxBuffer[6 + i]);
|
|
|
+ }
|
|
|
+ printf(" %s\r\n\r\n", rtcRxBuffer[6] == 0x01 ? "success" : "fail");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ printf("receive rtc checksum fail\r\n\r\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ close(rtcfd);
|
|
|
+}
|
|
|
+
|
|
|
int main(void)
|
|
|
{
|
|
|
char newString[32][32];
|
|
@@ -3882,61 +4083,6 @@ int main(void)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
- /*
|
|
|
- else if(strcmp(newString[0], "dbop") == 0)
|
|
|
- {
|
|
|
- if(DeductDB_Open())
|
|
|
- {
|
|
|
- printf ("Deduct DB Open OK\n\n");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf ("Deduct DB Open OK\n\n");
|
|
|
- }
|
|
|
- }
|
|
|
- else if(strcmp(newString[0], "dbup") == 0)
|
|
|
- {
|
|
|
- int gun = 0;
|
|
|
- RecordTransactionInfo deduct;
|
|
|
-
|
|
|
- if(DB_GetReUploadDeduct(&gun, &deduct) == PASS)
|
|
|
- {
|
|
|
- printf("Get Gun %d, TxId: %d, Result: %d, Donate: %d, ApprovalNo: %s, CardNo: %s, VemData: %s, Amount: %f, IsUpload: %d\r\n",
|
|
|
- gun, deduct.TransactionId, deduct.DeductResult, deduct.IsDonateInvoice, deduct.ApprovalNo, deduct.CardNo, deduct.VemData, deduct.Amount, deduct.IsUpload);
|
|
|
-
|
|
|
- deduct.IsUpload = YES;
|
|
|
- printf("Set this deduct upload OK, and restore into database\r\n");
|
|
|
- UpdateDeductInfoStatus(gun, &deduct);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf("There is no deduct info need to upload\r\n");
|
|
|
- }
|
|
|
- }
|
|
|
- else if(strcmp(newString[0], "dbde") == 0)
|
|
|
- {
|
|
|
- int gun = 0;
|
|
|
- RecordTransactionInfo deduct;
|
|
|
-
|
|
|
- if(DB_GetReDeductInfo(&gun, &deduct) == PASS)
|
|
|
- {
|
|
|
- printf("Get Gun %d, TxId: %d, Result: %d, Donate: %d, ApprovalNo: %s, CardNo: %s, VemData: %s, Amount: %f, IsUpload: %d\r\n",
|
|
|
- gun, deduct.TransactionId, deduct.DeductResult, deduct.IsDonateInvoice, deduct.ApprovalNo, deduct.CardNo, deduct.VemData, deduct.Amount, deduct.IsUpload);
|
|
|
-
|
|
|
- deduct.DeductResult = YES;
|
|
|
- printf("Set this deduct result OK, and restore into database\r\n");
|
|
|
- UpdateDeductInfoStatus(gun, &deduct);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf("There is no deduct info need to re-deduct\r\n");
|
|
|
- }
|
|
|
- }
|
|
|
- else if(strcmp(newString[0], "db") == 0)
|
|
|
- {
|
|
|
- DB_GetAllDeductInfo();
|
|
|
- }
|
|
|
- */
|
|
|
else if(strcmp(newString[0], "gcmd") == 0)
|
|
|
{
|
|
|
if(strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
|
|
@@ -3955,6 +4101,10 @@ int main(void)
|
|
|
else if(strcmp(mainCmd, "info") == 0)
|
|
|
{
|
|
|
ShowInfo(subCmd, option);
|
|
|
+ }
|
|
|
+ else if(strcmp(mainCmd, "rtcsync") == 0)
|
|
|
+ {
|
|
|
+ RtcSyncCmd(subCmd, option);
|
|
|
}
|
|
|
else
|
|
|
{
|