Skip to main content

VoE (Vendor over EtherCAT)

The VoE protocol carries vendor-defined data and follows the ETG.1000.6 mailbox communication specification (Mailbox Type 0x0F). Each vendor can define its own VoE header format and data structures.

Accessed through slave.VoE. null when the slave does not support VoE.​

Properties​

CategoryPropertyTypeRead/writeDescription
Protocol capabilityIsSupportedboolread-onlybool view of VoESupport == true: true only for "known supported", false when the conclusion is unknown
VoESupportbool?read-onlyVoE capability tri-state: true = supported, false = mbx_proto was actually read and the bit is not set, null = unknown (read failed)
IsSupportedKnownboolread-onlyWhether the capability conclusion is known; false = unknown (not the same as unsupported)
TimeoutDefaultTimeoutMsintread/writeDefault timeout reference (milliseconds), 500 by default. When a method omits timeoutMs it always runs with 500 ms; pass another timeout explicitly if you need one
StructureVoEHeaderSizeintconstantVoE header size (6 bytes: VendorID 4 + VendorType 2)
StateLastStatusMailboxStatusread-onlyStatus of the most recent mailbox transaction (MailboxStatus enum)
ErrorLastErrorCodeuintread-onlyMost recent error value (raw uint, not an enum)
FilteringAllowedVendorIdsHashSet<uint>read-onlyVendorID allow-list (empty list + StrictVendorFilter false = allow all)
StrictVendorFilterboolread/writeStrict mode: when true, an empty allow-list also rejects send and receive; false by default
StatisticsStatisticsReadFailedboolread-onlyWhether the most recent mailbox statistics read failed; when true, Statistics returns an empty snapshot and the values are not trustworthy
Capability tri-state

VoESupport returns bool?: true = supported, false = SII mbx_proto was actually read and the bit is not set, null = this read failed (the call failed). A failed read is no longer folded into false; to tell "confirmed unsupported" from "unknown", check VoESupport / IsSupportedKnown.

StatisticsReadFailed​

public bool StatisticsReadFailed { get; }

Whether the most recent mailbox statistics read failed. The shape returned by Statistics is fixed: on a failed read it returns an empty snapshot, so this property is required to tell "genuinely empty" from "not read this time".

note

This property reflects only the success or failure of the statistics read; it does not trigger a retry. LastStatus and LastErrorCode are the cached result of the most recent operation and are not reflected by this property.

Example:

var stats = slave.VoE.Statistics;
if (slave.VoE.StatisticsReadFailed)
Console.WriteLine("统计读取失败,本次数值不可信"); // Statistics read failed, this reading is not trustworthy
else
Console.WriteLine($"累计发送: {stats.TotalSent}"); // Total sent: {stats.TotalSent}

Basic operations​

Send(uint vendorId, ushort vendorType, byte[] data, int timeoutMs = 500)​

public bool Send(uint vendorId, ushort vendorType, byte[] data, int timeoutMs = 500)

Sends VoE data to the slave.

Parameters:

  • vendorId (uint) — vendor ID (4 bytes)
  • vendorType (ushort) — vendor type (2 bytes)
  • data (byte[]) — data to send
  • timeoutMs (int) — timeout (milliseconds)

Return value:

  • bool — true on success

Example:

slave.VoE.Send(0x00000002, 0x0001, new byte[] { 0x01, 0x02, 0x03 });

Receive(int timeoutMs = 500)​

public VoEResponse? Receive(int timeoutMs = 500)

Receives VoE data from the slave.

Return value:

  • VoEResponse? — VoE response object; null on failure

SendAndReceive(uint vendorId, ushort vendorType, byte[] data, int timeoutMs = 500)​

public VoEResponse? SendAndReceive(uint vendorId, ushort vendorType, byte[] data, int timeoutMs = 500)

Sends VoE data and waits for the response.

Parameters:

  • vendorId (uint) — vendor ID (4 bytes)
  • vendorType (ushort) — vendor type (2 bytes)
  • data (byte[]) — data to send
  • timeoutMs (int) — timeout (milliseconds)

Return value:

  • VoEResponse? — VoE response object; null on failure

Example:

var response = slave.VoE.SendAndReceive(0x00000002, 0x0001, new byte[] { 0x10 });
if (response != null)
{
Console.WriteLine($"厂商ID: 0x{response.VendorId:X8}"); // Vendor ID: 0x{response.VendorId:X8}
Console.WriteLine($"数据: {response.ToHexString()}"); // Data: {response.ToHexString()}
}

Related structures:

