hardsploit_gui 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/bin/hardsploit_gui +3 -0
- data/lib/Firmware/FPGA/I2C/I2C_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_I2C_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/PARALLEL/NO_MUX_PARALLEL_MEMORY/HARDSPLOIT_FIRMWARE_FPGA_NO_MUX_PARALLEL_MEMORY.rpd +0 -0
- data/lib/Firmware/FPGA/SPI/SPI_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SPI_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/SWD/SWD_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_SWD_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/TEST/TEST_INTERACT/HARDSPLOIT_FIRMWARE_FPGA_TEST_INTERACT.rpd +0 -0
- data/lib/Firmware/FPGA/VersionFPGA.rb +5 -0
- data/lib/Firmware/UC/HARDSPLOIT_FIRMWARE_UC.bin +0 -0
- data/lib/Firmware/UC/VersionUC.rb +12 -0
- data/lib/HardsploitAPI/HardsploitAPI.rb +134 -0
- data/lib/HardsploitAPI/HardsploitAPI_CONSTANT.rb +145 -0
- data/lib/HardsploitAPI/HardsploitAPI_FIRMWARE.rb +311 -0
- data/lib/HardsploitAPI/HardsploitAPI_I2C.rb +218 -0
- data/lib/HardsploitAPI/HardsploitAPI_NO_MUX_PARALLELE_MEMORY.rb +229 -0
- data/lib/HardsploitAPI/HardsploitAPI_SPI.rb +179 -0
- data/lib/HardsploitAPI/HardsploitAPI_TEST_INTERACT.rb +98 -0
- data/lib/HardsploitAPI/HardsploitAPI_USB_COMMUNICATION.rb +149 -0
- data/lib/HardsploitAPI/LICENSE.txt +674 -0
- data/lib/HardsploitAPI/README.md +22 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD.rb +249 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_DEBUG.rb +102 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_MEM_AP.rb +78 -0
- data/lib/HardsploitAPI/SWD/HardsploitAPI_SWD_STM32.rb +104 -0
- data/lib/HardsploitAPI/TRADEMARK +3 -0
- data/lib/LICENSE.txt +674 -0
- data/lib/README.md +22 -0
- data/lib/TRADEMARK +3 -0
- data/lib/class/Chip_editor.rb +448 -0
- data/lib/class/Command_editor.rb +268 -0
- data/lib/class/Command_table.rb +239 -0
- data/lib/class/Console.rb +28 -0
- data/lib/class/Export_manager.rb +124 -0
- data/lib/class/Firmware.rb +29 -0
- data/lib/class/Generic_commands.rb +275 -0
- data/lib/class/HardsploitGUI.rb +462 -0
- data/lib/class/I2C/I2c_command.rb +48 -0
- data/lib/class/I2C/I2c_export.rb +121 -0
- data/lib/class/I2C/I2c_import.rb +92 -0
- data/lib/class/I2C/I2c_settings.rb +117 -0
- data/lib/class/PARALLEL/Parallel_export.rb +146 -0
- data/lib/class/PARALLEL/Parallel_import.rb +88 -0
- data/lib/class/PARALLEL/Parallel_settings.rb +102 -0
- data/lib/class/SPI/Spi_export.rb +141 -0
- data/lib/class/SPI/Spi_import.rb +112 -0
- data/lib/class/SPI/Spi_settings.rb +90 -0
- data/lib/class/Wire_helper.rb +246 -0
- data/lib/db/associations.rb +125 -0
- data/lib/db/hs.db +0 -0
- data/lib/gui/gui_chip_editor.rb +355 -0
- data/lib/gui/gui_chip_management.rb +372 -0
- data/lib/gui/gui_command_editor.rb +218 -0
- data/lib/gui/gui_export_manager.rb +93 -0
- data/lib/gui/gui_generic_commands.rb +164 -0
- data/lib/gui/gui_generic_export.rb +148 -0
- data/lib/gui/gui_generic_import.rb +126 -0
- data/lib/gui/gui_i2c_command.rb +115 -0
- data/lib/gui/gui_i2c_settings.rb +201 -0
- data/lib/gui/gui_parallel_settings.rb +194 -0
- data/lib/gui/gui_spi_import.rb +126 -0
- data/lib/gui/gui_spi_settings.rb +187 -0
- data/lib/gui/gui_wire_helper.rb +99 -0
- data/lib/gui_designer/gui_chip_editor.ui +553 -0
- data/lib/gui_designer/gui_chip_management.ui +842 -0
- data/lib/gui_designer/gui_command_editor.ui +347 -0
- data/lib/gui_designer/gui_export_manager.ui +115 -0
- data/lib/gui_designer/gui_generic_commands.ui +258 -0
- data/lib/gui_designer/gui_generic_export.ui +179 -0
- data/lib/gui_designer/gui_generic_import.ui +142 -0
- data/lib/gui_designer/gui_i2c_command.ui +145 -0
- data/lib/gui_designer/gui_i2c_settings.ui +261 -0
- data/lib/gui_designer/gui_parallel_settings.ui +244 -0
- data/lib/gui_designer/gui_processing.ui +81 -0
- data/lib/gui_designer/gui_spi_settings.ui +321 -0
- data/lib/gui_designer/gui_wire_helper.ui +117 -0
- data/lib/hardsploit.rb +122 -0
- data/lib/images/search.png +0 -0
- data/lib/logs/error.log +0 -0
- metadata +236 -0
data/lib/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Hardsploit
|
2
|
+
|
3
|
+
The essential security auditing tool for Internet of Things devices you'll need in your toolbox
|
4
|
+
|
5
|
+
### [GO TO HARDSPLOIT](http://www.hardsploit.io)
|
6
|
+
|
7
|
+
TO LEARN ABOUT IT
|
8
|
+
|
9
|
+
### [GO TO SHOP](https://www.shop-hardsploit.com)
|
10
|
+
TO BUY
|
11
|
+
|
12
|
+
### [GO TO WIKI](http://wiki.hardsploit.io)
|
13
|
+
|
14
|
+
TO UNDERSTAND HOW USE IT
|
15
|
+
|
16
|
+
### [GO TO FORUM](http://forum.hardsploit.io)
|
17
|
+
|
18
|
+
FOR SUPPORT / HELP
|
19
|
+
|
20
|
+
### [GO TO BUG TRACKER](http://issues.hardsploit.io)
|
21
|
+
|
22
|
+
FOR BUGS OR IMPROVEMENTS
|
data/lib/TRADEMARK
ADDED
@@ -0,0 +1,448 @@
|
|
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_chip_editor'
|
9
|
+
class Chip_editor < Qt::Widget
|
10
|
+
slots 'select_package()'
|
11
|
+
slots 'edit_chip()'
|
12
|
+
slots 'add_chip()'
|
13
|
+
slots 'select_manufacturer()'
|
14
|
+
slots 'select_type()'
|
15
|
+
slots 'fill_pin_table()'
|
16
|
+
slots 'filter_cbx()'
|
17
|
+
slots 'delete_cbx_element()'
|
18
|
+
|
19
|
+
def initialize(parent, chip, action)
|
20
|
+
super()
|
21
|
+
@gui_chip_editor = Ui_Chip_editor.new
|
22
|
+
centerWindow(self)
|
23
|
+
@gui_chip_editor.setupUi(self)
|
24
|
+
@parent = parent
|
25
|
+
@chip = chip
|
26
|
+
|
27
|
+
inputRestrict(@gui_chip_editor.lie_pack_name, 2)
|
28
|
+
inputRestrict(@gui_chip_editor.lie_pack_pin, 0)
|
29
|
+
inputRestrict(@gui_chip_editor.lie_manu_name, 2)
|
30
|
+
inputRestrict(@gui_chip_editor.lie_type_name, 2)
|
31
|
+
inputRestrict(@gui_chip_editor.lie_reference, 2)
|
32
|
+
inputRestrict(@gui_chip_editor.lie_description, 2)
|
33
|
+
|
34
|
+
# Combobox
|
35
|
+
# Package
|
36
|
+
package = Package.all
|
37
|
+
package.each do |p|
|
38
|
+
@gui_chip_editor.cbx_package.addItem(p.package_name)
|
39
|
+
end
|
40
|
+
# Manufacturer
|
41
|
+
manufacturer = Manufacturer.all
|
42
|
+
manufacturer.each do |p|
|
43
|
+
@gui_chip_editor.cbx_manufacturer.addItem(p.manufacturer_name)
|
44
|
+
end
|
45
|
+
# Type
|
46
|
+
c_type = CType.all
|
47
|
+
c_type.each do |p|
|
48
|
+
@gui_chip_editor.cbx_type.addItem(p.cType_name)
|
49
|
+
end
|
50
|
+
|
51
|
+
#Bus
|
52
|
+
@bus_list = Bus.all
|
53
|
+
|
54
|
+
if action != 'new'
|
55
|
+
package_name = package.find_by(package_id: @chip.chip_package).package_name
|
56
|
+
manufacturer_name = manufacturer.find_by(manufacturer_id: @chip.chip_manufacturer).manufacturer_name
|
57
|
+
c_type_name = c_type.find_by(cType_id: @chip.chip_type).cType_name
|
58
|
+
|
59
|
+
@gui_chip_editor.cbx_package.setCurrentIndex(@gui_chip_editor.cbx_package.findText(package_name))
|
60
|
+
@gui_chip_editor.lie_pack_name.setText(package_name)
|
61
|
+
@gui_chip_editor.lie_pack_name.setEnabled(false)
|
62
|
+
@gui_chip_editor.cbx_manufacturer.setCurrentIndex(@gui_chip_editor.cbx_manufacturer.findText(manufacturer_name))
|
63
|
+
@gui_chip_editor.lie_manu_name.setText(manufacturer_name)
|
64
|
+
@gui_chip_editor.lie_manu_name.setEnabled(false)
|
65
|
+
@gui_chip_editor.cbx_type.setCurrentIndex(@gui_chip_editor.cbx_type.findText(c_type_name))
|
66
|
+
@gui_chip_editor.lie_type_name.setText(c_type_name)
|
67
|
+
@gui_chip_editor.lie_type_name.setEnabled(false)
|
68
|
+
@gui_chip_editor.rbn_rectangular.setEnabled(false)
|
69
|
+
@gui_chip_editor.rbn_square.setEnabled(false)
|
70
|
+
if @chip.chip_voltage.zero?
|
71
|
+
@gui_chip_editor.rbn_5v.setChecked(true)
|
72
|
+
else
|
73
|
+
@gui_chip_editor.rbn_3v.setChecked(true)
|
74
|
+
end
|
75
|
+
package_shape = Package.find_by(package_id: @chip.chip_package).package_shape
|
76
|
+
if package_shape.zero?
|
77
|
+
@gui_chip_editor.rbn_square.setChecked(true)
|
78
|
+
else
|
79
|
+
@gui_chip_editor.rbn_rectangular.setChecked(true)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Line Edit
|
83
|
+
# Name
|
84
|
+
if action == 'edit'
|
85
|
+
@gui_chip_editor.lie_reference.setText(@chip.chip_reference)
|
86
|
+
end
|
87
|
+
# Load pin array
|
88
|
+
fill_pin_table('edit')
|
89
|
+
# Misc tab
|
90
|
+
@gui_chip_editor.lie_description.setText(@chip.chip_detail)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Array struct
|
94
|
+
@gui_chip_editor.tbl_pins.horizontalHeader.stretchLastSection = true
|
95
|
+
@gui_chip_editor.tbl_pins.verticalHeader.setVisible(false)
|
96
|
+
|
97
|
+
# Button text
|
98
|
+
if action == 'edit'
|
99
|
+
@gui_chip_editor.btn_add.setText('Edit')
|
100
|
+
Qt::Object.connect(@gui_chip_editor.btn_add, SIGNAL('clicked()'), self, SLOT('edit_chip()'))
|
101
|
+
else
|
102
|
+
@gui_chip_editor.btn_add.setText('Add')
|
103
|
+
Qt::Object.connect(@gui_chip_editor.btn_add, SIGNAL('clicked()'), self, SLOT('add_chip()'))
|
104
|
+
end
|
105
|
+
rescue Exception => msg
|
106
|
+
logger = Logger.new($logFilePath)
|
107
|
+
logger.error msg
|
108
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured when opening the chip wizard interface. Consult the log for more details').exec
|
109
|
+
end
|
110
|
+
|
111
|
+
# Control the form values
|
112
|
+
def control_form_val
|
113
|
+
error = ''
|
114
|
+
# Package
|
115
|
+
if @gui_chip_editor.lie_pack_name.text.empty?
|
116
|
+
error = 'Package reference missing'
|
117
|
+
# Pin number
|
118
|
+
elsif @gui_chip_editor.lie_pack_pin.text.empty?
|
119
|
+
error = 'Package pin number missing'
|
120
|
+
elsif @gui_chip_editor.tbl_pins.rowCount != @gui_chip_editor.lie_pack_pin.text.to_i
|
121
|
+
error = 'The pin number and the line count in the pin array does not match'
|
122
|
+
# Reference
|
123
|
+
elsif @gui_chip_editor.lie_reference.text.empty?
|
124
|
+
error = 'Chip reference missing'
|
125
|
+
# Manufacturer
|
126
|
+
elsif @gui_chip_editor.lie_manu_name.text.empty?
|
127
|
+
error = 'Chip manufacturer missing'
|
128
|
+
# Type
|
129
|
+
elsif @gui_chip_editor.lie_type_name.text.empty?
|
130
|
+
error = 'Chip type missing'
|
131
|
+
end
|
132
|
+
unless error.empty?
|
133
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Invalid form', error).exec
|
134
|
+
return false
|
135
|
+
else
|
136
|
+
return true
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def delete_cbx_element
|
141
|
+
msg = Qt::MessageBox.new
|
142
|
+
msg.setWindowTitle('Delete element')
|
143
|
+
msg.setText('By deleting this element, all the chips and commands linked to him will be deleted too. Continue ?')
|
144
|
+
msg.setIcon(Qt::MessageBox::Warning)
|
145
|
+
msg.setStandardButtons(Qt::MessageBox::Cancel | Qt::MessageBox::Ok)
|
146
|
+
msg.setDefaultButton(Qt::MessageBox::Cancel)
|
147
|
+
if msg.exec == Qt::MessageBox::Ok
|
148
|
+
case sender.objectName
|
149
|
+
when 'btn_removePackage'
|
150
|
+
if @gui_chip_editor.cbx_package.currentIndex == 0
|
151
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
152
|
+
else
|
153
|
+
package = Package.find_by(package_name: @gui_chip_editor.cbx_package.currentText)
|
154
|
+
chips = Chip.where(chip_package: package)
|
155
|
+
chips.each do |chip|
|
156
|
+
chip.cmd.destroy_all
|
157
|
+
end
|
158
|
+
chips.destroy_all
|
159
|
+
package.destroy
|
160
|
+
@gui_chip_editor.cbx_package.removeItem(@gui_chip_editor.cbx_package.currentIndex)
|
161
|
+
@gui_chip_editor.cbx_package.setCurrentIndex(0)
|
162
|
+
end
|
163
|
+
when 'btn_removeManufacturer'
|
164
|
+
if @gui_chip_editor.cbx_manufacturer.currentIndex == 0
|
165
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
166
|
+
else
|
167
|
+
manufacturer = Manufacturer.find_by(manufacturer_name: @gui_chip_editor.cbx_manufacturer.currentText)
|
168
|
+
chips = Chip.where(chip_manufacturer: manufacturer)
|
169
|
+
chips.each do |chip|
|
170
|
+
chip.cmd.destroy_all
|
171
|
+
end
|
172
|
+
chips.destroy_all
|
173
|
+
manufacturer.destroy
|
174
|
+
@gui_chip_editor.cbx_manufacturer.removeItem(@gui_chip_editor.cbx_manufacturer.currentIndex)
|
175
|
+
@gui_chip_editor.cbx_manufacturer.setCurrentIndex(0)
|
176
|
+
end
|
177
|
+
when 'btn_removeType'
|
178
|
+
if @gui_chip_editor.cbx_type.currentIndex == 0
|
179
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Warning', 'Please select a valid element to delete').exec
|
180
|
+
else
|
181
|
+
type = CType.find_by(cType_name: @gui_chip_editor.cbx_type.currentText)
|
182
|
+
chips = Chip.where(chip_type: type)
|
183
|
+
chips.each do |chip|
|
184
|
+
chip.cmd.destroy_all
|
185
|
+
end
|
186
|
+
chips.destroy_all
|
187
|
+
type.destroy
|
188
|
+
@gui_chip_editor.cbx_type.removeItem(@gui_chip_editor.cbx_type.currentIndex)
|
189
|
+
@gui_chip_editor.cbx_type.setCurrentIndex(0)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
@parent.feed_chip_array
|
193
|
+
end
|
194
|
+
rescue Exception => msg
|
195
|
+
logger = Logger.new($logFilePath)
|
196
|
+
logger.error msg
|
197
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while deleting the element. Consult the log for more details').exec
|
198
|
+
end
|
199
|
+
|
200
|
+
# Add chip in database
|
201
|
+
def add_chip
|
202
|
+
unless control_form_val
|
203
|
+
return
|
204
|
+
end
|
205
|
+
if Chip.exists?(chip_reference: @gui_chip_editor.lie_reference.text)
|
206
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Invalid form', 'This chip reference already exists').exec
|
207
|
+
return
|
208
|
+
end
|
209
|
+
chip = Chip.new
|
210
|
+
# Reference
|
211
|
+
chip.chip_reference = @gui_chip_editor.lie_reference.text
|
212
|
+
# Custom
|
213
|
+
chip.chip_custom = 1
|
214
|
+
# Manufacturer
|
215
|
+
manu = Manufacturer.find_or_create_by(manufacturer_name: @gui_chip_editor.lie_manu_name.text)
|
216
|
+
chip.chip_manufacturer = manu.manufacturer_id
|
217
|
+
# Package
|
218
|
+
if @gui_chip_editor.cbx_package.currentIndex != 0
|
219
|
+
chip.chip_package = Package.find_by(package_name: @gui_chip_editor.cbx_package.currentText).package_id
|
220
|
+
else
|
221
|
+
if @gui_chip_editor.rbn_square.checked
|
222
|
+
shape = 0
|
223
|
+
else
|
224
|
+
shape = 1
|
225
|
+
end
|
226
|
+
Package.create(
|
227
|
+
package_name: @gui_chip_editor.lie_pack_name.text,
|
228
|
+
package_pinNumber: @gui_chip_editor.lie_pack_pin.text,
|
229
|
+
package_shape: shape
|
230
|
+
)
|
231
|
+
chip.chip_package = Package.ids.last
|
232
|
+
end
|
233
|
+
# Type
|
234
|
+
ctype = CType.find_or_create_by(cType_name: @gui_chip_editor.lie_type_name.text)
|
235
|
+
chip.chip_type = ctype.cType_id
|
236
|
+
# Voltage
|
237
|
+
if @gui_chip_editor.rbn_3v.checked
|
238
|
+
voltage = 1
|
239
|
+
else
|
240
|
+
voltage = 0
|
241
|
+
end
|
242
|
+
chip.chip_voltage = voltage
|
243
|
+
# Divers
|
244
|
+
chip.chip_detail = @gui_chip_editor.lie_description.text
|
245
|
+
chip.save
|
246
|
+
# Ajout des PINs
|
247
|
+
for i in 0..(@gui_chip_editor.lie_pack_pin.text.to_i) - 1 do
|
248
|
+
pin_num = @gui_chip_editor.tbl_pins.item(i, 0)
|
249
|
+
pin_signal = @gui_chip_editor.tbl_pins.cellWidget(i, 2)
|
250
|
+
pin_bus = @gui_chip_editor.tbl_pins.cellWidget(i, 1)
|
251
|
+
if pin_bus.currentIndex == 0
|
252
|
+
signal = 62
|
253
|
+
else
|
254
|
+
signal = Signall.find_by(signal_name: pin_signal.currentText).signal_id
|
255
|
+
end
|
256
|
+
Pin.create(
|
257
|
+
pin_number: pin_num.text.to_i,
|
258
|
+
pin_chip: chip.chip_id,
|
259
|
+
pin_signal: signal
|
260
|
+
)
|
261
|
+
end
|
262
|
+
# Reloading array
|
263
|
+
@parent.feed_chip_array
|
264
|
+
close
|
265
|
+
end
|
266
|
+
|
267
|
+
# Edit the chip
|
268
|
+
def edit_chip
|
269
|
+
unless control_form_val
|
270
|
+
return 0
|
271
|
+
end
|
272
|
+
# Reference
|
273
|
+
if @chip.chip_reference != @gui_chip_editor.lie_reference.text
|
274
|
+
@chip.update(chip_reference: @gui_chip_editor.lie_reference.text)
|
275
|
+
end
|
276
|
+
# Manufacturer
|
277
|
+
manu = Manufacturer.find_or_create_by(manufacturer_name: @gui_chip_editor.lie_manu_name.text)
|
278
|
+
if @chip.chip_manufacturer != manu.manufacturer_id
|
279
|
+
@chip.update(chip_manufacturer: manu.manufacturer_id)
|
280
|
+
end
|
281
|
+
# Package
|
282
|
+
if @gui_chip_editor.rbn_square.isChecked
|
283
|
+
shape = 0
|
284
|
+
else
|
285
|
+
shape = 1
|
286
|
+
end
|
287
|
+
package = Package.find_or_create_by(
|
288
|
+
package_name: @gui_chip_editor.lie_pack_name.text,
|
289
|
+
package_pinNumber: @gui_chip_editor.lie_pack_pin.text,
|
290
|
+
package_shape: shape
|
291
|
+
)
|
292
|
+
if @chip.chip_package != package.package_id
|
293
|
+
@chip.update(chip_package: package.package_id)
|
294
|
+
end
|
295
|
+
# Type
|
296
|
+
ctype = CType.find_or_create_by(cType_name: @gui_chip_editor.lie_type_name.text)
|
297
|
+
if @chip.chip_type != ctype.cType_id
|
298
|
+
@chip.update(chip_type: ctype.cType_id)
|
299
|
+
end
|
300
|
+
# Voltage
|
301
|
+
if @gui_chip_editor.rbn_3v.checked
|
302
|
+
voltage = 1
|
303
|
+
else
|
304
|
+
voltage = 0
|
305
|
+
end
|
306
|
+
if @chip.chip_voltage != voltage
|
307
|
+
@chip.update(chip_voltage: voltage)
|
308
|
+
end
|
309
|
+
# Divers
|
310
|
+
if @chip.chip_detail != @gui_chip_editor.lie_description.text
|
311
|
+
@chip.update(chip_detail: @gui_chip_editor.lie_description.text)
|
312
|
+
end
|
313
|
+
|
314
|
+
# Edit PINs (Destroy all then recreate)
|
315
|
+
@chip.pin.destroy_all
|
316
|
+
for i in 0..(@gui_chip_editor.lie_pack_pin.text.to_i) - 1 do
|
317
|
+
pin_num = @gui_chip_editor.tbl_pins.item(i, 0)
|
318
|
+
pin_signal = @gui_chip_editor.tbl_pins.cellWidget(i, 2)
|
319
|
+
pin_bus = @gui_chip_editor.tbl_pins.cellWidget(i, 1)
|
320
|
+
if pin_bus.currentIndex == 0
|
321
|
+
signal = 62
|
322
|
+
else
|
323
|
+
signal = Signall.find_by(signal_name: pin_signal.currentText).signal_id
|
324
|
+
end
|
325
|
+
Pin.create(
|
326
|
+
pin_number: pin_num.text.to_i,
|
327
|
+
pin_chip: @chip.chip_id,
|
328
|
+
pin_signal: signal
|
329
|
+
)
|
330
|
+
end
|
331
|
+
# Reloading array
|
332
|
+
@parent.feed_chip_array
|
333
|
+
close
|
334
|
+
rescue Exception => msg
|
335
|
+
logger = Logger.new($logFilePath)
|
336
|
+
logger.error msg
|
337
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while editing the chip. Consult the log for more details').exec
|
338
|
+
end
|
339
|
+
|
340
|
+
# Package combobox
|
341
|
+
def select_package
|
342
|
+
if @gui_chip_editor.cbx_package.currentIndex != 0
|
343
|
+
selectedPackage = Package.find_by package_name: @gui_chip_editor.cbx_package.currentText
|
344
|
+
@gui_chip_editor.lie_pack_name.setEnabled(false)
|
345
|
+
@gui_chip_editor.lie_pack_name.setText(selectedPackage.package_name)
|
346
|
+
@gui_chip_editor.lie_pack_pin.setEnabled(false)
|
347
|
+
@gui_chip_editor.lie_pack_pin.setText(selectedPackage.package_pinNumber.to_s)
|
348
|
+
@gui_chip_editor.rbn_square.setEnabled(false)
|
349
|
+
@gui_chip_editor.rbn_rectangular.setEnabled(false)
|
350
|
+
if selectedPackage.package_shape == 0
|
351
|
+
@gui_chip_editor.rbn_square.setChecked(true)
|
352
|
+
else
|
353
|
+
@gui_chip_editor.rbn_rectangular.setChecked(true)
|
354
|
+
end
|
355
|
+
fill_pin_table
|
356
|
+
else
|
357
|
+
@gui_chip_editor.lie_pack_name.setEnabled(true)
|
358
|
+
@gui_chip_editor.lie_pack_name.clear
|
359
|
+
@gui_chip_editor.lie_pack_pin.setEnabled(true)
|
360
|
+
@gui_chip_editor.lie_pack_pin.clear
|
361
|
+
@gui_chip_editor.rbn_square.setChecked(true)
|
362
|
+
@gui_chip_editor.rbn_rectangular.setEnabled(true)
|
363
|
+
@gui_chip_editor.rbn_square.setEnabled(true)
|
364
|
+
@gui_chip_editor.tbl_pins.clear
|
365
|
+
@gui_chip_editor.tbl_pins.setRowCount(0)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
# Manufacturer combobox
|
370
|
+
def select_manufacturer
|
371
|
+
if @gui_chip_editor.cbx_manufacturer.currentIndex != 0
|
372
|
+
@gui_chip_editor.lie_manu_name.setEnabled(false)
|
373
|
+
@gui_chip_editor.lie_manu_name.setText(@gui_chip_editor.cbx_manufacturer.currentText)
|
374
|
+
else
|
375
|
+
@gui_chip_editor.lie_manu_name.setEnabled(true)
|
376
|
+
@gui_chip_editor.lie_manu_name.setText('')
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
# Type combobox
|
381
|
+
def select_type
|
382
|
+
if @gui_chip_editor.cbx_type.currentIndex != 0
|
383
|
+
@gui_chip_editor.lie_type_name.setEnabled(false)
|
384
|
+
@gui_chip_editor.lie_type_name.setText(@gui_chip_editor.cbx_type.currentText)
|
385
|
+
else
|
386
|
+
@gui_chip_editor.lie_type_name.setEnabled(true)
|
387
|
+
@gui_chip_editor.lie_type_name.setText('')
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
def fill_pin_table(action = '')
|
392
|
+
if @gui_chip_editor.lie_pack_pin.text.to_i <= 144 && @gui_chip_editor.lie_pack_pin.text.to_i > 4
|
393
|
+
@gui_chip_editor.tbl_pins.setRowCount(@gui_chip_editor.lie_pack_pin.text.to_i)
|
394
|
+
@gui_chip_editor.lie_pack_pin.text.to_i.times do |i|
|
395
|
+
cbx_bus = Qt::ComboBox.new
|
396
|
+
row = Qt::Variant.new(i)
|
397
|
+
cbx_bus.setProperty('row', row)
|
398
|
+
@gui_chip_editor.tbl_pins.setCellWidget(i, 1, cbx_bus)
|
399
|
+
cbx_signal = Qt::ComboBox.new
|
400
|
+
@gui_chip_editor.tbl_pins.setCellWidget(i, 2, cbx_signal)
|
401
|
+
item = Qt::TableWidgetItem.new
|
402
|
+
item.setFlags(Qt::ItemIsEnabled)
|
403
|
+
item.setData(0, Qt::Variant.new(i.next))
|
404
|
+
@gui_chip_editor.tbl_pins.setItem(i, 0, item)
|
405
|
+
cbx_bus.addItem('Bus...')
|
406
|
+
@bus_list.each do |b|
|
407
|
+
cbx_bus.addItem(b.bus_name)
|
408
|
+
end
|
409
|
+
if action == 'edit'
|
410
|
+
pin = Pin.find_by(pin_number: i.next, pin_chip: @chip.chip_id)
|
411
|
+
cbx_bus.setCurrentIndex(cbx_bus.findText(pin.signall.bus.pluck(:bus_name)[0]))
|
412
|
+
signal_list = Use.where(bus_id: pin.signall.bus.pluck(:bus_id)[0]).pluck(:signal_id)
|
413
|
+
signal_list.each do |s|
|
414
|
+
cbx_signal.addItem(Signall.find_by(signal_id: s).signal_name)
|
415
|
+
end
|
416
|
+
cbx_signal.setCurrentIndex(cbx_signal.findText(pin.signall.signal_name))
|
417
|
+
end
|
418
|
+
Qt::Object.connect(cbx_bus, SIGNAL('currentIndexChanged(int)'), self, SLOT('filter_cbx()'))
|
419
|
+
end
|
420
|
+
else
|
421
|
+
Qt::MessageBox.new(Qt::MessageBox::Warning, 'Invalid pin number value', 'Pin number needs to be between 4 and 144').exec
|
422
|
+
end
|
423
|
+
rescue Exception => msg
|
424
|
+
logger = Logger.new($logFilePath)
|
425
|
+
logger.error msg
|
426
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while adding pins to the table. Consult the log for more details').exec
|
427
|
+
end
|
428
|
+
|
429
|
+
# Filter signals by bus
|
430
|
+
def filter_cbx
|
431
|
+
bus_item_row = sender.property('row').to_i
|
432
|
+
busItem = @gui_chip_editor.tbl_pins.cellWidget(bus_item_row, 1)
|
433
|
+
associated_signal_item = @gui_chip_editor.tbl_pins.cellWidget(bus_item_row, 2)
|
434
|
+
associated_signal_item.clear
|
435
|
+
if busItem.currentText != 'Bus...'
|
436
|
+
bus = Bus.find_by(bus_name: busItem.currentText).bus_id
|
437
|
+
filtered_signal_list = Use.where(bus_id: bus)
|
438
|
+
filtered_signal_list.each do |s|
|
439
|
+
signalName = Signall.find_by(signal_id: s.signal_id).signal_name
|
440
|
+
associated_signal_item.addItem(signalName)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
rescue Exception => msg
|
444
|
+
logger = Logger.new($logFilePath)
|
445
|
+
logger.error msg
|
446
|
+
Qt::MessageBox.new(Qt::MessageBox::Critical, 'Critical error', 'Error occured while filtering the signals. Consult the log for more details').exec
|
447
|
+
end
|
448
|
+
end
|