瀏覽代碼

2021-10-08 / Alston Lin
Actions
1. Add the function to detect the custom version

Files
1. As follow commit history

alston 3 年之前
父節點
當前提交
6bd52454b0

文件差異過大導致無法顯示
+ 271 - 277
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c


+ 22 - 48
EVSE/Projects/AW-CCS/Apps/CCS/v2g/api/api.c

@@ -669,7 +669,6 @@ int Check_V2G_Rx_Msg_Name_iso2(struct iso2EXIDocument *exi_doc_ISO2)
 	return errn;
 }
 
-
 /*===========================================================================
 FUNCTION: SAVE_PhysicalValueType_DIN70121
 DESCRIPTION:
@@ -735,7 +734,6 @@ void SAVE_PhysicalValueType_ISO15118_2014(struct PhysicalValueType_ISO15118_2014
         case V_ISO15118_2014:
             out->Multiplier = -1;
             break;    //KW
-
         case W_ISO15118_2014:
         case Wh_ISO15118_2014:
 			out->Value = in_value * 10;
@@ -754,7 +752,6 @@ void SAVE_PhysicalValueType_ISO15118_2014(struct PhysicalValueType_ISO15118_2014
     //WH_DIN70121 = 9};
 }
 
-
 /*===========================================================================
 FUNCTION: DIN70121PhyValDecode
 DESCRIPTION:
@@ -855,7 +852,6 @@ float ISO151182014PhyValDecode(struct PhysicalValueType_ISO15118_2014 PhysicalDa
     return 0;
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_dinPhysicalValueType
 DESCRIPTION:
@@ -911,7 +907,6 @@ void SHM_Read_iso1PhysicalValueType(struct iso1PhysicalValueType *out, struct Ph
 	//iso1unitSymbolType_Wh = 6
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_dinDC_EVSEStatusType
 DESCRIPTION:
@@ -1040,7 +1035,7 @@ void SHM_Read_iso1MeterInfo(struct iso1MeterInfoType *out, struct MeterInfoType_
 	int i = 0;
 
 	//[1/5] MeterID
-	out->MeterID.charactersLen = 32;
+	out->MeterID.charactersLen = (strlen((char*)in->MeterID)<iso1MeterInfoType_MeterID_CHARACTERS_SIZE ? strlen((char*)in->MeterID) : iso1MeterInfoType_MeterID_CHARACTERS_SIZE);
 	for (i = 0; i < out->MeterID.charactersLen; i++)
 	{
 		out->MeterID.characters[i] = (unsigned char)in->MeterID[i];
@@ -1052,7 +1047,7 @@ void SHM_Read_iso1MeterInfo(struct iso1MeterInfoType *out, struct MeterInfoType_
 
 	//[3/5] SigMeterReading
 	out->SigMeterReading_isUsed = 1u;
-	out->SigMeterReading.bytesLen = 64;
+	out->SigMeterReading.bytesLen = (strlen((char*)in->SigMeterReading)<iso1MeterInfoType_SigMeterReading_BYTES_SIZE ? strlen((char*)in->SigMeterReading) : iso1MeterInfoType_SigMeterReading_BYTES_SIZE);
 	for (i = 0; i < out->SigMeterReading.bytesLen; i++)
 	{
 		out->SigMeterReading.bytes[i] = (unsigned char)in->SigMeterReading[i];
@@ -1360,7 +1355,6 @@ void SHM_Save_iso1_ServiceAndPaymentSelectionReq(struct CcsData *shm_ccs, struct
     }
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_din_ContractAuthenticationReq
 DESCRIPTION:
@@ -1605,7 +1599,6 @@ void SHM_Save_iso1_ChargeParameterDiscoveryReq(struct CcsData *shm_ccs, struct i
     shm_msg->DC_EVChargeParameter.BulkSOC = (unsigned char) exi->DC_EVChargeParameter.BulkSOC;
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_din_CableCheckReq
 DESCRIPTION:
@@ -1686,7 +1679,6 @@ void SHM_Save_iso1_CableCheckReq(struct CcsData *shm_ccs, struct iso1EXIDocument
 	//}
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_din_PreChargeReq
 DESCRIPTION:
@@ -1913,7 +1905,6 @@ void SHM_Save_iso1_PowerDeliveryReq(struct CcsData *shm_ccs, struct iso1EXIDocum
 	shm_msg->DC_EVPowerDeliveryParameter.ChargingComplete = (BOOL) exi->DC_EVPowerDeliveryParameter.ChargingComplete;
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_din_CurrentDemandReq
 DESCRIPTION:
@@ -2161,7 +2152,6 @@ void SHM_Save_iso1_CurrentDemandReq(struct CcsData *shm_ccs, struct iso1EXIDocum
 	#endif
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_iso1_ChargingStatusReq
 DESCRIPTION:
@@ -2245,7 +2235,6 @@ void SHM_Save_iso1_WeldingDetectionReq(struct CcsData *shm_ccs, struct iso1EXIDo
 	sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Save_din_SessionStopReq
 DESCRIPTION:
@@ -2302,7 +2291,6 @@ void SHM_Save_iso1_SessionStopReq(struct CcsData *shm_ccs, struct iso1EXIDocumen
 	//null
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_SessionSetupRes
 DESCRIPTION:
@@ -2363,7 +2351,6 @@ void SHM_Read_din_ContractAuthenticationRes(struct dinEXIDocument *exi_doc_DIN,
 	out->EVSEProcessing = (BOOL)in->EVSEProcessing; //0(Finished) or 1(Ongoing)
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_ChargeParameterDiscoveryRes
 DESCRIPTION:
@@ -2586,7 +2573,6 @@ void SHM_Read_iso1_ChargeParameterDiscoveryRes(struct iso1EXIDocument *exi_doc_I
 	#endif
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_CableCheckRes
 DESCRIPTION:
@@ -2657,7 +2643,6 @@ void SHM_Read_iso1_CableCheckRes(struct iso1EXIDocument *exi_doc_ISO1, struct Cc
 	SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_PreChargeRes
 DESCRIPTION:
@@ -2745,7 +2730,6 @@ void SHM_Read_iso1_PreChargeRes(struct iso1EXIDocument *exi_doc_ISO1, struct Ccs
 	SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_PowerDeliveryRes
 DESCRIPTION:
@@ -2814,7 +2798,8 @@ void SHM_Read_iso1_PowerDeliveryRes(struct iso1EXIDocument *exi_doc_ISO1, struct
     //----- [BODY (2/3)] DC_EVSEStatus -----
 	#if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) | (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
 	{
-		//out->DC_EVSEStatus_isUsed = 0u;
+    	out->AC_EVSEStatus_isUsed = 1u;
+    	SHM_Read_iso1AC_EVSEStatusType(&out->AC_EVSEStatus, &in->AC_EVSEStatus);
 	}
 	#else //CCS_ENERGY_TRANSFER_MODE == MODE_DC_EXTENDED
 	{
@@ -2824,7 +2809,6 @@ void SHM_Read_iso1_PowerDeliveryRes(struct iso1EXIDocument *exi_doc_ISO1, struct
 	#endif
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_CurrentDemandRes
 DESCRIPTION:
@@ -2968,7 +2952,6 @@ GLOBAL VARIABLES:
 =============================================================================*/
 void SHM_Read_iso1_ChargingStatusRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
 {
-	int i = 0;
 	struct iso1ChargingStatusResType *out;
 	struct ChargingStatusResponse_ISO15118_2014 *in;
 	init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
@@ -2978,7 +2961,6 @@ void SHM_Read_iso1_ChargingStatusRes(struct iso1EXIDocument *exi_doc_ISO1, struc
 	in = &shm_ccs->V2GMessage_ISO15118_2014.ChargingStatusResponse;
 	exi_doc_ISO1->V2G_Message.Body.ChargingStatusRes_isUsed = 1u;
 
-
 	//----- [BODY (1/10)] ResponseCode -----
     out->ResponseCode = (unsigned char)in->ResponseCode;
 
@@ -2993,8 +2975,8 @@ void SHM_Read_iso1_ChargingStatusRes(struct iso1EXIDocument *exi_doc_ISO1, struc
 	out->SAScheduleTupleID = (unsigned char)in->SAScheduleTupleID;	//[CAUTION] data type
 
     //----- [BODY (5/10)] EVSEID -----
-	out->EVSEID.charactersLen = 37;  //min length: 7, max length:37  bytes(ISO1, AC)
-	for (i = 0; i< out->EVSEID.charactersLen; i++)
+	out->EVSEID.charactersLen = (strlen((char*)in->EVSEID)<iso1ChargingStatusResType_EVSEID_CHARACTERS_SIZE) ? strlen((char*)in->EVSEID) : iso1ChargingStatusResType_EVSEID_CHARACTERS_SIZE;  //min length: 7, max length:37  bytes(ISO1, AC)
+	for (uint8_t i = 0; i< out->EVSEID.charactersLen; i++)
 	{
 		out->EVSEID.characters[i] = (unsigned char)in->EVSEID[i];
 	}
@@ -3080,7 +3062,6 @@ void SHM_Read_iso1_WeldingDetectionRes(struct iso1EXIDocument *exi_doc_ISO1, str
     SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
 }
 
-
 /*===========================================================================
 FUNCTION: SHM_Read_din_SessionStopRes
 DESCRIPTION:
@@ -3309,7 +3290,6 @@ void PRINT_XML_DOC_ISO2_SessionSetupReq(struct iso2EXIDocument *exi_doc_ISO2)
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionSetupReq\n");
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_ServiceDiscoveryReq
 DESCRIPTION:
@@ -3433,7 +3413,6 @@ void PRINT_XML_DOC_ISO1_ServiceDiscoveryReq(struct iso1EXIDocument *exi_doc_ISO1
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ServiceDiscoveryReq\n");
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_ServiceAndPaymentSelectionReq
 DESCRIPTION:
@@ -3543,7 +3522,6 @@ void PRINT_XML_DOC_ISO1_ServiceAndPaymentSelectionReq(struct iso1EXIDocument *ex
     DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [END] Parsing PaymentServiceSelectionReq\n");
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_ContractAuthenticationReq
 DESCRIPTION:
@@ -3785,7 +3763,7 @@ void PRINT_XML_DOC_ISO1_ChargeParameterDiscoveryReq(struct iso1EXIDocument *exi_
     //DC_EVStatus
     struct iso1DC_EVStatusType *status;
     status = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.DC_EVStatus;
-    PRINT_iso1DC_EVStatusType(status);
+    if(exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter_isUsed)PRINT_iso1DC_EVStatusType(status);
 
     //EVMaximumCurrentLimit
     obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumCurrentLimit;
@@ -3821,7 +3799,6 @@ void PRINT_XML_DOC_ISO1_ChargeParameterDiscoveryReq(struct iso1EXIDocument *exi_
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ChargeParameterDiscoveryReq (%d-th)\n", cnt);
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_CableCheckReq
 DESCRIPTION:
@@ -3911,7 +3888,6 @@ void PRINT_XML_DOC_DIN_PreChargeReq(struct dinEXIDocument *exi_doc_DIN)
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PreChargeReq (%d-th)\n", cnt);
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_ISO1_PreChargeReq
 DESCRIPTION:
@@ -3949,7 +3925,6 @@ void PRINT_XML_DOC_ISO1_PreChargeReq(struct iso1EXIDocument *exi_doc_ISO1)
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PreChargeReq (%d-th)\n", cnt);
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_PowerDeliveryReq
 DESCRIPTION:
@@ -4023,7 +3998,7 @@ void PRINT_XML_DOC_ISO1_PowerDeliveryReq(struct iso1EXIDocument *exi_doc_ISO1)
 
 
     //===== [BODY (1/3)] ChargeProgress =====
-    DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeProgress: %d (DEC, 0:start, 1:stop, 2:renegotiate)\n",
+    DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeProgress: %d (DEC, 0:start, 1:stop, 2:re-negotiate)\n",
             exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.ChargeProgress);
 	//iso1chargeProgressType_Start = 0,
 	//iso1chargeProgressType_Stop = 1,
@@ -4042,7 +4017,7 @@ void PRINT_XML_DOC_ISO1_PowerDeliveryReq(struct iso1EXIDocument *exi_doc_ISO1)
     //DC_EVStatus
     struct iso1DC_EVStatusType *status;
     status = &exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.DC_EVStatus;
-    PRINT_iso1DC_EVStatusType(status);
+    if(exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter_isUsed)PRINT_iso1DC_EVStatusType(status);
 
     //BulkChargingComplete
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete = %d (DEC)\n",
@@ -4060,7 +4035,6 @@ void PRINT_XML_DOC_ISO1_PowerDeliveryReq(struct iso1EXIDocument *exi_doc_ISO1)
     DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PowerDeliveryReq (%d-th)\n", cnt);
 }
 
-
 /*===========================================================================
 FUNCTION: PRINT_XML_DOC_DIN_CurrentDemandReq
 DESCRIPTION:
@@ -4942,67 +4916,67 @@ void PRINT_iso1DC_EVErrorCodeType(struct iso1DC_EVStatusType *status)
     {
         case iso1DC_EVErrorCodeType_NO_ERROR:                           // = 0,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NO_ERROR)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NO_ERROR)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_RESSTemperatureInhibit:      // = 1,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_RESSTemperatureInhibit)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_RESSTemperatureInhibit)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_EVShiftPosition:             // = 2,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVShiftPosition)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVShiftPosition)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_ChargerConnectorLockFault:   // = 3,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(ChargerConnectorLockFault)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(ChargerConnectorLockFault)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_EVRESSMalfunction:           // = 4,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVRESSMalfunction)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVRESSMalfunction)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_ChargingCurrentdifferential: // = 5,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingCurrentdifferential)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingCurrentdifferential)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_ChargingVoltageOutOfRange:   // = 6,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingVoltageOutOfRange)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingVoltageOutOfRange)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_Reserved_A:                         // = 7,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_A)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_A)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_Reserved_B:                         // = 8,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_B)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_B)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_Reserved_C:                         // = 9,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_C)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_C)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_FAILED_ChargingSystemIncompatibility:// = 10,
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingSystemIncompatibility)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingSystemIncompatibility)\n");
             break;
         }
     	case iso1DC_EVErrorCodeType_NoData:                             // = 11
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NoData)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NoData)\n");
             break;
         }
         default:
         {
-            DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] Unexpected iso1 EVErrorCode)");
+            DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] Unexpected iso1 EVErrorCode)\n");
             break;
         }
     }

+ 7 - 0
EVSE/Projects/DS60-120/Apps/FactoryConfig.c

@@ -102,9 +102,16 @@ void CustomChange(char *custom)
 {
 	if (strcmp(custom, "C0") == EQUAL)
 	{
+		// Bosch
 		SysConfig.AuthorisationMode = AUTH_MODE_DISABLE;
 		SysConfig.isRFID = 0;
 	}
+	else if (strcmp(custom, "N0") == EQUAL ||
+		strcmp(custom, "N1") == EQUAL)
+	{
+		// Noodoe (Shell)
+		SysConfig.isAPP = 0;
+	}
 }
 
 /**************************************************************************************/

+ 315 - 0
EVSE/Projects/DS60-120/Apps/cbmp.c

@@ -0,0 +1,315 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "cbmp.h"
+
+// Constants
+
+#define BITS_PER_BYTE 8
+
+#define BLUE 0
+#define GREEN 1
+#define RED 2
+#define ALPHA 3
+
+#define PIXEL_ARRAY_START_BYTES 4
+#define PIXEL_ARRAY_START_OFFSET 10
+
+#define WIDTH_BYTES 4
+#define WIDTH_OFFSET 18
+
+#define HEIGHT_BYTES 4
+#define HEIGHT_OFFSET 22
+
+#define DEPTH_BYTES 2
+#define DEPTH_OFFSET 28
+
+// Private function declarations
+
+void _throw_error(char* message);
+unsigned int _get_int_from_buffer(unsigned int bytes, 
+                                  unsigned int offset, 
+                                  unsigned char* buffer);
+unsigned int _get_file_byte_number(FILE* fp);
+unsigned char* _get_file_byte_contents(FILE* fp, unsigned int file_byte_number);
+int _validate_file_type(unsigned char* file_byte_contents);
+int _validate_depth(unsigned int depth);
+unsigned int _get_pixel_array_start(unsigned char* file_byte_contents);
+int _get_width(unsigned char* file_byte_contents);
+int _get_height(unsigned char* file_byte_contents);
+unsigned int _get_depth(unsigned char* file_byte_contents);
+void _update_file_byte_contents(BMP* bmp, int index, int offset, int channel);
+void _populate_pixel_array(BMP* bmp);
+void _map(BMP* bmp, void (*f)(BMP* bmp, int, int, int));
+void _get_pixel(BMP* bmp, int index, int offset, int channel);
+
+// Public function implementations
+
+BMP* bopen(char* file_path)
+{
+    FILE* fp = fopen(file_path, "rb");
+  
+    if (fp == NULL)
+    {
+        perror("Error opening file");
+        exit(EXIT_FAILURE);
+    }
+
+    BMP* bmp = (BMP*) malloc(sizeof(BMP));
+    bmp->file_byte_number = _get_file_byte_number(fp);
+    bmp->file_byte_contents = _get_file_byte_contents(fp, bmp->file_byte_number);
+    fclose(fp);
+
+    if(!_validate_file_type(bmp->file_byte_contents))
+    {
+        _throw_error("Invalid file type");
+    }
+
+    bmp->pixel_array_start = _get_pixel_array_start(bmp->file_byte_contents);
+
+    bmp->width = _get_width(bmp->file_byte_contents);
+    bmp->height = _get_height(bmp->file_byte_contents);
+    bmp->depth = _get_depth(bmp->file_byte_contents);
+
+    if(!_validate_depth(bmp->depth))
+    {
+        _throw_error("Invalid file depth");
+    }
+
+    _populate_pixel_array(bmp);
+
+    return bmp;
+}
+
+BMP* b_deep_copy(BMP* to_copy)
+{
+    BMP* copy = (BMP*) malloc(sizeof(BMP));
+    copy->file_byte_number = to_copy->file_byte_number;
+    copy->pixel_array_start = to_copy->pixel_array_start;
+    copy->width = to_copy->width;
+    copy->height = to_copy->height;
+    copy->depth = to_copy->depth;
+
+    copy->file_byte_contents = (unsigned char*) malloc(copy->file_byte_number * sizeof(unsigned char));
+
+    unsigned int i;
+    for (i = 0; i < copy->file_byte_number; i++)
+    {
+        copy->file_byte_contents[i] = to_copy->file_byte_contents[i];
+    }
+
+    copy->pixels = (pixel*) malloc(copy->width * copy->height * sizeof(pixel));
+
+    unsigned int x, y;
+    int index;
+    for (y = 0; y < copy->height; y++)
+    {
+        for (x = 0; x < copy->width; x++)
+        {
+            index = y * copy->width + x;
+            copy->pixels[index].red = to_copy->pixels[index].red;
+            copy->pixels[index].green = to_copy->pixels[index].green;
+            copy->pixels[index].blue = to_copy->pixels[index].blue;
+            copy->pixels[index].alpha = to_copy->pixels[index].alpha;
+        }
+    }
+
+    return copy;
+}
+
+int get_width(BMP* bmp)
+{
+    return bmp->width;
+}
+
+int get_height(BMP* bmp)
+{
+    return bmp->height;
+}
+
+unsigned int get_depth(BMP* bmp)
+{
+    return bmp->depth;
+}
+
+void get_pixel_rgb(BMP* bmp, int x, int y, unsigned char* r, unsigned char* g, unsigned char* b)
+{
+    int index = y * bmp->width + x;
+    *r = bmp->pixels[index].red;
+    *g = bmp->pixels[index].green;
+    *b = bmp->pixels[index].blue;
+}
+
+void set_pixel_rgb(BMP* bmp, int x, int y, unsigned char r, unsigned char g, unsigned char b)
+{
+    int index = y * bmp->width + x;
+    bmp->pixels[index].red = r;
+    bmp->pixels[index].green = g;
+    bmp->pixels[index].blue = b;
+}
+
+void bwrite(BMP* bmp, char* file_name)
+{
+    _map(bmp, _update_file_byte_contents);
+
+    FILE* fp = fopen(file_name, "wb");
+    fwrite(bmp->file_byte_contents, sizeof(char), bmp->file_byte_number, fp);
+    fclose(fp);
+}
+
+void bclose(BMP* bmp)
+{
+    free(bmp->pixels);
+    bmp->pixels = NULL;
+    free(bmp->file_byte_contents);
+    bmp->file_byte_contents = NULL;
+    free(bmp);
+    bmp = NULL;
+}
+
+
+// Private function implementations
+
+void _throw_error(char* message)
+{
+    fprintf(stderr, "%s\n", message);
+    exit(1);
+}
+
+unsigned int _get_int_from_buffer(unsigned int bytes, 
+                                  unsigned int offset, 
+                                  unsigned char* buffer)
+{
+    unsigned char* _buffer = (unsigned char*) malloc(bytes * sizeof(unsigned char));
+
+    unsigned int i;
+    for (i = 0; i < bytes; i++)
+    {
+        _buffer[i] = buffer[i + offset];
+    }
+
+    unsigned int value = *(unsigned int*) _buffer;
+    free(_buffer);
+    return value;
+}
+
+unsigned int _get_file_byte_number(FILE* fp)
+{
+    unsigned int byte_number;
+    fseek(fp, 0, SEEK_END);
+    byte_number = ftell(fp);
+    rewind(fp);
+    return byte_number;
+}
+
+unsigned char* _get_file_byte_contents(FILE* fp, unsigned int file_byte_number)
+{
+    unsigned char* buffer = (unsigned char*) malloc(file_byte_number * sizeof(char));
+    unsigned int result = fread(buffer, 1, file_byte_number, fp);
+
+    if (result != file_byte_number)
+    {
+        _throw_error("There was a problem reading the file");
+    }
+
+
+    return buffer;
+}
+
+int _validate_file_type(unsigned char* file_byte_contents)
+{
+    return file_byte_contents[0] == 'B' && file_byte_contents[1] == 'M';
+}
+
+int _validate_depth(unsigned int depth)
+{
+    return depth == 24 || depth == 32;
+}
+
+unsigned int _get_pixel_array_start(unsigned char* file_byte_contents)
+{
+    return _get_int_from_buffer(PIXEL_ARRAY_START_BYTES, PIXEL_ARRAY_START_OFFSET, file_byte_contents);
+}
+
+int _get_width(unsigned char* file_byte_contents)
+{
+    return (int) _get_int_from_buffer(WIDTH_BYTES, WIDTH_OFFSET, file_byte_contents);
+}
+
+int _get_height(unsigned char* file_byte_contents)
+{
+    return (int) _get_int_from_buffer(HEIGHT_BYTES, HEIGHT_OFFSET, file_byte_contents);
+}
+
+unsigned int _get_depth(unsigned char* file_byte_contents)
+{
+    return _get_int_from_buffer(DEPTH_BYTES, DEPTH_OFFSET, file_byte_contents);
+}
+
+void _update_file_byte_contents(BMP* bmp, int index, int offset, int channel)
+{
+    char value;
+    switch(channel)
+    {
+        case BLUE:
+            value = bmp->pixels[index].blue;
+            break;
+        case GREEN:
+            value = bmp->pixels[index].green;
+            break;
+        case RED:
+            value = bmp->pixels[index].red;
+            break;
+        case ALPHA:
+            value = bmp->pixels[index].alpha;
+            break;
+    }
+    bmp->file_byte_contents[offset + channel] = value;
+}
+
+void _populate_pixel_array(BMP* bmp)
+{
+    bmp->pixels = (pixel*) malloc(bmp->width * bmp->height * sizeof(pixel));
+    _map(bmp, _get_pixel);
+}
+
+void _map(BMP* bmp, void (*f)(BMP*, int, int, int))
+{
+    int channels = bmp->depth / (sizeof(unsigned char) * BITS_PER_BYTE);
+    int row_size = ((int) (bmp->depth * bmp->width + 31) / 32) * 4;
+    int padding = row_size - bmp->width * channels;
+
+    int c;
+    unsigned int x, y, index, offset;
+    for (y = 0; y < bmp->height; y++)
+    {
+        for (x = 0; x < bmp->width; x++)
+        {
+            index = y * bmp->width + x;
+            offset = bmp->pixel_array_start + index * channels + y * padding;
+            for (c = 0; c < channels; c++)
+            {
+                (*f)(bmp, index, offset, c);
+            }
+        }
+    }
+}
+
+void _get_pixel(BMP* bmp, int index, int offset, int channel)
+{
+    unsigned char value = _get_int_from_buffer(sizeof(unsigned char), offset + channel, bmp->file_byte_contents);
+    switch(channel)
+    {
+        case BLUE:
+            bmp->pixels[index].blue = value;
+            break;
+        case GREEN:
+            bmp->pixels[index].green = value;
+            break;
+        case RED:
+            bmp->pixels[index].red = value;
+            break;
+        case ALPHA:
+            bmp->pixels[index].alpha = value;
+            break;
+    }
+}

+ 54 - 0
EVSE/Projects/DS60-120/Apps/cbmp.h

@@ -0,0 +1,54 @@
+#ifndef CBMP_CBMP_H
+#define CBMP_CBMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Pixel structure
+// Not meant to be edited directly
+// Please use the API
+
+typedef struct pixel_data
+{
+    unsigned char red;
+    unsigned char green;
+    unsigned char blue;
+    unsigned char alpha;
+} pixel;
+
+// BMP structure
+// Not meant to be edited directly
+// Please use the API
+
+typedef struct BMP_data
+{
+    unsigned int file_byte_number;
+    unsigned char* file_byte_contents;
+
+    unsigned int pixel_array_start;
+
+    unsigned int width;
+    unsigned int height;
+    unsigned int depth;
+
+    pixel* pixels;
+} BMP;
+
+// Public function declarations
+
+BMP* bopen(char* file_path);
+BMP* b_deep_copy(BMP* to_copy);
+int get_width(BMP* bmp);
+int get_height(BMP* bmp);
+unsigned int get_depth(BMP* bmp);
+void get_pixel_rgb(BMP* bmp, int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
+void set_pixel_rgb(BMP* bmp, int x, int y, unsigned char r, unsigned char g, unsigned char b);
+void bwrite(BMP* bmp, char* file_name);
+void bclose(BMP* bmp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // CBMP_CBMP_H

+ 2 - 1
EVSE/Projects/DS60-120/Apps/main.c

@@ -1746,7 +1746,8 @@ void GetFirmwareVersion()
 
 	if (strcmp(_buf, "PN") == EQUAL ||
 			strcmp(_buf, "N7") == EQUAL ||
-			strcmp(_buf, "NX") == EQUAL)
+			strcmp(_buf, "NX") == EQUAL ||
+			strcmp(_buf, "OL") == EQUAL)
 		ShmDcCommonData->ShowLogoFlag = NO;
 	else
 		ShmDcCommonData->ShowLogoFlag = YES;

文件差異過大導致無法顯示
+ 3 - 892
EVSE/rootfs/root/cacert.pem


部分文件因文件數量過多而無法顯示