kernelv_sync_read_write_request()

Prototype

signed long int

SyncReadWriteRequest<T>(

ushort port,

uint indexGroup,

uint indexOffset,

T writeValue,

out T readValue,

out uint readLength);

Description

Synchronous writing and reading of variables. The variables are identified by Port, indexGroup and indexOffset.

When called, the data pointer contains the data to be written. Specify in writeLength the length of the data area to be written in bytes. Enter the number of bytes to be read in the realLength pointer.

The data read is saved to the memory to which the data pointer points and the number of bytes written is written to *readLength.

At present, the following ports are supported:

Port number

CNC task

551

GEO task

552

SDA task

The meaning of indexGroup and indexOffset depends on the addressed port and can be found in the documentation.

An error code is returned if the function is called while the CNC kernel has not yet started.

Parameter

Name

Type

Meaning

port

ushort

Port from which the data is to be read and written.

indexGroup

uint

Index group of data item to be read and written.

indexOffset

uint

Index offset of data item to be read and written.

writeValue

T

Value to be written. Can be a primitive type (int, float, uint, …) or a structured data structure (struct).

readValue

out T

Returns the read value after successful function call. The data type corresponds the writeValue type.

readLength

out uint

Number of actually read bytes. The maximum read length corresponding to the size of T is transferred internally at call.

Return values

Symbol

Value

Meaning

 

0

The function was executed without error.

 

-3

The simulation CNC kernel was not yet initialised.

ERR_CNC_RET_MEMORY

-4

The return value(s) does/do not fit into the memory provided.

 

6

The transferred port number is not known.

 

0x701

The requested service is not supported.

 

0x702

Index group is invalid.

 

0x703

Index offset is invalid

 

0x704

The variable addressed must not be written.

 

0x705

The data to be written does not match the addressed variable.

 

0x706

The job cannot be executed.

Possible reasons are:

  • invalid data on write accesses or
  • invalid state of kernelv, e.g. list updating while CNC channel is in error.