AoeReadSdoObject
使用 EtherCAT ADS (AoE) SDO 法讀取從站數據。
語法
KsCommandStatus AoeReadSdoObject(
int SlaveId,
int Port,
int ObIndex,
int ObSubIndex,
BOOL CompleteAccess,
BYTE* Value,
int Length
);
參數
SlaveId:從站陣列的索引。當 EtherCAT 從站裝置啟動時,此索引具有與 SlaveId 相同的值,該值對應於從站裝置在網路中的位置。請注意,在 EtherCAT 進入運行 (Op) 狀態後,加入或移除網路上的任何從站裝置將改變各裝置在網路中的位置 (SlaveId)。儘管如此,從站的索引將保持不變。新增的裝置將排列在陣列的末端。對於更改後的所有從站,索引和 SlaveId 將不再匹配。上述行為模式僅適用於實體裝置;不適用於模擬裝置。詳細資訊請參閱 EnableHotConnect 中的使用案例。
Port:EtherCAT 從站連接埠。
ObIndex:欲在物件字典中讀取的物件索引。
ObSubIndex:欲在物件字典中讀取的物件子索引。
CompleteAccess:TRUE:讀取所有子索引;FALSE:讀取一個子索引。
Value:欲讀取值的指標。
Length:欲讀取值的長度(位元)。
回傳值
返回 KsCommandStatus 結構。
可用的 EtherCAT 狀態
ecatPreOP, ecatSafeOP, ecatOP
範例
複製
//////////////////////////////////////////////////////////////////
//
// This code snippet demonstrates how to configure IO-Link sensors
// connected to IO-Link master and use AoeReadSdoObject to request
// service data stored in these IO-Link devices.
//
//////////////////////////////////////////////////////////////////
KsError nRet = errNoError;
KsCommandStatus Command = { 0 };
char readResult[64] = { 0 };
IoLinkSetting IoLink = {
17, // IO-Link specification: Version 1.1
0, // SPDU
3, // Control
32, // Input length
0 // Output length
};
nRet = Create(0, 0);
nRet = AddModuleConfiguration(
1, // EthercatSlaveID
0, // LinkedDeviceID
configIoLink, // Protocol
&IoLink // Settings
);
Command = WaitForCommand(30, TRUE, Start());
Command = WaitForCommand(
5,
FALSE,
AoeReadSdoObject(
0, // SlaveID
0x1001, // Port
0x13, // ObIndex
0, // ObSubIndex
FALSE, // CompleteAccess
(BYTE*)readResult, // Value
64 // Length
)
);
// Write the 0x13 "Product ID" data to 0x18 "Application Specific Name"
Command = WaitForCommand(5, FALSE, AoeWriteSdoObject(0, 0x1001, 0x18, 0,
FALSE, (BYTE*)readResult, 64));
Command = WaitForCommand(5, FALSE, Stop());
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
標頭檔 | ksapi.h | ksapi.h |
程式庫 | KsApi_Rtss.lib | KsApi.lib |
參見