({{, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer])[device] 
reads the complete contents of the buffer on a device.}, {, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer])[device,n]
reads n elements from the buffer.}, {, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer])[device,crit]
reads elements from the buffer until the device-specific criterion crit is met.}, {, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer])[device,crit,param]
reads elements associated with the parameter param. }, {, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer])[device,crit,{(Subscript[param, 1]),(Subscript[param, 2]),…}]
reads elements associated with the (Subscript[param, i]).}})

OpenersNotesSection(Spacer1)Details

A device can be specified either by a (RefLink[DeviceObject, paclet:ref/DeviceObject]) or by a string representing a device class.

(RefLink[DeviceReadBuffer, paclet:ref/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, (RefLink[DeviceReadBuffer, paclet:ref/DeviceReadBuffer]) generates a message.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

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

dev=DeviceOpen["RandomSignalDemo"]

DeviceReadBuffer[dev]

Read the specified number of elements from the buffer:

DeviceReadBuffer["RandomSignalDemo",3]

OpenersExampleSection2(Spacer1)Applications  (2)

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

dev= DeviceOpen["Serial","/dev/ttyACM0"]

Read in Arduino's response:

FromCharacterCode[DeviceReadBuffer[dev]]

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

dev= DeviceOpen["SerialDemo","*Sphero*"]

val=FromCharacterCode[{255,255,0,1,5,1,248}];

DeviceWrite[dev,val]

Read the specified number of bytes from the device buffer:

DeviceReadBuffer[dev,4]

Read the rest of the response:

DeviceReadBuffer[dev]

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

DeviceWrite[dev,val];

crit="ReadTerminator"-> 1;

DeviceReadBuffer[dev,crit]

Close the device connection:

DeviceClose[dev]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DeviceReadList, paclet:ref/DeviceReadList])  ▪  (RefLink[DeviceReadTimeSeries, paclet:ref/DeviceReadTimeSeries])  ▪  (RefLink[DeviceReadLatest, paclet:ref/DeviceReadLatest])  ▪  (RefLink[DeviceStreams, paclet:ref/DeviceStreams])  ▪  (RefLink[DeviceExecuteAsynchronous, paclet:ref/DeviceExecuteAsynchronous])  ▪  (RefLink[SocketReadMessage, paclet:ref/SocketReadMessage])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Developing Device Drivers, paclet:tutorial/DevelopingDeviceDrivers])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Using Connected Devices, paclet:guide/UsingConnectedDevices])}, {▪(RefLinkPlain[Raspberry Pi, paclet:guide/RaspberryPi])}})}})