私は現在、GNU Radio でブロックを開発しており、スレッドを使用したいと考えています。このスレッドは、UDP ソケットからデータを取得するためにあるため、GNU Radio ブロックで使用できます。「一般的な作業」機能は、すべての信号とデータ処理を行う機能です。
マスター ソース ファイルは次のように編成されます。
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 */`
私が得る問題は、コンパイルしようとすると、次のエラーが発生することです。
In constructor ‘gr::adsb::out_impl::out_impl()’:
error: argument of type ‘void* (gr::adsb::out_impl::)(void*)’ does not match ‘void* (*)(void*)’
このエラーは次の行を参照しており、 task_UdpRx に関係しています。
if(pthread_create(&Thread_UdpRx, NULL, task_UdpRx, NULL))
誰にもアイデアはありますか?
必要に応じて、詳細をお尋ねください。私が表示したコードは、可能な限り最高の理解を得るために私ができる最短のものです.
ありがとうございました !