DeviceReadBuffer

DeviceReadBuffer[device]

reads the complete contents of the buffer on a device.

DeviceReadBuffer[device,n]

reads n elements from the buffer.

DeviceReadBuffer[device,crit]

reads elements from the buffer until the device-specific criterion crit is met.

DeviceReadBuffer[device,crit,param]

reads elements associated with the parameter param.

DeviceReadBuffer[device,crit,{param1,param2,}]

reads elements associated with the parami.

Details

  • A device can be specified either by a DeviceObject or by a string representing a device class.
  • DeviceReadBuffer is a blocking function; when called, it communicates with the device and does not return until it has the data it needs.
  • Not all devices have buffers. For those that do not, DeviceReadBuffer generates a message.

Examples

open allclose all

Basic Examples  (2)

Open a demo device and read the contents of its buffer:

Read the specified number of elements from the buffer:

Applications  (2)

Open a serial connection to an Arduino device running a custom program called sketch:

Read in Arduino's response:

Write a string of bytes to a Sphero serial device after opening a connection to it:

Read the specified number of bytes from the device buffer:

Read the rest of the response:

Write the same values and read the buffered response until a specified terminator is encountered:

Close the device connection:

Introduced in 2014
 (10.0)