code: def open(self):
          
          if self.device is not None and self.device.is_open:
              self.close()
          self.device = serial.Serial(port=self.devfile, baudrate=self.baudrate,
                                      bytesize=self.bytesize, parity=self.parity,
                                      stopbits=self.stopbits, timeout=self.timeout,
                                      xonxoff=self.xonxoff, dsrdtr=self.dsrdtr)
  
          if self.device is not None:
              print("Serial printer enabled")
          else:
              print("Unable to open serial printer on: {0}".format(str(self.devfile)))
docs: Setup serial port and set is as escpos device