Class: Uart_baudrate
- Inherits:
-
Qt::Widget
- Object
- Qt::Widget
- Uart_baudrate
- Defined in:
- lib/class/uart/Uart_baudrate.rb
Instance Method Summary collapse
- #copy ⇒ Object
-
#initialize(parent_view) ⇒ Uart_baudrate
constructor
A new instance of Uart_baudrate.
- #start_detect ⇒ Object
- #stop_detect ⇒ Object
Constructor Details
#initialize(parent_view) ⇒ Uart_baudrate
Returns a new instance of Uart_baudrate.
16 17 18 19 20 21 22 23 |
# File 'lib/class/uart/Uart_baudrate.rb', line 16 def initialize(parent_view) super() Firmware.new('UART') @view = Ui_Uart_baudrate.new centerWindow(self) @view.setupUi(self) @parent_view = parent_view end |
Instance Method Details
#copy ⇒ Object
58 59 60 61 |
# File 'lib/class/uart/Uart_baudrate.rb', line 58 def copy @parent_view.lie_baud_rate.setText(@baudrate.to_s) close end |
#start_detect ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/class/uart/Uart_baudrate.rb', line 25 def start_detect @view.btn_start.setEnabled(false) $app.processEvents @uart = HardsploitAPI_UART.new( baud_rate: 115200, word_width: 8, use_parity_bit: 0, parity_type: 0, nb_stop_bits: 1, idle_line_level: 1 ) @uart.enableMeasureBaudRate @view.btn_stop.setEnabled(true) end |
#stop_detect ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/class/uart/Uart_baudrate.rb', line 40 def stop_detect @view.btn_stop.setEnabled(false) @baudrate = @uart.measureBaudRate @uart.disableMeasureBaudRate @view.btn_start.setEnabled(true) unless @baudrate.zero? @view.lbl_baudrate.setText("Baud rate detected: #{@baudrate} Hz") else @view.lbl_baudrate.setText("Baud rate detected: None.") end rescue HardsploitAPI::ERROR::HARDSPLOIT_NOT_FOUND ErrorMsg.new.hardsploit_not_found rescue HardsploitAPI::ERROR::USB_ERROR ErrorMsg.new.usb_error rescue Exception => msg ErrorMsg.new.unknown(msg) end |