Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QtSerialPort write() problems
Qt 6.11 is out! See what's new in the release blog

QtSerialPort write() problems

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 755 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moldy01
    wrote on last edited by
    #1

    I've been trying for a couple of days now, so I thought that I'd better get help from those that do a LOT more Qt dev than I. I'm using a USB to TTL Serial dongle, which I know works well, as outside of Qt, serial.Serial's write works very well.

    For some reason inside of the bowels of Qt, serial.Serial doesn't exist. So, I thought that I'd switch to QtSerialPort and try again. I can get it to init the port, but writing to the port doesn't seem to want do anything for me. Scope doesn't see a thing at the Rx/Tx lines.

    Am I just doing something stupid???

    def openCover(self):
        global OpenTime
        msg_tx_buffer = bytearray([1, 1, 1, 31, 255])
        op = self.openPort()
        if op:
            self.statusText.setText('Port opened')
            startTime = time.time()
            while time.time() < startTime + OpenTime:
                self.port.write(msg_tx_buffer)
                time.sleep(0.01)
        self.port.close()
    
    JonBJ 1 Reply Last reply
    0
    • M Moldy01

      I've been trying for a couple of days now, so I thought that I'd better get help from those that do a LOT more Qt dev than I. I'm using a USB to TTL Serial dongle, which I know works well, as outside of Qt, serial.Serial's write works very well.

      For some reason inside of the bowels of Qt, serial.Serial doesn't exist. So, I thought that I'd switch to QtSerialPort and try again. I can get it to init the port, but writing to the port doesn't seem to want do anything for me. Scope doesn't see a thing at the Rx/Tx lines.

      Am I just doing something stupid???

      def openCover(self):
          global OpenTime
          msg_tx_buffer = bytearray([1, 1, 1, 31, 255])
          op = self.openPort()
          if op:
              self.statusText.setText('Port opened')
              startTime = time.time()
              while time.time() < startTime + OpenTime:
                  self.port.write(msg_tx_buffer)
                  time.sleep(0.01)
          self.port.close()
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Moldy01 said in QtSerialPort write() problems:

      For some reason inside of the bowels of Qt, serial.Serial doesn't exist

      Don't know what this means, don't know what serial.Serial might be.

      Your code does not seem to use anything Qt, no QSerialPort class. Don't know what self.openPort() might or might not do. Don't know what self.port is.

      The only Qt code here is the setText(), which won't work anyway in the sense that it won't appear because you don't allow the Qt event loop to run.

      All your code seems maybe to use Python serial port handling/code, so look there for answers.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved