I am working on implementing BFSK algorithm on a DSP processor and need to simulate the implementation on LINUX using predefined DSP infra files. The input data in coming in the the form of a float array. The individual bits are extracted from the input one by one. The modulated output is generated in the fprm of a typdef struct, which is a consists of two float variables (real and imaginary parts since the modulated data is a complex baseband signal). But the DSP simulation needs the output to be saved into a void pointer array. This cant be changed as the DSP APIs need it in the form of a void pointer. The definition of the struct is as follows :
typedef struct {
float re;
float im;
}complex_float;
I am able to copy the data into the void pointer using memcpy :
sigbuf=(float *)malloc(bitsPerBlk*sigLen*sizeof(complex_float));
memcpy(sigbuf, comSig, (bitsPerBlk*sigLen*sizeof(complex_float)));
sigbuf is the void pointer array where the ouput would be saved and comSig is the complex_float array where the modulated output is saved. The thing is I am not able to access the invidual values of the sigbuf array. I tried this as well
sigbuf=(complex_float *)malloc(bitsPerBlk*sigLen*sizeof(complex_float));
But still it doesnot work.
If someone can help me out it would be very helpful for me.
Thanks,
Anshu
I’m going to take a guess here. Why don’t you just make a copy of comSig to sigBuf then pass it to your API?
I don’t know the docs on your function but it sounds like your API takes a void pointer to some buffer of data and perhaps its length or number of elements.
I think you are misunderstanding what a void pointer is and what your function wants. A void pointer is just a generic pointer to some data. It’s the functions way of taking in any data, then probably casting it to your complex_float structure to operate on the data.
As a future reference to why you weren’t able to dereference a void pointer is because it has no size. You’d have to cast it to a type then you’d be able to dereference it.