I use wiringSerial.h library to read from USB port of raspi in thread
void MyThread::run()
{
qDebug
("Thread id inside run %d",
(int)QThread::currentThreadId());
int fd ,value;
if ((fd = serialOpen ("/dev/ttyACM0",230400)) < 0)
{
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
}
while (serialDataAvail(fd)>-2)
{
value=serialGetchar (fd) ;
msleep(1);
emit signalValueUpdated(value);
}
serialClose(fd);
}
void MyThread::run()
{
qDebug("Thread id inside run %d",(int)QThread::currentThreadId());
int fd ,value;
if ((fd = serialOpen ("/dev/ttyACM0",230400)) < 0)
{
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
}
while (serialDataAvail(fd)>-2)
{
value=serialGetchar (fd) ;
msleep(1);
emit signalValueUpdated(value);
}
serialClose(fd);
}
To copy to clipboard, switch view to plain text mode
the data that received is a number between -1 to 255
when use value in emit signal Value Updated(value); or print it
the value is not the same value that send to raspberry pi, what should I do?
Bookmarks