VoEResponse​

  • VendorId (uint) — vendor ID
  • VendorType (ushort) — vendor type
  • Data (byte[]) — response data
  • DataLength (int) — data length
  • ToHexString() (string) — formats the data as a hexadecimal string (for example "01 02 03")
  • ToString() (string) — full description (for example "VoE Response: VendorID=0x00000002, VendorType=0x0001, DataLength=3")

VendorID allow-list​

Send and receive filtering: an empty allow-list with StrictVendorFilter false = all vendor IDs allowed; as soon as an entry is added, filtering follows the allow-list. For a vendor ID outside the allow-list, Send / SendRaw return false, SendAndReceive returns null, and ReceiveRaw drops the frame.

AddAllowedVendor(uint vendorId)​

public void AddAllowedVendor(uint vendorId)

Adds an allowed VendorID (for example 0x00000002 = Beckhoff). VendorID 0 is reserved; passing it throws ArgumentException.

ClearAllowedVendors()​

public void ClearAllowedVendors()

Clears the allow-list and restores the default "allow all" behavior (provided StrictVendorFilter is false).

Raw frame operations​

SendRaw(byte[] frameData, int timeoutMs = 500)​

public bool SendRaw(byte[] frameData, int timeoutMs = 500)

Sends a raw VoE frame (the caller assembles the frame format, including the VoE header).

Return value:

  • bool — true on success

ReceiveRaw(int timeoutMs = 500)​

public byte[]? ReceiveRaw(int timeoutMs = 500)

Receives a raw VoE frame.

Return value:

  • byte[]? — raw frame data; null on failure

SendRawAndReceive(byte[] frameData, int timeoutMs = 500)​

public byte[]? SendRawAndReceive(byte[] frameData, int timeoutMs = 500)

Sends a raw frame and waits for the response.

Return value:

  • byte[]? — raw frame data of the response; null on failure

Helper methods​

BuildVoEFrame(uint vendorId, ushort vendorType, byte[]? data)​

public byte[] BuildVoEFrame(uint vendorId, ushort vendorType, byte[]? data)

Builds a standard VoE frame (VoE header + data).

Return value:

  • byte[] — the assembled VoE frame

ParseVoEFrame(byte[] frame)​

public VoEResponse? ParseVoEFrame(byte[] frame)

Parses a VoE frame (header + data). Returns null when parsing fails because the frame is shorter than 6 bytes.

Return value:

  • VoEResponse? — parsed VoE response object; null when parsing fails

Receiving notifications (vendor-initiated)​

StartNotificationListener()​

public bool StartNotificationListener()

Starts VoE notification listening for the master this instance belongs to (start it once per master; re-entrant safe). After it succeeds, this instance automatically subscribes to notifications from any vendor for this slave.

Notification listening and subscriptions are scoped per master: a notification from slave N on master A reaches only instances on A and never leaks to the same slave index on master B.

Return value:

  • bool — true on success

NotificationReceived​

public event EventHandler<VoENotificationEventArgs>? NotificationReceived;

Event raised when a vendor-initiated VoE frame arrives. Call StartNotificationListener first, then subscribe to this event.

Related structures:

public class VoENotificationEventArgs : EventArgs
{
public ushort MasterIndex { get; } // source master (tells identical slave indices apart across masters)
public ushort SlaveIndex { get; } // slave index
public uint VendorId { get; } // vendor ID
public ushort VendorType { get; } // vendor type
public byte[] Data { get; } // notification data
public DateTime Timestamp { get; } // timestamp (UTC)
}

StopNotificationListener() / StopAllListeners(ushort masterIndex)​

public void StopNotificationListener()                       // stops this instance's subscription (other instances unaffected)
public static void StopAllListeners(ushort masterIndex) // stops notification listening for the given master (other masters unaffected)
public static bool IsListenerRunning(ushort masterIndex) // whether notification listening is running for the given master

Async methods​

Every synchronous method has a matching Async version with the Async suffix and one extra CancellationToken cancellationToken = default: SendAsync / SendAndReceiveAsync / ReceiveAsync / SendRawAsync / ReceiveRawAsync / SendRawAndReceiveAsync.

Full example​

Vendor command exchange​

if (slave.VoE != null)
{
var response = slave.VoE.SendAndReceive(
vendorId: 0x00000002,
vendorType: 0x0001,
data: new byte[] { 0x01, 0x00 }
);

if (response != null)
Console.WriteLine(response.ToString());
}

Bulk data transfer​

if (slave.VoE != null)
{
byte[] payload = new byte[1024];
slave.VoE.Send(0x00000002, 0x1000, payload);

var reply = slave.VoE.Receive();
if (reply != null)
Console.WriteLine($"收到 {reply.DataLength} 字节响应"); // Received a {reply.DataLength}-byte response
}