Exemple #1
0
    def refreshCom(self):
        self.cmbPort.clear()
        for info in QSerialPortInfo.availablePorts():
            # self.com.setPort(info)
            self.cmbPort.addItem(info.portName())
        for info in QSerialPortInfo.standardBaudRates():
            self.cmbBaud.addItem(str(info))

        if (self.cmbBaud.findText('9600') != -1):
            self.cmbBaud.setCurrentIndex(self.cmbBaud.findText('9600'))
        elif (slef.cmbBaud.findText('19200') != -1):
            self.cmbBaud.setCurrentIndex(self.cmbBaud.findText('19200'))
        else:
            slef.cmbBaud.setCurrentIndex(0)
    def __init__(self, port):
        super().__init__()
        self.setupUi(self)

        self.line_end = ''

        self.baudRateComboBox.addItems(
            map(str, QSerialPortInfo.standardBaudRates()))

        self.sendButton.clicked.connect(self.send)
        self.downbutton.clicked.connect(self.to_end)
        self.baudRateComboBox.currentIndexChanged.connect(self.change_baudrate)
        self.lineEndComboBox.currentIndexChanged.connect(self.change_line_end)

        self.serial = QtSerialPort.QSerialPort(
            port,
            baudRate=QtSerialPort.QSerialPort.Baud9600,
            readyRead=self.receive)
        self.serial.open(QtCore.QIODevice.ReadWrite)
Exemple #3
0
 def __init__(self, parent=None, flags=Qt.WindowFlags()):
     super().__init__(parent, flags)
     self.sPortList = {}
     self.devChange = QFileSystemWatcher(["/dev"])
     self.devChange.directoryChanged.connect(
         self.on_devChange_directoryChanged)
     self.setupUi(self)
     ports = QSerialPortInfo.availablePorts()
     for i in ports:
         self.serialPort.addItem(i.portName())
         self.sPortList[i.portName()] = i
     bauds = QSerialPortInfo.standardBaudRates()
     for i in bauds:
         self.speed.addItem(str(i))
     self.speed.setCurrentText("38400")
     self.flowControl.addItem(self.tr("Software Flow Control (Xon/Xoff)"),
                              "SOFT")
     self.flowControl.addItem(self.tr("Hardware Flow Control (RTS/CTS)"),
                              "HARD")
     self.flowControl.addItem(self.tr("No Flow Control"), "NONE")
     self.flowControl.setCurrentIndex(2)
Exemple #4
0
    def RefreshCom(self):
        self.cmbPort.clear()
        for info in QSerialPortInfo.availablePorts():
            self.cmbPort.addItem(info.portName())
            # self.cmbPort.addItem(info.portName()+info.description())
            # print(info.description())
            # print(info.manufacturer())
            # print(info.serialNumber())
        for info in QSerialPortInfo.standardBaudRates():
            self.cmbBaud.addItem(str(info))

        if (self.cmbBaud.findText('9600') != -1):
            self.cmbBaud.setCurrentIndex(self.cmbBaud.findText('9600'))
        elif (self.cmbBaud.findText('19200') != -1):
            self.cmbBaud.setCurrentIndex(self.cmbBaud.findText('19200'))
        else:
            self.cmbBaud.setCurrentIndex(0)

        self.cmbParity.addItems(['None', 'Even', 'Odd', 'Mark', 'Space'])
        self.cmbWordLen.addItems(['5', '6', '7', '8'])
        self.cmbStopBits.addItems(['1', '1.5', '2'])
 def change_baudrate(self, state):
     print(state)
     self.serial.setBaudRate(QSerialPortInfo.standardBaudRates()[state])
Exemple #6
0
    def initUI(self):

        self.m_serialPortLabel = QLabel("Serial port:")
        self.m_serialPortComboBox = QComboBox()
        self.m_serialBaudsLabel = QLabel("Bauds:")
        self.m_serialBaudsComboBox = QComboBox()
        self.m_waitResponseLabel = QLabel("Wait response, msec:")
        self.m_waitResponseSpinBox = QSpinBox()
        self.m_longDelayLabel = QLabel("transaction delay, msec:")
        self.m_longDelaySpinBox = QSpinBox()

        self.m_runButton = QPushButton("Send request")
        self.m_requestLabel = QLabel("Request (hex without 0x):")
        self.m_requestLineEdit = QLineEdit("09")
        self.m_trafficLabel = QLabel("No traffic.")
        self.m_statusLabel = QLabel("Status: Not running.")

        available_ports = QSerialPortInfo.availablePorts()
        for port in available_ports:
            self.m_serialPortComboBox.addItem(port.portName())

        available_bauds = QSerialPortInfo.standardBaudRates()
        for bauds in available_bauds:
            self.m_serialBaudsComboBox.addItem(str(bauds))
        self.m_serialBaudsComboBox.itemText(9)

        self.m_waitResponseSpinBox.setRange(0, 10000)
        self.m_waitResponseSpinBox.setValue(1500)

        self.m_longDelaySpinBox.setRange(0, 10000)
        self.m_longDelaySpinBox.setValue(100)
        self.longdelay = 0.1

        mainLayout = QGridLayout()

        mainLayout.addWidget(self.m_serialPortLabel, 0, 0)
        mainLayout.addWidget(self.m_serialPortComboBox, 0, 1)
        mainLayout.addWidget(self.m_serialBaudsLabel, 0, 2)
        mainLayout.addWidget(self.m_serialBaudsComboBox, 0, 3)

        mainLayout.addWidget(self.m_waitResponseLabel, 1, 0)
        mainLayout.addWidget(self.m_waitResponseSpinBox, 1, 1)

        mainLayout.addWidget(self.m_longDelayLabel, 2, 0)
        mainLayout.addWidget(self.m_longDelaySpinBox, 2, 1)

        #mainLayout.addWidget(self.m_stopButton,1,2,2,1)
        mainLayout.addWidget(self.m_requestLabel, 3, 0)
        mainLayout.addWidget(self.m_requestLineEdit, 3, 1)

        mainLayout.addWidget(self.m_runButton, 4, 1)

        mainLayout.addWidget(self.m_trafficLabel, 5, 0, 1, 4)

        mainLayout.addWidget(self.m_statusLabel, 6, 0, 1, 5)

        self.setLayout(mainLayout)

        self.setWindowTitle("TDC7201 Terminal")
        self.setWindowIcon(QIcon('pinion-icon.png'))
        self.m_serialPortComboBox.setFocus()

        #connection
        self.m_runButton.clicked.connect(self.transactionUI)
        self.m_serialt.responseSignal.connect(self.showResponse)
        self.m_serialt.errorSignal.connect(self.processError)
        self.m_serialt.timeoutSignal.connect(self.processTimeout)
        self.m_longDelaySpinBox.valueChanged.connect(self.updLongDelay)
        self.m_waitResponseSpinBox.valueChanged.connect(self.updwaitTimeout)

        self.center()

        self.show()