Hi Josh,
I am trying to send messages to Bonsai through the virtual serial COM on state machine r2 with v23 firmware.
Here is my matlab code:
function ConnectBonsai
% Open water Valve to clean the tube - LY, 12/19/2019
global BpodSystem
Interval = 5 ;
%% main section
for currentTrial=1:10
sma = NewStateMatrix();
% sma = AddState(sma, 'Name', 'GETSoftCode2APP', ...
% 'Timer', 0,...
% 'StateChangeConditions', {'APP_SoftCode10', 'SendSoftCode2APP'},...
% 'OutputActions', {});
sma = AddState(sma, 'Name', 'SendSoftCode2APP', ...
'Timer', 0.1,...
'StateChangeConditions', {'Tup', 'Interval'},...
'OutputActions', {'APP_SoftCode', 1});
sma = AddState(sma, 'Name', 'Interval', ...
'Timer', Interval,...
'StateChangeConditions', {'Tup', '>exit'},...
'OutputActions', {});
SendStateMatrix(sma);
RunStateMatrix();
disp(['Trial #' num2str(currentTrial)]);
if BpodSystem.Status.BeingUsed== 0
return;
end
end
end
Attached is my Bonsai workflow.
I am not sure about the settings in the BaudRate of CreateSerialPort node and the newline of SerialStringRead node.
Can you help me make this work?
Thanks,
Lei