跳转到内容

Line Connection#

Line Connection 相机功能允许您设置或确定当前选择的通用 I/O 线路(GPIO 线路)的线路连接。

使用 Two-Wire Interface (TWI) 相机功能时需要设置线路连接。

该功能的使用#

设置 Line Connection#

设置线路连接:

  1. LineSelector 参数设置为所需的 GPIO 线路
  2. LineMode 参数设置为 InOut。这允许您将 GPIO 线路用作输入输出线路。
  3. 设置 BslLineConnection 参数设置为以下值:
    • ConnectionOff:没有为当前选择的线路设置连接信号。
    • TwiSda:为当前选择的线路设置了 TWI SDA 信号。
    • TwiScl:为当前选择的线路设置了 TWI SCL 信号。

确定 Line Connection#

确定线路连接:

  1. LineSelector 参数设置为所需的 I/O 线路。
  2. 获取 BslLineConnection 参数的值以确定 I/O 线路的当前线路连接。

示例代码#

// Select Line 2
camera.LineSelector.SetValue(LineSelector_Line2);
// Set the line mode to InOut
camera.LineMode.SetValue(LineMode_InOut);
// 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 1
CEnumParameter(nodemap, "LineSelector").SetValue("Line1");
// Set the line mode to InOut
CEnumParameter(nodemap, "LineMode").SetValue("InOut");
// 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 1
camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line1);
// Set the line mode to InOut
camera.Parameters[PLCamera.LineMode].SetValue(PLCamera.LineMode.InOut);
// 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 1 */
errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line1");
CHECK(errRes);
/* Set the line mode to InOut */
errRes = PylonDeviceFeatureFromString(hdev, "LineMode", "InOut");
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 轻松设置参数。