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

Line Connection#

透過 Line Connection 相機功能,您可以設定或判定目前所選 通用 I/O 線路(GPIO 線路)的連線訊號。

連線訊號是用來控制特定的相機功能。例如,「TWI SDA」與「TWI SCL」訊號可用於 Two-Wire Interface 通訊。

使用功能#

設定 Line Connection#

若要設定 Line Connection:

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

判斷 Line Connection#

若要判定 Line Connection:

  1. 將相機中的 LineSelector 參數至所需的 I/O 線路。
  2. 取得 BslLineConnection 參數可用以判定 I/O 線路的目前 Line Connection。

範例程式碼#

// 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 來輕鬆設定參數。