blob: ed02c9023d01e2763ab6aec4e856fe26cad77c40 [file] [log] [blame]
George Hung09b8cd92020-06-04 19:54:41 +08001#!/bin/bash
2
3SERVICE_NAME="xyz.openbmc_project.Inventory.Manager"
4SAS_CABLE_OBJPATH=("/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab0_prsnt"
5"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab1_prsnt"
6"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab2_prsnt"
7"/xyz/openbmc_project/inventory/system/chassis/cable/ss_cab3_prsnt")
8INTERFACE_NAME="xyz.openbmc_project.Inventory.Item"
9
10IPMI_LOG_SERVICE="xyz.openbmc_project.Logging.IPMI"
11IPMI_LOG_OBJPATH="/xyz/openbmc_project/Logging/IPMI"
12IPMI_LOG_INTERFACE="xyz.openbmc_project.Logging.IPMI"
13IPMI_LOG_FUNCT="IpmiSelAdd"
14IPMI_LOG_PARA_FORMAT="ssaybq" #5 parameters, s : string, s : string, ay : byte array, b : boolean, y : UINT16
15LOG_ERR="Cable_error(Incorrect_interconnection)"
16LOG_EVENT_DATA="3 0x01 0xff 0xfe"
17LOG_ASSERT_FLAG="true"
18LOG_DEASSERT_FLAG="false"
19LOG_GENID_FLAG="0x0020"
20cable_state=("true" "true" "true" "true")
21
22mapper wait ${SAS_CABLE_OBJPATH[0]}
23mapper wait ${SAS_CABLE_OBJPATH[1]}
24mapper wait ${SAS_CABLE_OBJPATH[2]}
25mapper wait ${SAS_CABLE_OBJPATH[3]}
26
27while true; do
28 for i in {0..3};
29 do
30 boot_status="$(busctl get-property $SERVICE_NAME ${SAS_CABLE_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')"
31
32 if [ $boot_status == "false" ] && [ ${cable_state[$i]} == "true" ];then
33 echo "Update cable $(($i+1)) state."
34 cable_state[$i]="false"
35 busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG
36 elif [ $boot_status == "true" ] && [ ${cable_state[$i]} != "true" ];then
37 echo "Update cable $(($i+1)) state."
38 cable_state[$i]="true"
39 busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT $LOG_ERR ${SAS_CABLE_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG
40 fi
41 done
42 sleep 1
43done
44
45exit 0