3.10 TCP (Deprecated)

3.10.1 @octave_tcp/fclose

Function File: res = fclose (obj)

Closes TCP connection obj

3.10.2 @octave_tcp/flush

: data = flush (dev)
: data = flush (dev, "input")
: data = flush (dev, "output")

Flush the tcp socket buffers

Inputs

dev - connected tcp device

If an additional parameter is provided of "input" or "output", then only the input or output buffer will be flushed

Outputs

None

See also: serialport.

3.10.3 @octave_tcp/flushinput

Loadable Function: flushinput (tcp)

Flush the pending input, which will also make the BytesAvailable property be 0.

Inputs

tcp - instance of octave_tcp class.

Outputs

None.

See also: flushoutput.

3.10.4 @octave_tcp/flushoutput

Loadable Function: flushoutput (tcp)

Flush the output buffer.

Inputs

tcp - instance of octave_tcp class.

Outputs

None.

See also: flushinput.

3.10.5 @octave_tcp/fopen

Function File: res = fopen (obj) (dummy)

Opens TCP connection obj

This currently is a dummy function to improve compatibility to MATLAB

3.10.6 @octave_tcp/fprintf

Function File: numbytes = fprintf (obj, template ...)

Writes formatted string template using optional parameters to TCP instrument

Inputs

obj is a TCP object.
template Format template string

Outputs

Number of characters written

3.10.7 @octave_tcp/fread

Function File: data = fread (obj)
Function File: data = fread (obj, size)
Function File: data = fread (obj, size, precision)
Function File: [data,count] = fread (obj, ...)
Function File: [data,count,errmsg] = fread (obj, ...)

Reads data from TCP instrument

Inputs

obj is a TCP object.
size Number of values to read. (Default: 100).
precision precision of data.

Outputs

data data read.
count values read.
errmsg read operation error message.

3.10.8 @octave_tcp/fwrite

Function File: numbytes = fwrite (obj, data)
Function File: numbytes = fwrite (obj, data, precision)

Writes data to TCP instrument

Inputs

obj is a TCP object.
data data to write.
precision precision of data.

Outputs

returns number of bytes written.

3.10.9 @octave_tcp/get

Function File: struct = get (tcp)
Function File: field = get (tcp, property)

Get the properties of tcp object.

Inputs

tcp - instance of octave_tcp class.
property - name of property.

Outputs

When property was specified, return the value of that property.
otherwise return the values of all properties as a structure.

See also: @octave_tcp/set.

3.10.10 @octave_tcp/read

Function File: data = read (obj)
Function File: data = read (obj, size)
Function File: data = read (obj, size, datatype)

Reads data from TCP instrument

Inputs

obj is a TCP object.
size Number of values to read. (Default: 100).
datatype datatype of data.

Outputs

data data read.

3.10.11 @octave_tcp/set

Function File: set (obj, property,value)
Function File: set (obj, property,value,…)

Set the properties of tcp object.

Inputs

If property is a cell so must be value, it sets the values of all matching properties.

The function also accepts property-value pairs.

Properties

’name’

Set the name for the tcp socket.

’remotehost’

Set the remote host name for the tcp socket.

’remoteport’

Set the remote port for the tcp socket.

’timeout’

Set the timeout value in seconds. Value of -1 means a blocking call.

Outputs

None

See also: @octave_tcp/get.

3.10.12 @octave_tcp/write

Function File: numbytes = write (obj, data)
Function File: numbytes = write (obj, data, datatype)

Writes data to TCP instrument

Inputs

obj is a TCP object.
data data to write.
datatype datatype of data. If not specified, it defaults to "uint8".

Outputs

returns number of bytes written.

3.10.13 tcp

Loadable Function: tcp = tcp ()
Loadable Function: tcp = tcp (ipaddress)
Loadable Function: tcp = tcp (ipaddress, port)
Loadable Function: tcp = tcp (ipaddress, port, timeout)
Loadable Function: tcp = tcp (ipaddress, [propertyname, propertyvalue])
Loadable Function: tcp = tcp (ipaddress, port, [propertyname, propertyvalue])

Open tcp interface.

Inputs

ipaddress - the ip address of type String. If omitted defaults to ’127.0.0.1’.
port - the port number to connect. If omitted defaults to 23.
timeout - the interface timeout value. If omitted defaults to blocking call.
propname,propvalue - property name/value pairs.

Known input properties:

name

name value

timeout

Numeric timeout value or -1 to wait forever

Outputs

The tcp() shall return instance of octave_tcp class as the result tcp.

Properties

The tcp object has the following public properties:

name

name assigned to the tcp object

type

instrument type ’tcp’ (readonly)

localport

local port number (readonly)

remoteport

remote port number

remotehost

remote host

status

status of the object ’open’ or ’closed’ (readonly)

timeout

timeout value in seconds used for waiting for data

bytesavailable

number of bytes currently available to read (readonly)

3.10.14 tcp_close

Loadable Function: tcp_close (tcp)

Close the interface and release a file descriptor.

Inputs

tcp - instance of octave_tcp class.

Outputs

None

3.10.15 tcp_read

Loadable Function: [data, count] = tcp_read (tcp, n, timeout)

Read from tcp interface.

Inputs

tcp - instance of octave_tcp class.
n - number of bytes to attempt to read of type Integer
timeout - timeout in ms if different from default of type Integer

Outputs

count - number of bytes successfully read as an Integer
data - data bytes themselves as uint8 array.

3.10.16 tcp_timeout

Loadable Function: tcp_timeout (tcp, timeout)
Loadable Function: t = tcp_timeout (tcp)

Set new or get existing tcp interface timeout parameter used for tcp_read() requests. The timeout value is specified in milliseconds.

Inputs

tcp - instance of octave_tcp class.
timeout - tcp_read() timeout value in milliseconds. Value of -1 means a blocking call.

Outputs

If timeout parameter is omitted, the tcp_timeout() shall return current timeout value as the result t.

3.10.17 tcp_write

Loadable Function: n = tcp_write (tcp, data)

Write data to a tcp interface.

Inputs

tcp - instance of octave_tcp class.
data - data to be written to the tcp interface. Can be either of String or uint8 type.

Outputs

Upon successful completion, tcp_write() shall return the number of bytes written as the result n.

3.10.18 tcpip

Function File: tcp = tcpip (host, [port], [PropertyName, PropertyValue...])

Matlab compatible wrapper to the tcp interface.

NOTE: tcpip has been deprecated. Use tcpclient instead

Inputs

host - the host name or ip.
port - the port number to connect. If omitted defaults to 80.
PropertyName, PropertyValue - Optional property name, value pairs to set on the tcp object.

Properties

Currently the only known properties are "timeout" and "name".

Outputs

tcpip will return an instance of octave_tcp class as the result.