({{, (RefLink[DeviceExecute, paclet:ref/DeviceExecute])[device,"command"] 
executes the specified command on a device.}, {, (RefLink[DeviceExecute, paclet:ref/DeviceExecute])[device,"command",params]
executes the command with the parameters params.}})

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[DeviceExecute, paclet:ref/DeviceExecute]) is a blocking function; when called, it communicates with the device and does not return until it has the data it needs.

The parameters params can be given either as a list of raw parameters or as an association or list of rules giving names and values of parameters.

(RefLink[DeviceExecute, paclet:ref/DeviceExecute]) returns a Wolfram Language version of the result of executing the specified command on the device.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Open a demo device and execute a command on it:

dev= DeviceOpen["FunctionDemo"]

DeviceExecute[dev,"Date"]

Specify a device class to execute the same command:

DeviceExecute["FunctionDemo","Date"]

Execute a command with a specified parameter:

command="DayName";param=Today;

DeviceExecute["FunctionDemo",command,param]

OpenersExampleSection2(Spacer1)Applications  (2)

Open a weather station and write a string to its LCD screen:

dev=DeviceOpen["TinkerForgeWeatherStation"]

DeviceConfigure[dev,"LCDBrickletUID"-> "gLp"];DeviceWrite[dev,"This is a string"];

Use (RefLink[DeviceExecute, paclet:ref/DeviceExecute]) to clear the screen:

DeviceExecute[dev,"ClearLCDDisplay"]

Write a string of bytes to a Sphero serial device and use (RefLink[DeviceExecute, paclet:ref/DeviceExecute]) to check if a response is available:

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

DeviceWrite[dev,FromCharacterCode[{255,255,0,1,5,1,248}]];

DeviceExecute[dev,"SerialReadyQ"]

Flush the buffered data and check that the buffer is empty:

DeviceExecute[dev,"ReadFlush"]

DeviceExecute[dev,"SerialReadyQ"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[DeviceExecuteAsynchronous, paclet:ref/DeviceExecuteAsynchronous])  ▪  (RefLink[DeviceWrite, paclet:ref/DeviceWrite])  ▪  (RefLink[DeviceRead, paclet:ref/DeviceRead])  ▪  (RefLink[DeviceStreams, paclet:ref/DeviceStreams])}})}})

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Using Connected Devices, paclet:guide/UsingConnectedDevices])}, {▪(RefLinkPlain[Background & Scheduled Tasks, paclet:guide/BackgroundAndScheduledTasks])}, {▪(RefLinkPlain[Arduino, paclet:guide/Arduino])}, {▪(RefLinkPlain[Raspberry Pi, paclet:guide/RaspberryPi])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}})}})