Closed yukih00 closed 3 years ago
Dear yukih00,
I am very glad for understanding that you continue the exploration of our API, it will be a pleasure to support you regarding this issue! Thank you very much for opening a new discussion, it is very helpful for us and will certainly be for other members of the community.
A few moments ago I had the opportunity to test your script and to replicate the issue. Your perception is totally correct, the connection with the device fails, it seems that the API has a small limitation but fortunately it can be easily overtaken.
Before clicking on X key (to establish a connection with PLUX device) you should always execute a Bluetooth scan and connect to one of the found devices instead of having a fixed configuration (a constant macAddress.
If you follow the Scan >> Connection workflow the NullReferenceException
will probably disappear. Note that sometimes the connection is not established with success at the first try, so, it could be necessary to try to connect more than once.
After a successful connection (flagged by the call of ConnectionDone()
callback) you will be able to start a real-time acquisition by pressing C. However, you should change the PDM.StartAcquisitionUnity(100, new List<int>() { 1,2,3,4}, 16);
call, replacing 16
by 10
, because BITalino only supports acquisitions using 10 bits resolution (when 4 or less channels are active) or 6 bits (if more than 4 channels are active).
In addition, if you want to manually stop the acquisition, it will probably be necessary to apply a very simple edit in the phase == 1
if clause:
[...]
else if (phase == 1)
{
//Sampling
data = PDM.GetPackageOfData(true);
TS = TS + Time.deltaTime;
//Output
Output();
if (Input.GetKeyDown(KeyCode.V))
{
PDM.StopAcquisitionUnity();
}
}
I truly hope that the previous information could be helpful, however, if you don't consider them totally enlightening or if further questions/issues arise, please, do not hesitate to alert us!
My best and sincere regards, GRamosPlux
In order to measure pulse and EDA data, I wrote a C# script. But the script provided errors such as Null reference exception. I guest that the connection between Unity and the device (PsychoBIT) failed or a function “StartAcquisitionUnity” was incorrectly used. The script was found in https://1drv.ms/u/s!AlgXmeFIkeV9tvFiblDQWhOsjnbFug?e=0rwRcJ.
Could you provide some advices to me?
best, yukih00