Why do I get ‘An error occurred during writing’ error when writing data to a virtual serial port?
I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it?I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it? I am a using a virtual COM serial port (created with drivers from an USB-RS232 adapter, Bluetooth adapter, or TCP/IP COM port redirector), and the serial communication object in MATLAB version R2013a (or equivalent serial object in the Instrument Control Toolbox).
However, upon writing data to the port with FPRINTF or FWRITE I get an ‘Unexpected Error: An error occurred during writing.’, even though the data has been written successfully to the device.
s=serial(‘COM4’);
fopen(s);
fprintf(s, ‘abc’);
ERROR: Error using serial/fprintf (line 144)
Unexpected Error: An error occurred during writing.
A similar behavior and error message is observed with FWRITE:
s=serial(‘COM4’);
fopen(s);
fwrite(s, [97 98 99]);
ERROR: Error using serial/fwrite (line 199)
Unsuccessful write: An error occurred during writing.
I have tested that a 3rd party software can write data to the virtual serial port with no error.
Why do I get these errors and what can I do about it? serial, com, rs232, rs-232, fwrite, fprintf MATLAB Answers — New Questions