Line Connection#
連接信號可用於控制特定的相機功能。例如,「TWI SDA」與「TWI SCL」信號可用於 Two-Wire Interface 通訊。
使用此功能#
設定 Line Connection#
若要設定 Line Connection:
- 將
LineSelector參數設為所需的 GPIO line. - 將
BslLineConnection參數設為下列其中一個值:ConnectionOff:未針對目前所選的線路設定連接信號。TwiSda:已針對目前所選的線路設定 TWI SDA 信號。TwiScl:已針對目前所選的線路設定 TWI SCL 信號。LightControl:已針對目前所選的線路設定 Light Control 信號。
- 請確保
LineMode參數已設定為InOut。這可讓您將 GPIO 線路用作輸入輸出線路。如果參數未自動設定為InOut,請手動進行設定。
決定 Line Connection#
若要判斷 Line Connection:
- 將
LineSelector參數設定至所需的 I/O 線路。 - 取得
BslLineConnection參數來判斷 I/O 線路的目前 Line Connection。
範例程式碼#
INodeMap& nodemap = camera.GetNodeMap();
// Select Line 2
CEnumParameter(nodemap, "LineSelector").SetValue("Line2");
// Set the line connection to TWI SDA
CEnumParameter(nodemap, "BslLineConnection").SetValue("TwiSda");
// Get the current line connection
String_t e = CEnumParameter(nodemap, "BslLineConnection").GetValue();
// Select Line 2
camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line2);
// Set the line connection to TWI SDA
camera.Parameters[PLCamera.BslLineConnection].SetValue(PLCamera.BslLineConnection.TwiSda);
// Get the current line connection
string e = camera.Parameters[PLCamera.BslLineConnection].GetValue();
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
size_t len = 0;
char e_str[64] = {0};
/* Select Line 2 */
errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line2");
CHECK(errRes);
/* Set the line connection to TWI SDA */
errRes = PylonDeviceFeatureFromString(hdev, "BslLineConnection", "TwiSda");
CHECK(errRes);
/* Get the current line connection */
len = sizeof(e_str);
errRes = PylonDeviceFeatureToString(hdev, "BslLineConnection", e_str, &len);
CHECK(errRes);
您也可以使用 pylon Viewer 來輕鬆設定參數。