I want to send and receive data between the mbed and matlab. That should not be a problem, just using the serial drivers (which are installed yes).
So simple Matlab script:
s1=serial('COM5');
fopen(s1);
fprintf(s1, 'Bwah');
fclose(s1);
On computer 1, windows Vista, that works fine.
On computer 2, windows XP, it does not work.
On computer 3, windows 7, it does not work.
In both cases Matlab tells me:
Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar error happens when using fwrite instead.
If I use TeraTerm it works fine. Now before you tell me to go to the Matlab forums, Matlab works fine if I write to another serial port. So the problem is really between Mbed and Matlab.
The writing part also does occur, the error happens after the (virtual) serial port gets its data. But with matlab programs exitting due to an error that does not really help me. Reading seems to be working normally.
With some googling the only relevant information I could find was:
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.
Which is nice and all, but it does not explain why it works on computer #1, and it really doesnt help me with how to solve this. Also computer 2 and 3 have nothing in common (one is a home laptop, other one is work computer, also different matlab versions, but all pretty up to date).
So has anyone encountered this before, and/or any clue how to fix this?
Edit: Well I was already searching a while, but of course right after I post a topic I find a kinda 'solution'. In matlab code use:
try
fprintf(s1, 'Vroem');
end
(And you can add a catch if you want, and then do nothing in it, Matlab now tells you you are a bad person for not using catch). It isn't exactly what you call nice way of programming, but it does work. Sending one string, and receiving two strings for over 3000 times without opening/closing the comport in matlab does not generate any errors (I was scared of bufferoverflows, if the original error prevented a buffer from being cleared). Still it would be nice if anyone knows a better way to deal with this.
btw, formatting on these forums is horrible...
I want to send and receive data between the mbed and matlab. That should not be a problem, just using the serial drivers (which are installed yes).
So simple Matlab script: s1=serial('COM5'); fopen(s1); fprintf(s1, 'Bwah'); fclose(s1);
On computer 1, windows Vista, that works fine. On computer 2, windows XP, it does not work. On computer 3, windows 7, it does not work.
In both cases Matlab tells me: Error using serial/fprintf (line 144) Unexpected Error: An error occurred during writing.
A similar error happens when using fwrite instead.
If I use TeraTerm it works fine. Now before you tell me to go to the Matlab forums, Matlab works fine if I write to another serial port. So the problem is really between Mbed and Matlab. The writing part also does occur, the error happens after the (virtual) serial port gets its data. But with matlab programs exitting due to an error that does not really help me. Reading seems to be working normally.
With some googling the only relevant information I could find was:
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.
Which is nice and all, but it does not explain why it works on computer #1, and it really doesnt help me with how to solve this. Also computer 2 and 3 have nothing in common (one is a home laptop, other one is work computer, also different matlab versions, but all pretty up to date).
So has anyone encountered this before, and/or any clue how to fix this?
Edit: Well I was already searching a while, but of course right after I post a topic I find a kinda 'solution'. In matlab code use:
(And you can add a catch if you want, and then do nothing in it, Matlab now tells you you are a bad person for not using catch). It isn't exactly what you call nice way of programming, but it does work. Sending one string, and receiving two strings for over 3000 times without opening/closing the comport in matlab does not generate any errors (I was scared of bufferoverflows, if the original error prevented a buffer from being cleared). Still it would be nice if anyone knows a better way to deal with this.
btw, formatting on these forums is horrible...