Sensor test using dbus-send method only

Removed REST methods related to sensor test

IPMItool is not required to run sensor test

Partly Resolves openbmc/openbmc-test-automation#40

Change-Id: I8f0fc6778b13d6d447d0a10bdc9f8bc9892df6fc
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index e043a9e..6e50e8b 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -1,16 +1,26 @@
 *** Settings ***
 Documentation   This module is for IPMI client for copying ipmitool to
-...             openbmc box and execute ipmitool commands.
-
+...             openbmc box and execute ipmitool IPMI standard
+...             command. IPMI raw command will use dbus-send command
 Resource        ../lib/resource.txt
 Resource        ../lib/connection_client.robot
+Library         String
+
+*** Variables ***
+${dbusHostIpmicmd1} =   dbus-send --system  /org/openbmc/HostIpmi/1
+${dbusHostIpmiCmdReceivedMsg} =   org.openbmc.HostIpmi.ReceivedMessage
+${netfnByte} =    ${EMPTY}
+${cmdByte}   =    ${EMPTY}
+${arrayByte} =       array:byte:
 
 *** Keywords ***
 Run IPMI Command
     [arguments]    ${args}
-    Copy ipmitool
-    ${output}   ${stderr}=  Execute Command    /tmp/ipmitool -I dbus raw ${args}  return_stderr=True
-    Should Be Empty 	${stderr}
+    ${valueinBytes} =   Byte Conversion  ${args}
+    ${cmd} =   Catenate   ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
+    ${cmd} =   Catenate   ${cmd} ${valueinBytes}
+    ${output}   ${stderr}=  Execute Command  ${cmd}  return_stderr=True
+    Should Be Empty      ${stderr}
     set test variable    ${OUTPUT}     "${output}"
 
 Run IPMI Standard Command
@@ -20,6 +30,67 @@
     Should Be Equal    ${output}    ${0}    msg=${stderr}
     [return]    ${stdout}
 
+Byte Conversion
+    [Documentation]   Byte Conversion method receives IPMI RAW commands as
+    ...               argument in string format.
+    ...               Sample argument is as follows
+    ...               "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
+    ...               0x00"
+    ...               IPMI RAW command format is as follows
+    ...               <netfn Byte> <cmd Byte> <Data Bytes..>
+    ...               This method converts IPMI command format into
+    ...               dbus command format  as follows
+    ...               <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
+    ...               <array:byte:data>
+    ...               Sample dbus  Host IPMI Received Message argument
+    ...               byte:0x00 byte:0x04 byte:0x00 byte:0x30
+    ...               array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
+    [arguments]     ${args}
+    ${argLength} =   Get Length  ${args}
+    Set Global Variable  ${arrayByte}   array:byte:
+    @{listargs} =   Split String  ${args}
+    ${index} =   Set Variable   ${0}
+    :FOR   ${word}   in   @{listargs}
+    \    Run Keyword if   ${index} == 0   Set NetFn Byte  ${word}
+    \    Run Keyword if   ${index} == 1   Set Cmd Byte    ${word}
+    \    Run Keyword if   ${index} > 1    Set Array Byte  ${word}
+    \    ${index} =    Set Variable    ${index + 1}
+    ${length} =   Get Length  ${arrayByte}
+    ${length} =   Evaluate  ${length} - 1
+    ${arrayByteLocal} =  Get Substring  ${arrayByte}  0   ${length}
+    Set Global Variable  ${arrayByte}   ${arrayByteLocal}
+    ${valueinBytesWithArray} =   Catenate  byte:0x00   ${netfnByte}  byte:0x00
+    ${valueinBytesWithArray} =   Catenate  ${valueinBytesWithArray}  ${cmdByte}
+    ${valueinBytesWithArray} =   Catenate  ${valueinBytesWithArray} ${arrayByte}
+    ${valueinBytesWithoutArray} =   Catenate  byte:0x00 ${netfnByte}  byte:0x00
+    ${valueinBytesWithoutArray} =   Catenate  ${valueinBytesWithoutArray} ${cmdByte}
+#   To Check scenario for smaller IPMI raw commands with only 2 arguments
+#   instead of usual 12 arguments.
+#   Sample small IPMI raw command: Run IPMI command 0x06 0x36
+#   If IPMI raw argument length is only 9 then return value in bytes without
+#   array population.
+#   Equivalent dbus-send argument for smaller IPMI raw command:
+#   byte:0x00 byte:0x06 byte:0x00 byte:0x36
+    Run Keyword if   ${argLength} == 9     Return from Keyword    ${valueinBytesWithoutArray}
+    [return]    ${valueinBytesWithArray}
+
+
+Set NetFn Byte
+   [arguments]    ${word}
+   ${netfnByteLocal} =  Catenate   byte:${word}
+   Set Global Variable  ${netfnByte}  ${netfnByteLocal}
+
+Set Cmd Byte
+   [arguments]    ${word}
+   ${cmdByteLocal} =  Catenate   byte:${word}
+   Set Global Variable  ${cmdByte}  ${cmdByteLocal}
+
+Set Array Byte
+   [arguments]    ${word}
+   ${arrayByteLocal} =   Catenate   SEPARATOR=  ${arrayByte}  ${word}
+   ${arrayByteLocal} =   Catenate   SEPARATOR=  ${arrayByteLocal}   ,
+   Set Global Variable  ${arrayByte}   ${arrayByteLocal}
+
 Copy ipmitool
     OperatingSystem.File Should Exist   tools/ipmitool      msg=The ipmitool program could not be found in the tools directory. It is not part of the automation code by default. You must manually copy or link the correct openbmc version of the tool in to the tools directory in order to run this test suite.