Slow communication with NA though LAN cable, using the fread fucntion
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Slow communication with NA, I use direct Lan cable for connection: I use the TCPIP to connect to a Network Analyzer using the following code:
obj_e5080_ = tcpip('169.254.64.111', 5025); obj_e5080_.InputBufferSize = 1e5; obj_e5080_.OutputBufferSize = 1e5; obj_e5080_.ByteOrder = 'littleEndian';
Then I want to check the elapsed time for reading the data using this code:
tic fprintf(obj_e5080_, ':INITiate:IMMediate'); opc1 = sscanf(query(obj_e5080_, '*OPC?'), '%d'); fprintf(obj_e5080_,':CALCulate:MEASure:DATA:SDATa?'); sdata1 = fread(obj_e5080_,81,'double'); toc
However, the results are not good and it is very slow: Elapsed time = 0.2 seconds, can Anyone help please?
I attached the real time results as well
0 Commenti
Risposte (1)
Tony Mohan Varghese
il 14 Ago 2017
The issue may be related to this line:
sdata1 = fread(obj_e5080_,81,'double');
fread function will read data as double precision and stores them as double array. This is a memory heavy operation and is thus slow. I would suggest to read the data as characters and convert them back to double array later.
It was also observed that fread takes much longer to execute when the default terminator setting is used / Terminator is not empty (“”). This behavior is mentioned in the FREAD doc page:
See "Note: Set the terminator property to '' (null), if appropriate, to ensure efficient throughput of binary data." Try to use a null/empty terminator .
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!