Exactly - You should add DEFINES += _TTY_POSIX in your pro file (or if you are using KDevelop it has a field for that in the qmake configuration).So only i used Posix_QextSerialPort. Should i define somewhere about _TTY_POSIX ?
Exactly - You should add DEFINES += _TTY_POSIX in your pro file (or if you are using KDevelop it has a field for that in the qmake configuration).So only i used Posix_QextSerialPort. Should i define somewhere about _TTY_POSIX ?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
high_flyer:
that parameter has already been set when i untar the qextserial package. should i specify that in my application pro file ?
Let me explain what i have done so far :
1). Downloaded the qextserial package , untarred and entered qmake ,make. there were the following libraries created:
libqextserialport.so libqextserialport.so.1 libqextserialport.so.1.0 libqextserialport.so.1.0.0
2). Then created a directory ,copied my source files. entered the header files and the libraries for qextserial in my project file. then entered make.
is this procedure correct ? else can you say me the correct one ?
yes.should i specify that in my application pro file ?
It should work.is this procedure correct ? else can you say me the correct one ?
But I would not copy the header files and libs, I would link to them or user the -L and -I in my make file.
But that is a subjective private taste matter, your way should work just as well.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
hi ,
i specified in my project file also and it compiled successfully.but still the same error comes . Is there any permission i need to set to serial port ? i'l post my full code here if any one find any error please point me :
Qt Code:
#include <qwidget.h> #include <qapplication.h> #include <stdlib.h> #include <qextserialport.h> { public: private: int mouse; int mouseidx; }; { setMinimumSize(640,480 ); QextSerialPort *note= new QextSerialPort("/dev/ttyS0"); note->setBaudRate(BAUD115200); note->setParity(PAR_NONE); note->setDataBits(DATA_8); note->setStopBits(STOP_1); note->open(IO_ReadOnly); } int main( int argc, char **argv ) { Widget connect1; a.setMainWidget( &connect1 ); connect1.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
Last edited by high_flyer; 7th May 2007 at 10:54. Reason: missing [code] tags
I guess you mean the segmentation fault.compiled successfully.but still the same error comes .
Your code has the following problems:
You are allocating the serial port on to a local pointer.Qt Code:
QextSerialPort *note= new QextSerialPort("/dev/ttyS0");To copy to clipboard, switch view to plain text mode
You will not be able to access the serial port outside the constructor.
'note' needs to be a member variable.
Where is the code that handels the reading/writing to the serial port?
theLSB:
I did not add the read/write operation. i thougth first let me open the port sucessfuly. then,read that.
Do you mean that i need to declare it under protected and use it in the constructor ?'note' needs to be a member variable
No, you need to declare it as a member variable.Do you mean that i need to declare it under protected and use it in the constructor ?
Do you know what a member variable is?
Qt Code:
{ private: //depends on your needs, this can be any access mode QextSerialPort *m_note; public: private: int mouse; int mouseidx; }; m_note(NULL) { setMinimumSize(640,480 ); m_note= new QextSerialPort("/dev/ttyS0"); if(note) { m_note->setBaudRate(BAUD115200); m_note->setParity(PAR_NONE); m_note->setDataBits(DATA_8); m_note->setStopBits(STOP_1); m_note->open(IO_ReadOnly); } }To copy to clipboard, switch view to plain text mode
Last edited by high_flyer; 7th May 2007 at 13:46.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
high_flyer:
yeah i did as you said. i tried both the ways-private or protected. But no use.![]()
Could you be a bit more descriptive?But no use.
The access mode has nothing to do with it.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
first i tried declaring the Qextserialport as a private member variable, compiled and when i rum the same error came. next i tried declaring it as protected member variable, the same thing happened.
what error? segmentation falut?
Are there any other methods do the Widget class?
Try setting debug messages along the code or run in a debugger and see where the applciation crashes.
EIDT:
Wait, in the code I edited for you, your should change all 'note' instances to 'm_note' did you do that?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Hi,
i solved that problem. i did not declare it in the heap.The following is what i did:With this the application opens without segmentation fault. Now i'm finding out how to read the datas ? the suggestion b1 gave did not work out as there is no member function called read in the Qextserialport.Qt Code:
QextSerialPort note("/dev/ttyS0"); note.setBaudRate(BAUD115200); note.setParity(PAR_NONE); note.setDataBits(DATA_8); note.setStopBits(STOP_1); note.open(IO_ReadOnly);To copy to clipboard, switch view to plain text mode
Anyway thanks a lot for all of your kind response .
Bookmarks