I'm currently developing a bloc on GNU Radio and I want to use a thread. This thread is there to acquired data from a UDP socket so I can use it in my GNU Radio bloc. The "general work" function is the one that does all the signal and data processing.
The master source file is organized like this :
namespace gr {
namespace adsb {
out::sptr
out::make()
{
return gnuradio::get_initial_sptr
(new out_impl());
}
/*
* UDP thread
*/
void *task_UdpRx (void *arg)
{
while(true)
{
printf("Task UdpRx\n\r");
usleep(500*1000);
}
pthread_exit(NULL);
}
/*
* The private constructor
*/
out_impl::out_impl()
: gr::block("out",
gr::io_signature::make(1, 1, sizeof(int)),
gr::io_signature::make(1, 1, sizeof(char)))
{
pthread_t Thread_UdpRx;
//Thread init
if(pthread_create(&Thread_UdpRx, NULL, task_UdpRx, NULL))
{
err("Pthread error");
}
else
{
printf("UDP thread initialization completed\n\r");
}
}
/*
* Our virtual destructor.
*/
out_impl::~out_impl()
{
}
void out_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
ninput_items_required[0] = noutput_items;
}
int out_impl::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
const int *in = (const int *) input_items[0];
char *out = (char *) output_items[0];
// Do <+signal processing+>
for(int i = 0; i < noutput_items; i++)
{
printf("General work\n\r");
}/* for < noutput_items */
// Tell runtime system how many input items we consumed on
// each input stream.
consume_each (noutput_items);
// Tell runtime system how many output items we produced.
return noutput_items;
} /* general work */
} /* namespace adsb */
} /* namespace gr */`
The problem I get is that when I try to compile, I get this error :
In constructor ‘gr::adsb::out_impl::out_impl()’:
error: argument of type ‘void* (gr::adsb::out_impl::)(void*)’ does not match ‘void* (*)(void*)’
This error refers to the line and it concerns task_UdpRx :
if(pthread_create(&Thread_UdpRx, NULL, task_UdpRx, NULL))
Does anybody have any idea ?
Don't hesitate to ask for more details if needed. The code I've displayed is the shortest I could do in order for you to get the best understanding possible.
Thank you !