Browse Source

2022-07-19 / ct_chen

Actions:
1. Webservice add function of reading status code flag

Files:
1. EVSE/Modularization/WebService.c
   EVSE/rootfs/var/www/get_statuscode_action.php
ct_chen 2 years ago
parent
commit
f17f9a2fed

+ 37 - 0
EVSE/Modularization/WebService.c

@@ -3098,6 +3098,43 @@ int main(int argc, char *argv[]) {
 		printf("%s\n", json_object_to_json_string(jobj4));
 		json_object_put(jobj4);
 	}
+
+	// get status code
+	if(strcmp(argv[1], "StatusCode") == 0)
+	{
+		int type = atoi(argv[2]);
+		int bytes = atoi(argv[3]);
+		int bits = atoi(argv[4]);
+		struct json_object *jobj1;
+
+		//FaultCode
+		struct json_object *FaultCode;
+		//AlarmCode
+		struct json_object *AlarmCode;
+		//InfoCode
+		struct json_object *InfoCode;
+
+		jobj1=json_object_new_object();
+
+		//FaultCode
+		if(type==1){
+			FaultCode = json_object_new_int(((ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[bytes]) >> bits) & 1);//(num >> n) & 1
+			json_object_object_add(jobj1,"FaultCode",FaultCode);
+		}
+		//AlarmCode
+		if(type==2){
+			AlarmCode = json_object_new_int(((ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[bytes]) >> bits) & 1);//(num >> n) & 1
+			json_object_object_add(jobj1,"AlarmCode",AlarmCode);
+		}
+		//InfoCode
+		if(type==3){
+			InfoCode = json_object_new_int(((ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[bytes]) >> bits) & 1);//(num >> n) & 1
+			json_object_object_add(jobj1,"InfoCode",InfoCode);
+		}
+		printf("%s\n", json_object_to_json_string(jobj1));
+		json_object_put(jobj1);
+
+	}
 	//	for(;;)
 	//	{
 

+ 28 - 0
EVSE/rootfs/var/www/get_statuscode_action.php

@@ -0,0 +1,28 @@
+<?php
+	// 設置資料類型 json,編碼格式 utf-8
+	header('Content-Type: application/json; charset=UTF-8');
+	
+	// 判斷如果是 GET 請求,則進行搜尋;如果是 POST 請求,則進行新建
+	// $_SERVER['REQUEST_METHOD'] 返回訪問頁面使用的請求方法
+	if ($_SERVER['REQUEST_METHOD'] == "GET") {
+		create();
+	} else if ($_SERVER['REQUEST_METHOD'] == "POST") {
+		create();
+	}
+
+	function create() {
+		chdir("/root");
+		exec("'./WebService' 'StatusCode' ".$_REQUEST['type']." ". $_REQUEST['bytes']." ".$_REQUEST['bits'],$output,$return_var);
+		if(count($output)==0){
+//			echo '<script>alert("Something went wrong on machine");</script>';
+			echo "Something went wrong on machine";
+			exit;
+		}
+		if(trim($output[0])=="InitShareMemory Error"){
+//			echo '<script>alert("InitShareMemory Error");</script>';
+			echo "InitShareMemory Error";
+			exit;
+		}
+		echo $output[0];
+	}
+?>

+ 0 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.byteswap.cmd

@@ -1 +0,0 @@
-cmd_MLO.byteswap := ./tools/mkimage -T omapimage -n byteswap -a 0x402F0400 -d spl/u-boot-spl.bin MLO.byteswap  >/dev/null

+ 0 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/.MLO.cmd

@@ -1 +0,0 @@
-cmd_MLO := ./tools/mkimage -T omapimage -a 0x402F0400 -d spl/u-boot-spl.bin MLO  >/dev/null