MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manual de usuario Pagina 360

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 408
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 359
8 Serial Port I/O
8-40
You can verify the number of values read from the device – including the
terminator – with the
ValuesReceived property.
s.ValuesReceived
ans =
56
Synchronous Versus Asynchronous Read Operations.
You specify whether read
operations are synchronous or asynchronous with the
ReadAsyncMode property.
You can configure
ReadAsyncMode to continuous or manual.
If
ReadAsyncMode is continuous (the default value), the serial port object
continuously queries the device to determine if data is available to be read. If
data is available, it is asynchronously stored in the input buffer. To transfer the
data from the input buffer to MATLAB, you use one of the synchronous
(blocking) read functions such as
fgetl or fscanf. If data is available in the
input buffer, these functions will return quickly.
s.ReadAsyncMode = 'continuous';
fprintf(s,'*IDN?')
s.BytesAvailable
ans =
56
out = fscanf(s);
If ReadAsyncMode is manual, the serial port object does not continuously query
the device to determine if data is available to be read. To read data
asynchronously, you use the
readasync function.You then use one of the
synchronous read functions to transfer data from the input buffer to MATLAB.
s.ReadAsyncMode = 'manual';
fprintf(s,'*IDN?')
s.BytesAvailable
ans =
0
readasync(s)
s.BytesAvailable
ans =
56
out = fscanf(s);
Vista de pagina 359
1 2 ... 355 356 357 358 359 360 361 362 363 364 365 ... 407 408

Comentarios a estos manuales

Sin comentarios