TomE8
TomE8

Reputation: 576

control timeout valus in udp communication matlab

How can I chane the "timeout" value in UDP communication? I get this warning:

Warning: Unsuccessful read:  The specified amount of data was not returned within the Timeout period. 

and I want to increase the timeout value so I will not expireance this warning...

Upvotes: 0

Views: 767

Answers (1)

Daniel
Daniel

Reputation: 36710

To set a timeout, you can use:

u.Timeout=99;

In this case the timeout property is not documented, at least I am unable to find any documentation. When working with unknown or not fully documented objects, I typically try get methods and properties to examine them:

>> methods(x)

Methods for class udp:

Contents       eq             fscanf         instrhelp      ne             size           
binblockread   fclose         fwrite         instrhwinfo    obj2mfile      stopasync      
binblockwrite  fgetl          get            instrnotify    open           subsasgn       
class          fgets          horzcat        instrument     openvar        subsref        
close          fieldnames     icinterface    isa            propinfo       udp            
ctranspose     flushinput     igetfield      isequal        query          vertcat        
delete         flushoutput    inspect        isetfield      readasync                     
disp           fopen          instrcallback  isvalid        record                        
display        fprintf        instrfind      length         scanstr                       
end            fread          instrfindall   methods        set                           

>> properties(x)

No properties for class udp or no class udp.

>> get(x)
    ByteOrder = bigEndian
    BytesAvailable = 0
    BytesAvailableFcn = 
    BytesAvailableFcnCount = 48
    BytesAvailableFcnMode = terminator
    BytesToOutput = 0
    ErrorFcn = 
    InputBufferSize = 512
    Name = UDP-127.0.0.1
    ObjectVisibility = on
    OutputBufferSize = 512
    OutputEmptyFcn = 
    RecordDetail = compact
    RecordMode = overwrite
    RecordName = record.txt
    RecordStatus = off
    Status = open
    Tag = 
    Timeout = 3
    TimerFcn = 
    TimerPeriod = 1
    TransferStatus = idle
    Type = udp
    UserData = []
    ValuesReceived = 0
    ValuesSent = 0

    UDP specific properties:
    DatagramAddress = 
    DatagramPort = []
    DatagramReceivedFcn = 
    DatagramTerminateMode = on
    InputDatagramPacketSize = 512
    LocalHost = 
    LocalPort = 52148
    LocalPortMode = auto
    OutputDatagramPacketSize = 512
    ReadAsyncMode = continuous
    RemoteHost = 127.0.0.1
    RemotePort = 9090
    Terminator = LF

Note that get is not always supported. In case you receive Error using get Conversion to double from A is not possible. the other two methods display everything accessible.

Upvotes: 1

Related Questions