Serial Communication terminator query
1 次查看(过去 30 天)
显示 更早的评论
hello, i am trying to obtain data string from a serial comm port. i should be getting the string and LF/CR to the end.
i have tried to configure the port accordingly as :
handles.s= serial('COM1','BaudRate',9600,'DataBits',8,'Parity','none','StopBits',1, 'BytesAvailableFcnMode','Terminator','BytesAvailableFcn', {@Data_Fcn_Callback},'Terminator','LF/CR');
where @Data_Fcn_Callback is the function i want to be executed on receiving Lf/CR.
But the BytesAvailableFcnMode info from help states : 'You can configure BytesAvailableFcnMode only when the object is disconnected from the device.You disconnect an object with the fclose function. A disconnected object has a Status property value of closed.' I am unable to understand how to obtain data in such case.
Am i right in my procedure ? other ways/suggestions to do the same task will be appreciated .
Thank you.
0 个评论
回答(1 个)
Jan
2012-12-19
You forgot to explain, if your program works as expected.
The help text means, that you cannot change the 'BytesAvailableFcnMode' property after the serial object has been opened. Your code does define this peroperty before calling fopen. Therefore everything should be ok.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Acquisition Toolbox Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!