Thank you for your reply and sorry for not providing enough information.

I used QSerialport to write this program, and serial was an instance of that class, I declared it above those lines of codes
Qt Code:
  1. QSerialPort *serial = new QSerialPort(this);
To copy to clipboard, switch view to plain text mode 
, and "write" is just a function of the class, writing data to the port.

What you said can be a possibility, but I'm not really sure, do you have any suggestion on how to fix it? I would greatly appreciate your help