Hi Josh,
I have another issue with the analog input module after I started using TrialManager in my protocol. I am using the analog input module to monitor and record the signals from a joystick. My protocol consists of a state for triggering the start of logging of the analog signals and another state for triggering the stop of logging of the analog signals. I also have a line "BpodSystem.Data.Rawevents.Trial(currentTrial).JS = A.getData.y" at the end of my main loop for saving the voltage data recorded in each trial. This was working fine when I was using an equivalent protocol that is based on RunStateMachine() before. However, once I have changed the code into TrialManager-based, I get the following error immediately or after running a few trials:
Error using ArCOMObject_Ain/read (line 290)
Error: The serial port returned 0 bytes.
Error in BpodAnalogIn/getData (line 381)
nSamples = double(obj.Port.read(1, 'uint32'));
Error in Joystick_TrialManager (line 226)
BpodSystem.Data.RawEvents.Trial{currentTrial}.JS = A.getData.y;
Error in run (line 91)
evalin('caller', strcat(script, ';'));
Error in NewLaunchManager>LaunchProtocol (line 707)
run(ProtocolPath);
Error while evaluating DestroyedObject Callback.
For the first few trials that could be run through occasionally, the logging of the analog inputs seems to be terminated at a timing that is earlier than what it should be. Also, the analog input module will go into a "crashed" state such that the red light inside it will be completely turned off and I will have to unplug the USB cable to make it functions again.
Do you know how to fix this issue?
Many thanks,
Tin
P.S. I noticed that in TrialManager-based protocol, the serial interface seems to work in a slightly different way? For example, I get an error saying "The last state machine sent was not acknowledged by the Bpod device" if I start logging by "AnalogIn1, ['L' 1]", which didn't occur in my old RunStateMachine-based protocols. This is also not specific to the analog input module, as the same thing happens in "WavePlayer1" as well. However, I was able to solve this issue by using LoadSerialMessages().