zedboardでスイッチ値を読み取っているカスタムソースブロックを作成しました。私が書いたprocドライバを使ってそれらにアクセスしています。 /var/log/kern.logが適切な出力を報告しています。ソースブロックのデバッグprintfが適切な出力を報告しています。gnuradioソースのみに0を出力する
ただし、ファイルシンクだけでなくGUI番号シンクにもデータをプッシュすると、ゼロが読み取られます。ブロックを適切にセットアップしていませんか?
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "switches_impl.h"
#include <stdio.h>
#include <stdlib.h>
#include <uinstd.h>
namespace gr {
namespace zedboard {
switches::sptr
switches::make()
{
return gnuradio::get_initial_sptr
(new switches_impl());
}
/*
* The private constructor
*/
switches_impl::switches_impl()
: gr::block("switches",
gr::io_signature::make(0,0,0),
gr::io_signature::make(1, 1, sizeof(unsigned int *)))
{}
/*
* Our virtual destructor.
*/
switches_impl::~switches_impl()
{
}
void
switches_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
/* <+forecast+> e.g. ninput_items_required[0] = noutput_items */
}
int
switches_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 <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0];
unsigned int *out = (unsigned int *) output_items[0];
// Do <+signal processing+>
// Tell runtime system how many input items we consumed on
// each input stream.
char buffer[5];
size_t size = 1;
size_t nitems = 5;
FILE* fp;
fp = fopen("/proc/zedSwitches","r");
if (fp == NULL)
{
printf("Cannot open for read\n");
return -1;
}
/*
Expect return format:
0x00
*/
fread(buffer, size, nitems, fp);
fclose(fp);
out=(unsigned int *)strtoul(buffer,NULL,0);
printf("read: 0x%02x",out);
consume_each (noutput_items);
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace zedboard */
} /* namespace gr */
ありがとう、私はこれを通過します。私はソースを指定するのではなく、gr_modtoolから一般的なブロックを作りました...私はff_squareブロックを作成する際のガイドラインに従っていましたが、これをあまりにも多く作成するための準備は本当にありませんでした。私はしばらくこのソースと別のシンクに苦労してきました。入力いただきありがとうございます! – gutelfuldead
ええ、 'square_ff'の例は、私がGNU Radio wikiについて本当に好きでないものの1つかもしれません。本当に、ガイド付きのチュートリアルはあなたに良いイントロを与えるのに適しています! :) –