SerialPC <-> MATLAB issue

09 Dec 2012

Hi all,

This is my first post here at mbed.org so bare with me ...

I'm currently involved in a research project that requires raw serial communication with MBED from MATLAB. I use this small piece of MATLAB code to set up communication:

mbed = serial('com1')
fopen(mbed)
fprintf(mbed, 'Hello MBED')

Everything seems to work fine, the data is correctly received by MBED but MATLAB throws an error:

??? Error using ==> serial.fprintf at 144
An error occurred during writing.

Since this is obviously a MATLAB issue my first instinct is to search the MATLAB website for some more information ... It seems this is not a MATLAB issue but a SerialPC driver problem:

Quote:

To determine if the data has been written completely, the MATLAB serial object tries to flush the data out after writing. Some older USB->RS232 drivers do not properly support this operation resulting in an error. Make sure that you have the latest driver from the vendor of your USB->RS232 dongle as these drivers have improved significantly in recent years.

Found at http://http://www.mathworks.com/matlabcentral/newsreader/view_thread/299738

Can someone please shed some light on this issue and/or provide a workaround

Thanks,

KK

09 Dec 2012

Hey,

You aren't only one with the issue, and that was indeed also all information I managed to find. See this topic: http://mbed.org/forum/helloworld/topic/3568/

Known solutions are either downgrading to matlab 2009 or earlier, or putting each printf inside a try statement. A really ugly solution, but as you said the data is received by the mbed, and when you put it in a try statement it ignores the errors thrown.

16 Dec 2012

i did it on matlab 2009 and it worked perfectly.

16 Dec 2012

RPC library works perfect for MATLAB 2009 or later versions......... But if you are using an earlier version then this library wont works........