Serial port
-
int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);
fd = open(MODEMDEVICE,O_RDWR|O_NOCTTY);While(true)
{
Buffer.clear();
nreturn = read(fd,&chBuf,1);
if(nreturn > 0)
{
for(i=0;i<nreturn;i++)
{
Buffer.append(chBuf[i]);if(chBuf[0] == 0xc9) nReadIndex = 0;
pData[nReadIndex++] = chBuf[i];
qDebug() << "data" << Buffer.toHex();
}
if(chBuf[0] == 0xcf)
{if(nReadIndex >= 10)
//Display of Gui opreration //
nReadIndex = 0;
}
For this how can i use timers instead of while loop, where should i start timer , i tried but am geting segmentation problem.Please help me
-
Without any proper code, I can't.
-
Without any proper code, I can't.
-
That won't really help debugging but from the looks of it, you are using the linux platform API, so please ask this on a linux dedicated forum.
There's also this "how to":http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html that should give you some hints and this "stack overflow post":http://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c
-
That won't really help debugging but from the looks of it, you are using the linux platform API, so please ask this on a linux dedicated forum.
There's also this "how to":http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html that should give you some hints and this "stack overflow post":http://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c