zhangyuang / node-ffi-rs

Implement ffi in Node.js by Rust and NAPI
MIT License
191 stars 7 forks source link

Float array pointer #30

Closed liquidg3 closed 6 months ago

liquidg3 commented 7 months ago

Firstly, great work!

We've almost completely replaced ffi-napi in our platform with ffi-rs.

Here is some background on us if you're interested: https://lumenalabs.com

We're utilizing some biosensors and Lab Streaming Layer (https://labstreaminglayer.org/#/) to track different biometrics.

We are so close, but the function we are trying to call is here:

https://github.com/sccn/liblsl/blob/master/src/lsl_outlet_c.cpp#L40C1-L42C2

LIBLSL_C_API int32_t lsl_push_sample_ft(lsl_outlet out, const float *data, double timestamp) {
    return out->push_sample_noexcept(data, timestamp);
}

And we can't seem to get it to call in a way that sends any data to our neuro-engine.

Here is how we have it defined(...):

...
lsl_push_sample_ft: {
    library: 'lsl',
    retType: DataType.Void,
    paramsType: [DataType.External, DataType.DoubleArray, DataType.Double],
 },
...

It's the second paramType - the function in c++ is defined with a pointer to a float array, which we're assuming is the issues. We've tried every DataType.*Array we can find in hopes that something would be coerced to functioning, but we can't get it.

Any suggestions or enhancements would make our day!

Thanks so much!

zhangyuang commented 7 months ago

i wlill handle the issue at later

zhangyuang commented 7 months ago

It seems there can not use doubleArray type transform to floatArray, i will support DataType.floatArray ASAP

zhangyuang commented 7 months ago

Support DataType.floatArray in ffi-rs@1.0.63, you can try with the latest version

liquidg3 commented 7 months ago

That worked! Epic work! I meant to get back to you sooner actually, my bad!

zhangyuang commented 7 months ago

I am glad that the library can help you out