fclose (serial)
Disconnect serial port object from device
Syntax
fclose(obj)
Description
fclose(obj)
disconnectsobj
from the device, whereobj
is a serial port object or an array of serial port objects.
Examples
This example creates the serial port objects
on a Windows®platform, connectss
to the device, writes and reads text data, and then disconnectss
from the device usingfclose
.
s = serial('COM1'); fopen(s) fprintf(s,'*IDN?') idn = fscanf(s); fclose(s)
At this point, the device is available to be connected to a serial port object. If you no longer needs
,你应该从内存中删除delete
function, and remove it from the workspace with theclear
command.
Tips
Ifobj
was successfully disconnected, then theStatus
property is configured toclosed
and theRecordStatus
property is configured tooff
. You can reconnectobj
to the device using thefopen
function.
An error is returned if you issuefclose
while data is being written asynchronously. In this case, you should abort the write operation with thestopasync
function, or wait for the write operation to complete.