User avatar
Mahan_Micro
Posts: 44
Joined: Tue Aug 04, 2015 8:52 pm

interrupt for serial port recieving

Sat Sep 24, 2016 2:26 pm

Hi
I want to use serial port in pi2 and I write my code in C and working with virtual file in linux.
so I dont need to other library.
I can send and recieve in serial port but I dont know how I can use interrupt for recieving ???
I want to run a sub function(interrupt) when a 'char' recieved !
can you help me ??
If your Dreams Don't Scare You , They Aren't Big Enough

User avatar
joan
Posts: 14668
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: interrupt for serial port recieving

Sat Sep 24, 2016 3:31 pm

Look at the select, poll, and epoll functions.

User avatar
Mahan_Micro
Posts: 44
Joined: Tue Aug 04, 2015 8:52 pm

Re: interrupt for serial port recieving

Sat Sep 24, 2016 8:30 pm

joan wrote:Look at the select, poll, and epoll functions.
thanks
can you give me a good link or tutorial ??
If your Dreams Don't Scare You , They Aren't Big Enough

User avatar
topguy
Posts: 6157
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: interrupt for serial port recieving

Sun Sep 25, 2016 3:29 am

If you want your program to do stuff and not be busy listening to the serial port all the time I would suggest looking into multithreading.
Let the kernel deal with low-level stuff like interrupts unless you need response times measured in nanoseconds.

User avatar
Mahan_Micro
Posts: 44
Joined: Tue Aug 04, 2015 8:52 pm

Re: interrupt for serial port recieving

Sun Sep 25, 2016 6:52 pm

topguy wrote:If you want your program to do stuff and not be busy listening to the serial port all the time I would suggest looking into multithreading.
Let the kernel deal with low-level stuff like interrupts unless you need response times measured in nanoseconds.
thank you, you are right
do yo know any tutorial for multithreading in QT creator ??
it's my first exprience
If your Dreams Don't Scare You , They Aren't Big Enough

User avatar
topguy
Posts: 6157
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: interrupt for serial port recieving

Sun Sep 25, 2016 10:24 pm

Are you actually using Qt or just QtCreator as an IDE for C/C++ ?

Any guide on pthreads will be suitable.

User avatar
Mahan_Micro
Posts: 44
Joined: Tue Aug 04, 2015 8:52 pm

Re: interrupt for serial port recieving

Mon Sep 26, 2016 1:38 pm

topguy wrote:Are you actually using Qt or just QtCreator as an IDE for C/C++ ?

Any guide on pthreads will be suitable.
I use QTcreator as an IDE
thanks a lot
If your Dreams Don't Scare You , They Aren't Big Enough

Return to “C/C++”