Create a UDP port.
Attention: Valid only with Altair Communication Extension.
Syntax
uobj = udpport()
uobj = udpport([Name, value])
Inputs
- Name, value
- Name
- Type: string
- Valid options are:
- Name
- Value
- Timeout
- Numeric value in seconds, time given for read operation to finish. Negative
value to wait forever.
- Type: double
- ByteOrder
- Valid values are 'network' and 'host'
(default).
- Type: string
- LocalHost
- Ip address.
- Type: string
- LocalPort
- Numeric port number.
- Type: scalar
- EnablePortSharing
- Enables port sharing.
- Type: scalar
Outputs
- uobj
- UDP port object.
- Type: UDP port
- property, values
- Type: string
- Valid options are:
- Property Name
- Description/Values
- ByteOrder
- Byte order used for read/write.Valid values are 'network' and
'host' (default).
- Type: string
- Timeout
- Numeric value in seconds, time given for read operation to finish. Negative
value to wait forever.
- Type: double
- Sock
- Socket. Readonly property.
- Type: scalar
- Name
- Name of the udpport object. Readonly property.
- Type: string
- Type
- Value is 'UDP'. Readonly property.
- Type: string
- LocalPort
- Port number.Readonly property.
- Type: scalar
- LocalHost
- Ip address.Readonly property.
- Type: string
- DestPort
- Last used destination port number.Readonly property.
- Type: scalar
- DestIp
- Last used destination ip address.Readonly property.
- Type: string
- Status
- Connection status.Readonly property.
- Type: string
- NumBytesAvailable
- Number of bytes available to read. Readonly property.
- Type: scalar
- Terminator
- Termination caharacter used read/write string data. Readonly property.
- Type: scalar | string
- WriteDataType
- Data type used to write data. Readonly property.
- Type: string
- ReadDataType
- Data type used to read data. Readonly property.
- Type: string
- EnablePortSharing
- Enables port sharing. Readonly property.
- Type: scalar
- Function Name, Syntax
- Type: string
- Valid options are:
- Function Name
- Description/Syntax/Arguments
- read
- reads data.
- data=read() data=read(NumberOfBytes) data=read(NumberOfBytes,DataType)
NumberOfBytes is a scalar. Supported "DataType" values are 'string', 'double'
,'int8','int16','int32','int64','uint8','uint16','uint32','uint64'.
- write
- writes data.
- data=write(Data) data=write(Data,DataType) data=write(Data,DataType,
DestinationIP, DestinationPort) Supported type for "Data" is string, real number,
real matrix. Supported "DataType" values are 'string', 'double'
,'int8','int16','int32','int64','uint8','uint16','uint32','uint64'. Destination ip
is a string. Destination port is a number. Destination ip and port numbers are
used from previous write operation if not provided.
- close
- Closes connection.
Examples
read/write string data
sobj=udpport();
cobj=udpport();
cobj.write('Hello Server','string',sobj.LocalHost, sobj.LocalPort);
sobj.read()
sobj.write('Hello Client','string',cobj.LocalHost, cobj.LocalPort);
cobj.read()
sobj.close();
cobj.close();
ans = Hello Server
ans = Hello Client
read/write numeric data
sobj=udpport();
cobj=udpport();
data=[1,2,3,4];
cobj.write(data,'double',sobj.LocalHost, sobj.LocalPort);
clientdata=sobj.read(4,'double')
data=99;
sobj.write(data,'int32',cobj.LocalHost, cobj.LocalPort);
serverdata=cobj.read(1,'int32')
sobj.close();
cobj.close();
clientdata = [Matrix] 1 x 4
1 2 3 4
serverdata = 99