Confused with QSerialPort control
-
Hi,
I'm using this to receive data from an Arduino script:
QObject::connect(arduino, SIGNAL(readyRead()), this, SLOT(readSerial()));
This line is inside a "begin" button, and calls the readSerial function
It works perfectly when I first run the program and I receive data like this (as intended):
"x"
"x"
"x"
"r"
"x"
"x"I then have a 'pause' button, where I send a stop command to my Arduino. Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
"x"
""
"x"
""
"x"
""
"r"
""
"x"
""
"x"
I believe this is causing an issue with my system.
I have a stop command in my Arduino to stop sending data, but do I have to somehow stop my signal/slot thing?
Would love if somebody can help me/ requires more info on my program.Cheers
-
Hi,
I'm using this to receive data from an Arduino script:
QObject::connect(arduino, SIGNAL(readyRead()), this, SLOT(readSerial()));
This line is inside a "begin" button, and calls the readSerial function
It works perfectly when I first run the program and I receive data like this (as intended):
"x"
"x"
"x"
"r"
"x"
"x"I then have a 'pause' button, where I send a stop command to my Arduino. Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
"x"
""
"x"
""
"x"
""
"r"
""
"x"
""
"x"
I believe this is causing an issue with my system.
I have a stop command in my Arduino to stop sending data, but do I have to somehow stop my signal/slot thing?
Would love if somebody can help me/ requires more info on my program.Cheers
@SOrton said in Confused with QSerialPort control:
This line is inside a "begin" button, and calls the readSerial function
Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
Make sure you are not doing your
connect()
statement a second time? Your output looks like you might be doing two serial reads for eachreadyRead()
signal, hence the alternating "blank" results?As a separate issue, do yourself a favour and change your
connect()
s to use the "new" syntax which was introduced over a decade ago.... -
-
@SOrton said in Confused with QSerialPort control:
This line is inside a "begin" button, and calls the readSerial function
Once I restart the Serial read (AFTER a pause), I'm receiving data incorrectly like this:
Make sure you are not doing your
connect()
statement a second time? Your output looks like you might be doing two serial reads for eachreadyRead()
signal, hence the alternating "blank" results?As a separate issue, do yourself a favour and change your
connect()
s to use the "new" syntax which was introduced over a decade ago....