MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Bedienungsanleitung Seite 354

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 408
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 353
8 Serial Port I/O
8-34
As shown below, after the string is written to the output buffer, it is then
written to the device via the serial port.
Writing Text Data
You use the fprintf function to write text data to the device. For many devices,
writing text data means writing string commands that change device settings,
prepare the device to return data or status information, and so on.
For example, the
Display:Contrast command changes the display contrast of
the oscilloscope.
s = serial('COM1');
fopen(s)
fprintf(s,'Display:Contrast 45')
By default, fprintf writes data using the %s\n format since many serial port
devices accept only text-based commands. However, you can specify many
other formats as described in the
fprintf reference pages.
You can verify the number of values sent to the device with the
ValuesSent
property.
s.ValuesSent
ans =
20
COM1
...
Output Buffer
Bytes used during write
Bytes unused during write
6 values
6 bytes
Serial Port I/O Hardware Instrument
*IDN?
Seitenansicht 353
1 2 ... 349 350 351 352 353 354 355 356 357 358 359 ... 407 408

Kommentare zu diesen Handbüchern

Keine Kommentare