Method: HardsploitAPI_PARALLEL#readByteFromMemory

Defined in:
lib/HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb

#readByteFromMemory(address) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb', line 99

def readByteFromMemory(address)
	packet = Array.new
	packet.push 0  #low byte of lenght of trame refresh automaticly before send by usb
	packet.push 0  #high byte of lenght of trame refresh automaticly before send by usb
	packet.push HardsploitAPI.lowByte(HardsploitAPI::USB_COMMAND::FPGA_COMMAND)
	packet.push HardsploitAPI.highByte(HardsploitAPI::USB_COMMAND::FPGA_COMMAND)

	packet.push 0x50 #Command RAW COMMUNICATION TO FPGA FIFO


	#16 bits
	packet.push	0
	packet.push (1500/6.66).floor


	packet.push  ((address & 0xFF000000) >> 24 ) #AddStart3
	packet.push  ((address & 0x00FF0000) >> 16 ) #AddStart2
	packet.push  ((address & 0x0000FF00) >> 8 )  #AddStart1
	packet.push  ((address & 0x000000FF) >> 0)   #AddStart0

	packet.push 0x10 #Memory read command
	packet.push  ((address & 0xFF000000) >> 24 ) #AddStart3
	packet.push  ((address & 0x00FF0000) >> 16 ) #AddStop2
	packet.push  ((address & 0x0000FF00) >> 8 )  #AddStop1
	packet.push  ((address & 0x000000FF) >> 0)   #AddStop0

	result = sendAndReceiveDATA(packet,1000)

	if result == USB_STATE::TIMEOUT_RECEIVE then
		return "TIMEOUT"
	else
		if result.size == 6 then
				return HardsploitAPI.BytesToInt(result[4] , result[5])
		else
			raise "BAD RESPONSE"
		end
	end
end