muss nochmal Fragen.
Die Funktion rtlsdr_read_async soll empfangene Daten vom SDR holen und in meinen Puffer stellen.
In C ist zu der Funktion folgendes codiert:
Code: Alles auswählen
// in rtl_sdr.h
#define rtlsdr_read_async_cb_t cb = void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx)
RTLSDR_API int rtlsdr_read_async(rtlsdr_dev_t *dev,
rtlsdr_read_async_cb_t cb,
void *ctx,
uint32_t buf_num,
uint32_t buf_len);
// in rtl_adsb.c
#define DEFAULT_ASYNC_BUF_NUMBER 12
#define DEFAULT_BUF_LENGTH (16 * 16384)
static rtlsdr_dev_t *dev = NULL;
static void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx)
{
memcpy(buffer, buf, len);
}
int main(int argc, char **argv)
{
rtlsdr_read_async(dev, rtlsdr_callback, (void *)(NULL),
DEFAULT_ASYNC_BUF_NUMBER,
DEFAULT_BUF_LENGTH);
}
und habe ich folgendes codiert:
Code: Alles auswählen
// in rtl_sdr.pas
type
Trtlsdr_read_async_cb_t = procedure(buf: pbyte; len: Tuint32_t; ctx: pointer); cdecl;
function rtlsdr_read_async(dev: Prtlsdr_dev_t; cb: Trtlsdr_read_async_cb_t; ctx: pointer; buf_num: Tuint32_t; buf_len: Tuint32_t): longint; cdecl; external librtlsdr;
// Unit1.pas
type
TForm1 = class(TForm)
private
procedure rtlsdr_callback(buf: pbyte; len: Tuint32_t; ctx: pointer);
const DEFAULT_ASYNC_BUF_NUMBER: Tuint32_t = 12;
const DEFAULT_BUF_LENGTH: Tuint32_t = 16*16384;
var sdropennum: Prtlsdr_dev_t;
var buffer: ^byte;
// mit GetMem(buffer, DEFAULT_BUF_LENGTH * sizeof(byte)); habe ich Speicher allociert
procedure TForm1.rtlsdr_callback(buf: pbyte; len: Tuint32_t; ctx: pointer);
begin
move(buffer, buf, len);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
h1: Trtlsdr_read_async_cb_t;
h2: pointer;
h3: Tuint32_t;
h4: Tuint32_t;
h5: longint;
begin
h1:=???
h2:=???
h3:=DEFAULT_ASYNC_BUF_NUMBER;
h4:=DEFAULT_BUF_LENGTH;
h5:=rtlsdr_read_async(sdropennum, h1, h2, h3, h4);
end;
hatte mal für h1: h1:=rtlsdr_read_async(sdropennum, rtlsdr_callback(&buffer, DEFAULT_BUF_LENGTH, nil), @buffer, DEFAULT_ASYNC_BUF_NUMBER, DEFAULT_BUF_LENGTH); angedacht.
da kommt aber die Fehlermeldung:
unit1.pas(188,86) Error: Incompatible type for arg no. 2: Got "untyped", expected "<procedure variable type of procedure(PByte;LongWord;Pointer);CDecl>"
h2 könnte eventuell nil sein.
Ich hoffe auf eine Lösung.
Danke und Gruß
Jürgen