def open(self):
if self.device is not None and self.device.is_open:<EOL><INDENT>self.close()<EOL><DEDENT>self.device = serial.Serial(port=self.devfile, baudrate=self.baudrate,<EOL>bytesize=self.bytesize, parity=self.parity,<EOL>stopbits=self.stopbits, timeout=self.timeout,<EOL>xonxoff=self.xonxoff, dsrdtr=self.dsrdtr)<EOL>if self.device is not None:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>".format(str(self.devfile)))<EOL><DEDENT>
Setup serial port and set is as escpos device