addSource
Add an input source to a data recording session
Description
addSource(
adds the specified hardware input source, dr
,src
,sourceName
)src
to data recording
session, dr
. dr
is a data recording session on
SoC hardware board created using DataRecorder
.
Examples
Record Data From SoC Hardware Board
Create a connection from MATLAB to the specified SoC hardware board using the IP address, username, and password of the board.
hw = socHardwareBoard('Xilinx Zynq ZC706 evaluation kit','hostname','192.168.1.18','username','root','password','root');
Create a data recording session on the SoC hardware board by using the
hw
object. The resulting DataRecorder
object represents the data recording session on the SoC hardware
board.
dr = soc.recorder(hw)
dr = DataRecorder with properties: HardwareName: 'Xilinx Zynq ZC706 evaluation kit' Sources: {} Recording: false
List the input sources added to the data recording session.
dr.Sources(hw)
ans = 1×0 empty cell array
By default, soc.recorder
objects have no added input sources. To add an
input source to the data recording session, first create an input source object by using the
soc.iosource
function. For this example,
create an User Datagram Protocol (UDP) source object.
udpSrc = soc.iosource(hw,'UDP Receive')
udpSrc = soc.iosource.UDPRead with properties: Main LocalPort: 25000 DataLength: 1 DataType: 'uint8' ReceiveBufferSize: -1 BlockingTime: 0 OutputVarSizeSignal: false SampleTime: 0.1000 HideEventLines: true Show all properties
Add this UDP source object to the data recording session by using the addSource
object function.
addSource(dr,udpSrc,'UDPDataReceived-Port25000')
Verify the result by inspecting the Sources
property of the soc.recorder
object.
dr.Sources
ans = 1×1 cell array {'UDPDataOnPort25000'}
Call the setup function to initialize all hardware peripheral input sources added to the data recording session, and start the data recording process.
setup(dr)
Record data for 60 seconds on the SoC hardware board.
record(dr, 60);
Check the status of the data recording session by using the isRecording
object function. The recording status when data recording is in
progress is 1
.
recordingStatus = isRecording(dr)
recordingStatus = logical 1
The recording status when data recording is complete is 0
.
isRecording(dr)
recordingStatus = logical 0
Save recorded data to a TGZ-compressed file.
save(dr,'UDPDataReceived','UDP Data Testing',{'Recorded On Zynq Board'})
This function saves the recorded data as the file UDPDataReceived.tgz
in your working folder of the host PC. You can read this file by using an socFileReader
object in MATLAB™ or an IO Data Source block
in your Simulink® model.
Remove the added source from the data recording session by using the removeSource
object function.
removeSource(dr,'UDPDataReceived-Port25000')
Verify the result by inspecting the Sources
property of the
soc.recorder
object.
ans = 1×0 empty cell array
Input Arguments
dr
— Data recording session specified for SoC hardware board
soc.recorder
object
Data recording session for specified SoC hardware board, specified as a
DataRecorder
object.
src
— Source object for specified input source
soc.iosource
object
Source object for specified input source, specified as an soc.iosource
object.
sourceName
— Name of input source in the data recording session
character vector
Name of input source in the data recording session, specified as a character vector. The function uses this name as the source name when the specified input source is recorded and saved on a dataset file.
Note
Setting sourceName
to 'all'
errors as the sourceName
'all'
is used to remove all input sources added to a
data recording session using the removeSource
function.
Version History
Introduced in R2019a
See Also
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)