跳至內容
測試伺服器
開發伺服器

Line Connection#

「Line Connection 」相機功能可讓您設定或判定目前選取之通用輸入/輸出線(GPIO 線)的連接訊號。

連接訊號用於控制相機的某些功能。例如,「TWI SDA」和「TWI SCL」訊號用於 Two-Wire Interface 通訊之用。

使用功能#

設定Line Connection#

要設定線路連接:

  1. 將相機中的 LineSelector 參數設為所需的 GPIO 線.
  2. 將相機中的 BslLineConnection 參數設定為以下值之一:
    • ConnectionOff: 目前選取的行未設定連線訊號。
    • TwiSda: TWI SDA 訊號已針對目前選取的行進行設定。
    • TwiScl: TWI SCL 訊號已針對目前選取的行進行設定。
    • LightControl: 已針對目前選取的行設定燈光控制訊號。
  3. 請確保 LineMode 參數設為 InOut. 這讓您可以將 GPIO 線用作輸入/輸出線。如果該參數未自動設定為 InOut, 請手動設定。

確定Line Connection#

要確定線路連接方式:

  1. 將相機中的 LineSelector 將參數設定至所需的 I/O 線。
  2. 取得 BslLineConnection 用於確定 I/O 線路當前連接狀態的參數。

範例程式碼#

// Select Line 2
camera.LineSelector.SetValue(LineSelector_Line2);
// Set the line connection to TWI SDA
camera.BslLineConnection.SetValue(BslLineConnection_TwiSda);
// Get the current line connection
BslLineConnectionEnums e = camera.BslLineConnection.GetValue();
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);
# Select Line 2
camera.LineSelector.Value = "Line2"
# Set the line connection to TWI SDA
camera.BslLineConnection.Value = "TwiSda"
# Get the current line connection
e = camera.BslLineConnection.Value

您也可以 use the pylon Viewer 來輕鬆設定參數。