hardsploit_gui 2.3 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -22
- data/Rakefile +1 -1
- data/bin/hardsploit_gui +3 -3
- data/lib/Firmwares/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/Firmwares/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/SPI/SPI_SNIFFER/HARDSPLOIT_FIRMWARE_FPGA_SPI_SNIFFER.rpd +0 -0
- data/lib/Firmwares/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/UART/UART_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_UART_INTERACT.rpd +0 -0
- data/lib/Firmwares/FPGA/VersionFPGA.rb +5 -5
- data/lib/Firmwares/UC/VersionUC.rb +12 -12
- data/lib/HardsploitAPI/Core/HardsploitAPI.rb +210 -210
- data/lib/HardsploitAPI/Core/HardsploitAPI_CONSTANT.rb +150 -150
- data/lib/HardsploitAPI/Core/HardsploitAPI_ERROR.rb +109 -109
- data/lib/HardsploitAPI/Core/HardsploitAPI_FIRMWARE.rb +305 -305
- data/lib/HardsploitAPI/Core/HardsploitAPI_PROGRESS.rb +28 -28
- data/lib/HardsploitAPI/Core/HardsploitAPI_USB_COMMUNICATION.rb +166 -166
- data/lib/HardsploitAPI/Modules/I2C/HardsploitAPI_I2C.rb +356 -356
- data/lib/HardsploitAPI/Modules/NO_MUX_PARALLEL_MEMORY/HardsploitAPI_NO_MUX_PARALLEL_MEMORY.rb +206 -206
- data/lib/HardsploitAPI/Modules/NRF24L01/HardsploitAPI_NRF24L01.rb +306 -306
- data/lib/HardsploitAPI/Modules/SPI/HardsploitAPI_SPI.rb +340 -340
- data/lib/HardsploitAPI/Modules/SPI_SNIFFER/HardsploitAPI_SPI_SNIFFER.rb +83 -83
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD.rb +367 -367
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_DEBUG.rb +89 -89
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_MEM_AP.rb +61 -61
- data/lib/HardsploitAPI/Modules/SWD/HardsploitAPI_SWD_STM32.rb +121 -121
- data/lib/HardsploitAPI/Modules/TEST/HardsploitAPI_TEST_INTERACT.rb +98 -98
- data/lib/HardsploitAPI/Modules/UART/HardsploitAPI_UART.rb +196 -196
- data/lib/Hardsploit_gui.rb +96 -96
- data/lib/LICENSE.txt +674 -674
- data/lib/README.md +22 -22
- data/lib/TRADEMARK +2 -2
- data/lib/class/Chip_editor.rb +304 -304
- data/lib/class/Chip_management.rb +496 -496
- data/lib/class/Command_editor.rb +216 -216
- data/lib/class/Command_table.rb +233 -233
- data/lib/class/Console.rb +26 -26
- data/lib/class/ErrorMsg.rb +312 -312
- data/lib/class/Export.rb +140 -140
- data/lib/class/Export_manager.rb +124 -124
- data/lib/class/Firmware.rb +70 -70
- data/lib/class/Generic_commands.rb +260 -260
- data/lib/class/{i2c → I2C}/I2c_command.rb +51 -51
- data/lib/class/{i2c → I2C}/I2c_export.rb +95 -95
- data/lib/class/{i2c → I2C}/I2c_import.rb +117 -117
- data/lib/class/{i2c → I2C}/I2c_scanner.rb +114 -114
- data/lib/class/{i2c → I2C}/I2c_settings.rb +148 -148
- data/lib/class/Import.rb +193 -193
- data/lib/class/{parallel → PARALLEL}/Parallel_export.rb +118 -118
- data/lib/class/{parallel → PARALLEL}/Parallel_import.rb +113 -113
- data/lib/class/{parallel → PARALLEL}/Parallel_settings.rb +81 -81
- data/lib/class/Progress_bar.rb +32 -32
- data/lib/class/{spi → SPI}/Spi_export.rb +108 -108
- data/lib/class/{spi → SPI}/Spi_import.rb +159 -159
- data/lib/class/{spi → SPI}/Spi_settings.rb +108 -108
- data/lib/class/{spi → SPI}/Spi_sniffer.rb +101 -101
- data/lib/class/Signal_mapper.rb +120 -120
- data/lib/class/Wire_helper.rb +230 -230
- data/lib/class/swd/Swd.rb +125 -125
- data/lib/class/swd/Swd_scanner.rb +121 -121
- data/lib/class/swd/Swd_settings.rb +76 -76
- data/lib/class/uart/Uart_baudrate.rb +62 -62
- data/lib/class/uart/Uart_console.rb +115 -115
- data/lib/class/uart/Uart_settings.rb +102 -102
- data/lib/db/associations.rb +138 -138
- data/lib/db/database.rb +4 -4
- data/lib/db/development.sqlite3 +0 -0
- data/lib/db/migrate/004_create_manufacturers.rb +13 -13
- data/lib/db/migrate/005_create_packages.rb +13 -13
- data/lib/db/migrate/006_create_chip_types.rb +11 -11
- data/lib/db/migrate/007_create_buses.rb +11 -11
- data/lib/db/migrate/008_create_signals.rb +14 -14
- data/lib/db/migrate/009_create_chips.rb +25 -25
- data/lib/db/migrate/010_create_commands.rb +21 -21
- data/lib/db/migrate/011_create_bytes.rb +19 -19
- data/lib/db/migrate/012_create_i2c_settings.rb +21 -21
- data/lib/db/migrate/013_create_spi_settings.rb +26 -26
- data/lib/db/migrate/014_create_parallel_settings.rb +21 -21
- data/lib/db/migrate/015_create_pins.rb +19 -19
- data/lib/db/migrate/016_create_uses.rb +17 -17
- data/lib/db/migrate/017_create_swd_settings.rb +19 -19
- data/lib/db/migrate/018_create_uart_settings.rb +22 -22
- data/lib/db/schema.rb +157 -157
- data/lib/db/seeds.rb +161 -161
- data/lib/gui/gui_chip_editor.rb +349 -349
- data/lib/gui/gui_chip_management.rb +377 -377
- data/lib/gui/gui_command_editor.rb +219 -219
- data/lib/gui/gui_export.rb +132 -132
- data/lib/gui/gui_export_manager.rb +93 -93
- data/lib/gui/gui_generic_commands.rb +202 -202
- data/lib/gui/gui_generic_export.rb +164 -164
- data/lib/gui/gui_generic_import.rb +142 -142
- data/lib/gui/gui_i2c_command.rb +116 -116
- data/lib/gui/gui_i2c_settings.rb +230 -230
- data/lib/gui/gui_import.rb +131 -131
- data/lib/gui/gui_parallel_settings.rb +195 -195
- data/lib/gui/gui_progress_bar.rb +85 -85
- data/lib/gui/gui_signal_mapper.rb +121 -121
- data/lib/gui/gui_signal_scanner.rb +146 -146
- data/lib/gui/gui_spi_import.rb +126 -126
- data/lib/gui/gui_spi_settings.rb +313 -313
- data/lib/gui/gui_spi_sniffer.rb +112 -112
- data/lib/gui/gui_swd_settings.rb +166 -166
- data/lib/gui/gui_uart_baudrate.rb +114 -114
- data/lib/gui/gui_uart_console.rb +164 -164
- data/lib/gui/gui_uart_settings.rb +243 -243
- data/lib/gui/gui_wire_helper.rb +99 -99
- data/lib/gui_designer/gui_chip_editor.ui +549 -549
- data/lib/gui_designer/gui_chip_management.ui +886 -886
- data/lib/gui_designer/gui_command_editor.ui +350 -350
- data/lib/gui_designer/gui_export.ui +171 -171
- data/lib/gui_designer/gui_export_manager.ui +115 -115
- data/lib/gui_designer/gui_generic_commands.ui +342 -342
- data/lib/gui_designer/gui_generic_export.ui +202 -202
- data/lib/gui_designer/gui_generic_import.ui +165 -165
- data/lib/gui_designer/gui_i2c_command.ui +148 -148
- data/lib/gui_designer/gui_i2c_settings.ui +292 -292
- data/lib/gui_designer/gui_import.ui +168 -168
- data/lib/gui_designer/gui_parallel_settings.ui +247 -247
- data/lib/gui_designer/gui_progress_bar.ui +86 -86
- data/lib/gui_designer/gui_signal_mapper.ui +179 -179
- data/lib/gui_designer/gui_signal_scanner.ui +261 -261
- data/lib/gui_designer/gui_spi_settings.ui +446 -446
- data/lib/gui_designer/gui_spi_sniffer.ui +156 -156
- data/lib/gui_designer/gui_swd_settings.ui +189 -189
- data/lib/gui_designer/gui_uart_baudrate.ui +161 -161
- data/lib/gui_designer/gui_uart_console.ui +284 -284
- data/lib/gui_designer/gui_uart_settings.ui +280 -280
- data/lib/gui_designer/gui_wire_helper.ui +117 -117
- data/lib/images/search.png +0 -0
- data/lib/logs/error.log +0 -63
- data/lib/models/bus.rb +19 -19
- data/lib/models/byte.rb +29 -29
- data/lib/models/chip.rb +41 -41
- data/lib/models/chip_type.rb +14 -14
- data/lib/models/command.rb +20 -20
- data/lib/models/i2c_setting.rb +41 -41
- data/lib/models/manufacturer.rb +14 -14
- data/lib/models/package.rb +26 -26
- data/lib/models/parallel_setting.rb +37 -37
- data/lib/models/pin.rb +14 -14
- data/lib/models/signall.rb +20 -20
- data/lib/models/spi_setting.rb +67 -67
- data/lib/models/swd_setting.rb +25 -25
- data/lib/models/uart_setting.rb +52 -52
- data/lib/models/use.rb +6 -6
- data/lib/startHardsploit.rb +10 -10
- metadata +14 -14
data/lib/class/Wire_helper.rb
CHANGED
@@ -1,230 +1,230 @@
|
|
1
|
-
#===================================================
|
2
|
-
# Hardsploit GUI - By Opale Security
|
3
|
-
# www.opale-security.com || www.hardsploit.io
|
4
|
-
# License: GNU General Public License v3
|
5
|
-
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
|
-
#===================================================
|
7
|
-
|
8
|
-
require_relative '../gui/gui_wire_helper'
|
9
|
-
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
-
|
11
|
-
class Wire_helper < Qt::Widget
|
12
|
-
slots 'rotate_scene()'
|
13
|
-
|
14
|
-
def initialize(chip)
|
15
|
-
super()
|
16
|
-
@wire_helper_gui = Ui_Wire_helper.new
|
17
|
-
centerWindow(self)
|
18
|
-
@wire_helper_gui.setupUi(self)
|
19
|
-
@chip = chip
|
20
|
-
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
21
|
-
@scene = Qt::GraphicsScene.new
|
22
|
-
@wire_helper_gui.lbl_chip.setText("Your chip (#{chip.reference}):")
|
23
|
-
Package.find_by(id: chip.package_id).shape.zero? ? draw_square : draw_rect
|
24
|
-
@wire_helper_gui.gView.setScene(@scene)
|
25
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
26
|
-
ErrorMsg.new.hardsploit_not_found
|
27
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
28
|
-
ErrorMsg.new.usb_error
|
29
|
-
rescue Exception => msg
|
30
|
-
ErrorMsg.new.unknown(msg)
|
31
|
-
end
|
32
|
-
|
33
|
-
def closeEvent(event)
|
34
|
-
HardsploitAPI.instance.setWiringLeds(value: 0xFF00FF00FF00FF00)
|
35
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
36
|
-
ErrorMsg.new.hardsploit_not_found
|
37
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
38
|
-
ErrorMsg.new.usb_error
|
39
|
-
rescue Exception => msg
|
40
|
-
ErrorMsg.new.unknown(msg)
|
41
|
-
end
|
42
|
-
|
43
|
-
def rotate_scene
|
44
|
-
@wire_helper_gui.gView.rotate(90)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def draw_square
|
49
|
-
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
50
|
-
pin_by_side = total_pin_nbr / 4
|
51
|
-
cHeight = 14*(pin_by_side + 4) # Chip's height (+4 because we add a space equal to one pin for each corner)
|
52
|
-
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
53
|
-
y = 32
|
54
|
-
y2 = cHeight - 38
|
55
|
-
x = 32
|
56
|
-
x2 = cHeight - 38
|
57
|
-
(1..total_pin_nbr).each do |i|
|
58
|
-
# Face 1
|
59
|
-
if i <= pin_by_side
|
60
|
-
ySig = y
|
61
|
-
yNum = y
|
62
|
-
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
63
|
-
y = y + 14 # Space between each pin
|
64
|
-
elsif i > pin_by_side && i <= total_pin_nbr / 2
|
65
|
-
# Face 2
|
66
|
-
xSig2 = x
|
67
|
-
xNum2 = x
|
68
|
-
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, cHeight + 55, xNum2 - 12, cHeight, x, cHeight, 6, 20, true)
|
69
|
-
x = x + 14
|
70
|
-
elsif i > total_pin_nbr / 2 && i <= (total_pin_nbr - (pin_by_side))
|
71
|
-
# Face 3
|
72
|
-
xSig = cHeight + 24
|
73
|
-
ySig = y2
|
74
|
-
yNum = y2
|
75
|
-
|
76
|
-
if i < 10
|
77
|
-
xNum = cHeight - 20
|
78
|
-
elsif i >= 10 && i < 100
|
79
|
-
xNum = cHeight - 25
|
80
|
-
else
|
81
|
-
xNum = cHeight - 35
|
82
|
-
end
|
83
|
-
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
84
|
-
y2 = y2 - 14
|
85
|
-
else
|
86
|
-
# Face 4
|
87
|
-
xSig2 = x2
|
88
|
-
xNum2 = x2
|
89
|
-
|
90
|
-
if i < 10
|
91
|
-
yNum2 = 20
|
92
|
-
elsif i >= 10 && i < 100
|
93
|
-
yNum2 = 30
|
94
|
-
else
|
95
|
-
yNum2 = 40
|
96
|
-
end
|
97
|
-
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, -20, xNum2 - 12, yNum2, x2, 0, 6, -20, true)
|
98
|
-
x2 = x2 - 14
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def draw_rect
|
104
|
-
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
105
|
-
pin_by_side = total_pin_nbr / 2
|
106
|
-
cHeight = 14 * (pin_by_side + 2) # +2 because we add a space equal to one pin for each corner
|
107
|
-
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
108
|
-
# Add the pins + text
|
109
|
-
y = 18
|
110
|
-
y2 = cHeight - 24
|
111
|
-
(1..total_pin_nbr).each do |i|
|
112
|
-
# Face 1
|
113
|
-
if i <= total_pin_nbr / 2
|
114
|
-
ySig = y
|
115
|
-
yNum = y
|
116
|
-
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
117
|
-
y = y + 14
|
118
|
-
# Face 2
|
119
|
-
else
|
120
|
-
xSig = cHeight + 24
|
121
|
-
ySig = y2
|
122
|
-
yNum = y2
|
123
|
-
|
124
|
-
if i < 10
|
125
|
-
xNum = cHeight - 20
|
126
|
-
elsif i >= 10 && i < 100
|
127
|
-
xNum = cHeight - 25
|
128
|
-
else
|
129
|
-
xNum = cHeight - 35
|
130
|
-
end
|
131
|
-
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
132
|
-
y2 = y2 - 14
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
#
|
139
|
-
# Custom Item - To trigger events on the graphics text items
|
140
|
-
#
|
141
|
-
class CustomItem < Qt::GraphicsTextItem
|
142
|
-
|
143
|
-
def setPin(upin, api_value)
|
144
|
-
@UPin = upin
|
145
|
-
@api_value = api_value
|
146
|
-
end
|
147
|
-
|
148
|
-
def boundingRect
|
149
|
-
rect = Qt::RectF.new
|
150
|
-
rect.setHeight(20)
|
151
|
-
rect.setWidth(65)
|
152
|
-
rect.setTop(5)
|
153
|
-
return rect
|
154
|
-
end
|
155
|
-
|
156
|
-
def mousePressEvent(event)
|
157
|
-
pin = self.instance_variable_get('@UPin')
|
158
|
-
pin.setColor
|
159
|
-
pin.instance_variable_get('@signalTxt').clearFocus
|
160
|
-
pin.instance_variable_get('@nbrTxt').clearFocus
|
161
|
-
return false if @api_value == 'NA'
|
162
|
-
pin_group = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
|
163
|
-
hardsploit_pin_number = pin_group.index(@api_value.pin[0]) * 8 + @api_value.pin[1].to_i
|
164
|
-
HardsploitAPI.instance.setWiringLeds(value: 2**hardsploit_pin_number)
|
165
|
-
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
166
|
-
ErrorMsg.new.hardsploit_not_found
|
167
|
-
rescue HardsploitAPI::ERROR::USB_ERROR
|
168
|
-
ErrorMsg.new.usb_error
|
169
|
-
rescue Exception => msg
|
170
|
-
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
171
|
-
pin.instance_variable_get('@signalTxt').clearFocus
|
172
|
-
pin.instance_variable_get('@nbrTxt').clearFocus
|
173
|
-
end
|
174
|
-
|
175
|
-
def mouseDoubleClickEvent(event)
|
176
|
-
pin = self.instance_variable_get('@UPin')
|
177
|
-
pin.instance_variable_get('@signalTxt').clearFocus
|
178
|
-
pin.instance_variable_get('@nbrTxt').clearFocus
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
#
|
183
|
-
# UniqPin - Contain all data linked to one pin on the graphic
|
184
|
-
#
|
185
|
-
class UniqPin
|
186
|
-
def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation)
|
187
|
-
signal_name = Pin.find_by(number: pinNum, chip_id: pinChip).signall
|
188
|
-
@signalTxt = CustomItem.new(signal_name.name)
|
189
|
-
@signalTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
190
|
-
@signalTxt.setPin(self, signal_name)
|
191
|
-
@signalTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
192
|
-
@signalTxt.setX(xSig)
|
193
|
-
@signalTxt.setY(ySig)
|
194
|
-
@signalTxt.rotation = 270.00 if rotation
|
195
|
-
scene.addItem(@signalTxt)
|
196
|
-
|
197
|
-
@nbrTxt = CustomItem.new(pinNum.to_s)
|
198
|
-
@nbrTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
199
|
-
@nbrTxt.setPin(self, pinNum.to_s)
|
200
|
-
@nbrTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
201
|
-
@nbrTxt.setX(xNum)
|
202
|
-
@nbrTxt.setY(yNum)
|
203
|
-
@nbrTxt.rotation = 270.00 if rotation
|
204
|
-
scene.addItem(@nbrTxt)
|
205
|
-
@pinGraphItem = scene.addRect(xRect, yRect, wRect, hRect)
|
206
|
-
end
|
207
|
-
|
208
|
-
def setColor
|
209
|
-
# Colors
|
210
|
-
@on = Qt::Color.new(0, 0, 255)
|
211
|
-
@off = Qt::Color.new(0, 0, 0)
|
212
|
-
# Disable the pin if another pin is already enabled
|
213
|
-
$pinEnabled.unsetColor unless $pinEnabled.nil?
|
214
|
-
# Light the new pin
|
215
|
-
@nbrTxt.setDefaultTextColor(@on)
|
216
|
-
@signalTxt.setDefaultTextColor(@on)
|
217
|
-
@bold = Qt::Font.new
|
218
|
-
@bold.setBold(true)
|
219
|
-
@signalTxt.setFont(@bold)
|
220
|
-
$pinEnabled = self
|
221
|
-
end
|
222
|
-
|
223
|
-
def unsetColor
|
224
|
-
@nbrTxt.setDefaultTextColor(@off)
|
225
|
-
@signalTxt.setDefaultTextColor(@off)
|
226
|
-
@bold.setBold(false)
|
227
|
-
@signalTxt.setFont(@bold)
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
1
|
+
#===================================================
|
2
|
+
# Hardsploit GUI - By Opale Security
|
3
|
+
# www.opale-security.com || www.hardsploit.io
|
4
|
+
# License: GNU General Public License v3
|
5
|
+
# License URI: http://www.gnu.org/licenses/gpl.txt
|
6
|
+
#===================================================
|
7
|
+
|
8
|
+
require_relative '../gui/gui_wire_helper'
|
9
|
+
require_relative '../HardsploitAPI/Core/HardsploitAPI'
|
10
|
+
|
11
|
+
class Wire_helper < Qt::Widget
|
12
|
+
slots 'rotate_scene()'
|
13
|
+
|
14
|
+
def initialize(chip)
|
15
|
+
super()
|
16
|
+
@wire_helper_gui = Ui_Wire_helper.new
|
17
|
+
centerWindow(self)
|
18
|
+
@wire_helper_gui.setupUi(self)
|
19
|
+
@chip = chip
|
20
|
+
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
21
|
+
@scene = Qt::GraphicsScene.new
|
22
|
+
@wire_helper_gui.lbl_chip.setText("Your chip (#{chip.reference}):")
|
23
|
+
Package.find_by(id: chip.package_id).shape.zero? ? draw_square : draw_rect
|
24
|
+
@wire_helper_gui.gView.setScene(@scene)
|
25
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
26
|
+
ErrorMsg.new.hardsploit_not_found
|
27
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
28
|
+
ErrorMsg.new.usb_error
|
29
|
+
rescue Exception => msg
|
30
|
+
ErrorMsg.new.unknown(msg)
|
31
|
+
end
|
32
|
+
|
33
|
+
def closeEvent(event)
|
34
|
+
HardsploitAPI.instance.setWiringLeds(value: 0xFF00FF00FF00FF00)
|
35
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
36
|
+
ErrorMsg.new.hardsploit_not_found
|
37
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
38
|
+
ErrorMsg.new.usb_error
|
39
|
+
rescue Exception => msg
|
40
|
+
ErrorMsg.new.unknown(msg)
|
41
|
+
end
|
42
|
+
|
43
|
+
def rotate_scene
|
44
|
+
@wire_helper_gui.gView.rotate(90)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def draw_square
|
49
|
+
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
50
|
+
pin_by_side = total_pin_nbr / 4
|
51
|
+
cHeight = 14*(pin_by_side + 4) # Chip's height (+4 because we add a space equal to one pin for each corner)
|
52
|
+
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
53
|
+
y = 32
|
54
|
+
y2 = cHeight - 38
|
55
|
+
x = 32
|
56
|
+
x2 = cHeight - 38
|
57
|
+
(1..total_pin_nbr).each do |i|
|
58
|
+
# Face 1
|
59
|
+
if i <= pin_by_side
|
60
|
+
ySig = y
|
61
|
+
yNum = y
|
62
|
+
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
63
|
+
y = y + 14 # Space between each pin
|
64
|
+
elsif i > pin_by_side && i <= total_pin_nbr / 2
|
65
|
+
# Face 2
|
66
|
+
xSig2 = x
|
67
|
+
xNum2 = x
|
68
|
+
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, cHeight + 55, xNum2 - 12, cHeight, x, cHeight, 6, 20, true)
|
69
|
+
x = x + 14
|
70
|
+
elsif i > total_pin_nbr / 2 && i <= (total_pin_nbr - (pin_by_side))
|
71
|
+
# Face 3
|
72
|
+
xSig = cHeight + 24
|
73
|
+
ySig = y2
|
74
|
+
yNum = y2
|
75
|
+
|
76
|
+
if i < 10
|
77
|
+
xNum = cHeight - 20
|
78
|
+
elsif i >= 10 && i < 100
|
79
|
+
xNum = cHeight - 25
|
80
|
+
else
|
81
|
+
xNum = cHeight - 35
|
82
|
+
end
|
83
|
+
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
84
|
+
y2 = y2 - 14
|
85
|
+
else
|
86
|
+
# Face 4
|
87
|
+
xSig2 = x2
|
88
|
+
xNum2 = x2
|
89
|
+
|
90
|
+
if i < 10
|
91
|
+
yNum2 = 20
|
92
|
+
elsif i >= 10 && i < 100
|
93
|
+
yNum2 = 30
|
94
|
+
else
|
95
|
+
yNum2 = 40
|
96
|
+
end
|
97
|
+
UniqPin.new(@scene, i, @chip.id, xSig2 - 12, -20, xNum2 - 12, yNum2, x2, 0, 6, -20, true)
|
98
|
+
x2 = x2 - 14
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def draw_rect
|
104
|
+
total_pin_nbr = Pin.where(chip_id: @chip.id).count
|
105
|
+
pin_by_side = total_pin_nbr / 2
|
106
|
+
cHeight = 14 * (pin_by_side + 2) # +2 because we add a space equal to one pin for each corner
|
107
|
+
@scene.addRect(Qt::RectF.new(0, 0, cHeight, cHeight))
|
108
|
+
# Add the pins + text
|
109
|
+
y = 18
|
110
|
+
y2 = cHeight - 24
|
111
|
+
(1..total_pin_nbr).each do |i|
|
112
|
+
# Face 1
|
113
|
+
if i <= total_pin_nbr / 2
|
114
|
+
ySig = y
|
115
|
+
yNum = y
|
116
|
+
UniqPin.new(@scene, i, @chip.id, -70, ySig - 12, 0, yNum - 12, 0, y, -20, 6, false)
|
117
|
+
y = y + 14
|
118
|
+
# Face 2
|
119
|
+
else
|
120
|
+
xSig = cHeight + 24
|
121
|
+
ySig = y2
|
122
|
+
yNum = y2
|
123
|
+
|
124
|
+
if i < 10
|
125
|
+
xNum = cHeight - 20
|
126
|
+
elsif i >= 10 && i < 100
|
127
|
+
xNum = cHeight - 25
|
128
|
+
else
|
129
|
+
xNum = cHeight - 35
|
130
|
+
end
|
131
|
+
UniqPin.new(@scene, i, @chip.id, xSig, ySig - 12, xNum, yNum - 12, cHeight, y2, 20, 6, false)
|
132
|
+
y2 = y2 - 14
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
#
|
139
|
+
# Custom Item - To trigger events on the graphics text items
|
140
|
+
#
|
141
|
+
class CustomItem < Qt::GraphicsTextItem
|
142
|
+
|
143
|
+
def setPin(upin, api_value)
|
144
|
+
@UPin = upin
|
145
|
+
@api_value = api_value
|
146
|
+
end
|
147
|
+
|
148
|
+
def boundingRect
|
149
|
+
rect = Qt::RectF.new
|
150
|
+
rect.setHeight(20)
|
151
|
+
rect.setWidth(65)
|
152
|
+
rect.setTop(5)
|
153
|
+
return rect
|
154
|
+
end
|
155
|
+
|
156
|
+
def mousePressEvent(event)
|
157
|
+
pin = self.instance_variable_get('@UPin')
|
158
|
+
pin.setColor
|
159
|
+
pin.instance_variable_get('@signalTxt').clearFocus
|
160
|
+
pin.instance_variable_get('@nbrTxt').clearFocus
|
161
|
+
return false if @api_value == 'NA'
|
162
|
+
pin_group = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
|
163
|
+
hardsploit_pin_number = pin_group.index(@api_value.pin[0]) * 8 + @api_value.pin[1].to_i
|
164
|
+
HardsploitAPI.instance.setWiringLeds(value: 2**hardsploit_pin_number)
|
165
|
+
rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND
|
166
|
+
ErrorMsg.new.hardsploit_not_found
|
167
|
+
rescue HardsploitAPI::ERROR::USB_ERROR
|
168
|
+
ErrorMsg.new.usb_error
|
169
|
+
rescue Exception => msg
|
170
|
+
HardsploitAPI.instance.setWiringLeds(value: 0x0000000000000000)
|
171
|
+
pin.instance_variable_get('@signalTxt').clearFocus
|
172
|
+
pin.instance_variable_get('@nbrTxt').clearFocus
|
173
|
+
end
|
174
|
+
|
175
|
+
def mouseDoubleClickEvent(event)
|
176
|
+
pin = self.instance_variable_get('@UPin')
|
177
|
+
pin.instance_variable_get('@signalTxt').clearFocus
|
178
|
+
pin.instance_variable_get('@nbrTxt').clearFocus
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
#
|
183
|
+
# UniqPin - Contain all data linked to one pin on the graphic
|
184
|
+
#
|
185
|
+
class UniqPin
|
186
|
+
def initialize(scene, pinNum, pinChip, xSig, ySig, xNum, yNum, xRect, yRect, wRect, hRect, rotation)
|
187
|
+
signal_name = Pin.find_by(number: pinNum, chip_id: pinChip).signall
|
188
|
+
@signalTxt = CustomItem.new(signal_name.name)
|
189
|
+
@signalTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
190
|
+
@signalTxt.setPin(self, signal_name)
|
191
|
+
@signalTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
192
|
+
@signalTxt.setX(xSig)
|
193
|
+
@signalTxt.setY(ySig)
|
194
|
+
@signalTxt.rotation = 270.00 if rotation
|
195
|
+
scene.addItem(@signalTxt)
|
196
|
+
|
197
|
+
@nbrTxt = CustomItem.new(pinNum.to_s)
|
198
|
+
@nbrTxt.cursor = Qt::Cursor.new(Qt::PointingHandCursor)
|
199
|
+
@nbrTxt.setPin(self, pinNum.to_s)
|
200
|
+
@nbrTxt.setTextInteractionFlags(Qt::TextSelectableByMouse)
|
201
|
+
@nbrTxt.setX(xNum)
|
202
|
+
@nbrTxt.setY(yNum)
|
203
|
+
@nbrTxt.rotation = 270.00 if rotation
|
204
|
+
scene.addItem(@nbrTxt)
|
205
|
+
@pinGraphItem = scene.addRect(xRect, yRect, wRect, hRect)
|
206
|
+
end
|
207
|
+
|
208
|
+
def setColor
|
209
|
+
# Colors
|
210
|
+
@on = Qt::Color.new(0, 0, 255)
|
211
|
+
@off = Qt::Color.new(0, 0, 0)
|
212
|
+
# Disable the pin if another pin is already enabled
|
213
|
+
$pinEnabled.unsetColor unless $pinEnabled.nil?
|
214
|
+
# Light the new pin
|
215
|
+
@nbrTxt.setDefaultTextColor(@on)
|
216
|
+
@signalTxt.setDefaultTextColor(@on)
|
217
|
+
@bold = Qt::Font.new
|
218
|
+
@bold.setBold(true)
|
219
|
+
@signalTxt.setFont(@bold)
|
220
|
+
$pinEnabled = self
|
221
|
+
end
|
222
|
+
|
223
|
+
def unsetColor
|
224
|
+
@nbrTxt.setDefaultTextColor(@off)
|
225
|
+
@signalTxt.setDefaultTextColor(@off)
|
226
|
+
@bold.setBold(false)
|
227
|
+
@signalTxt.setFont(@bold)
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|