Method: HardsploitAPI#sendAndReceiveDATA
- Defined in:
- lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb
#sendAndReceiveDATA(packet_send, timeout) ⇒ Object
Send data and wait to receive response
packet_send
-
array of byte
timeout
-
timeout to read response (ms)
Return USB_STATE or array with response (improve soon with exception)
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb', line 102 def sendAndReceiveDATA(packet_send,timeout) time = Time.new begin sendPacket(packet_send) received_data = @dev.bulk_transfer(:endpoint=>IN_ENDPOINT, :dataIn=>USB::USB_TRAME_SIZE, :timeout=>timeout) consoleSpeed "RECEIVE #{((received_data.bytes.to_a.size/(Time.new-time))).round(2)}Bytes/s #{(received_data.bytes.to_a.size)}Bytes in #{(Time.new-time).round(4)} s" return received_data.bytes.to_a rescue LIBUSB::ERROR_NO_DEVICE raise ERROR::HARDSPLOIT_NOT_FOUND rescue raise ERROR::USB_ERROR end end |