|
@@ -151,18 +151,18 @@ void dM(uint8_t *data, uint16_t len, uint8_t isRX)
|
|
|
|
|
|
if(isRX)
|
|
|
{
|
|
|
- DEBUG_INFO("- RX --------------------------------------------\n");
|
|
|
+ DEBUG_INFO_CLIENT("- RX --------------------------------------------\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DEBUG_INFO("- TX --------------------------------------------\n");
|
|
|
+ DEBUG_INFO_CLIENT("- TX --------------------------------------------\n");
|
|
|
}
|
|
|
|
|
|
memset(output, 0x00, ARRAY_SIZE(output));
|
|
|
for(uint16_t idx=0;idx<16;idx++)
|
|
|
sprintf((char*)output, "%s %02X", output, idx);
|
|
|
- DEBUG_INFO("%s\n", output);
|
|
|
- DEBUG_INFO("-------------------------------------------------\n");
|
|
|
+ DEBUG_INFO_CLIENT("%s\n", output);
|
|
|
+ DEBUG_INFO_CLIENT("-------------------------------------------------\n");
|
|
|
|
|
|
for(uint16_t idx = 0;idx<len;idx++)
|
|
|
{
|
|
@@ -178,8 +178,8 @@ void dM(uint8_t *data, uint16_t len, uint8_t isRX)
|
|
|
sprintf((char*)output, "%s %02X", output, data[idx]);
|
|
|
}
|
|
|
}
|
|
|
- DEBUG_INFO("%s\n", output);
|
|
|
- DEBUG_INFO("-------------------------------------------------\n");
|
|
|
+ DEBUG_INFO_CLIENT("%s\n", output);
|
|
|
+ DEBUG_INFO_CLIENT("-------------------------------------------------\n");
|
|
|
#endif
|
|
|
}
|
|
|
|
|
@@ -686,6 +686,7 @@ int conn_update_status(int socketFd, Connector_Info *connectorInfo, uint8_t conn
|
|
|
}
|
|
|
|
|
|
if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].isGunConnected != connectorInfo[gun_index].isGunConnected?YES:NO) ||
|
|
|
+ (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent != connectorInfo[gun_index].availableSharingCurrent) ||
|
|
|
(ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent != connectorInfo[gun_index].presentOutputCurrent))
|
|
|
{
|
|
|
DEBUG_INFO("Conn-%d gun_%d connected: %s\n", idx, gun_index, (connectorInfo[gun_index].isGunConnected?"Yes":"No"));
|
|
@@ -741,7 +742,7 @@ void create_cmd_getStatus(struct Message *out)
|
|
|
out->buffer[2] = SHARING_CMD_GET_STATUS;
|
|
|
out->buffer[out->size-1] = chksumCal(out);
|
|
|
|
|
|
- dM(out->buffer, out->size, FALSE);
|
|
|
+ //dM(out->buffer, out->size, FALSE);
|
|
|
}
|
|
|
|
|
|
void create_cmd_SetAvailableCurrent(struct Message *out, int socketFd)
|
|
@@ -766,7 +767,7 @@ void create_cmd_SetAvailableCurrent(struct Message *out, int socketFd)
|
|
|
}
|
|
|
}
|
|
|
out->buffer[out->size-1] = chksumCal(out);
|
|
|
- dM(out->buffer, out->size, FALSE);
|
|
|
+ //dM(out->buffer, out->size, FALSE);
|
|
|
}
|
|
|
|
|
|
int tcpSocketServer(void)
|
|
@@ -829,7 +830,7 @@ int tcpSocketServer(void)
|
|
|
{
|
|
|
if((input.size = recv(dupFd, input.buffer, sizeof(input.buffer), 0)) > 0)
|
|
|
{
|
|
|
- dM(input.buffer, input.size, YES);
|
|
|
+ //dM(input.buffer, input.size, YES);
|
|
|
|
|
|
if(isValidCheckSum(&input))
|
|
|
{
|
|
@@ -934,7 +935,7 @@ int tcpSocketServer(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- sleep(1);
|
|
|
+ usleep(500000);
|
|
|
}
|
|
|
|
|
|
return FAIL;
|
|
@@ -1202,7 +1203,7 @@ int tcpSocketClient(void)
|
|
|
cntSocketErr++;
|
|
|
}
|
|
|
}
|
|
|
- sleep(1);
|
|
|
+ usleep(500000);
|
|
|
}
|
|
|
close(sockfd);
|
|
|
|
|
@@ -1216,6 +1217,11 @@ int balance_check_loop(void)
|
|
|
{
|
|
|
for(;;)
|
|
|
{
|
|
|
+ // Get connection info
|
|
|
+ conn_getConectedQuantity();
|
|
|
+ conn_getOnHandCurrent();
|
|
|
+ conn_getConectedConnector();
|
|
|
+
|
|
|
// Check conn heart beat
|
|
|
for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
|
|
|
{
|
|
@@ -1256,7 +1262,6 @@ int balance_check_loop(void)
|
|
|
DEBUG_INFO("Detect gun connected re-allocate available current to each connection.\n");
|
|
|
ShmPowerSharing->isDetectNewConnected = NO;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
for(uint8_t idx=0;idx<CONNECTION_LIMIT;idx++)
|
|
@@ -1270,14 +1275,16 @@ int balance_check_loop(void)
|
|
|
{
|
|
|
if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent) > 3)
|
|
|
{
|
|
|
- if(ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent >= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC+SHARE_GAP_AC:SHARE_MIN_DC+SHARE_GAP_DC))
|
|
|
- ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent -= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_GAP_AC:SHARE_GAP_DC);
|
|
|
+ if((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent - ((ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent)>>1)) >= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC:SHARE_MIN_DC))
|
|
|
+ ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent -= (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent)>>1;
|
|
|
+ else
|
|
|
+ ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent = (ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].connectorType==CONNECTOR_TYPE_AC?SHARE_MIN_AC:SHARE_MIN_DC);
|
|
|
}
|
|
|
else if((abs(ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].presentOutputCurrent-ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent) <= 1) &&
|
|
|
(ShmPowerSharing->onHandCurrent > 0))
|
|
|
|
|
|
{
|
|
|
- ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent += ShmPowerSharing->onHandCurrent/ShmPowerSharing->connectedConnectorQty;
|
|
|
+ ShmPowerSharing->Connection_Info[idx].connectorInfo[gun_index].availableSharingCurrent += ShmPowerSharing->onHandCurrent/(ShmPowerSharing->connectedConnectorQty==0?1:ShmPowerSharing->connectedConnectorQty);
|
|
|
}
|
|
|
else
|
|
|
{}
|
|
@@ -1295,11 +1302,7 @@ int balance_check_loop(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- conn_getConectedQuantity();
|
|
|
- conn_getOnHandCurrent();
|
|
|
- conn_getConectedConnector();
|
|
|
-
|
|
|
- sleep(1);
|
|
|
+ usleep(100000);
|
|
|
}
|
|
|
|
|
|
return FAIL;
|