Possible Solutions When Encountering Connection Issues with the 'connect' Interface

If connection issues arise when using the ‘connect’ interface, it is necessary to verify if it aligns with the demonstrated methods in the example.

  • Taking the C++ version in Mech-Eye SDK as an example.

  • The image below shows the ‘connect’ interface. You can connect by selecting the camera index from the list or by manually entering the IP address, port, and connection timeout. In either case, you can use ‘disconnect’ to terminate the connection.

  • The ConnectToCamera sample demonstrates the usage of the ‘connect’ interface.

  1. status = device.connect(deviceInfoList[inputIndex]);
    This line of code attempts to connect to a Mech-Eye device. deviceInfoList is the list of device information, and inputIndex is the index indicating the device to connect to. The program tries to establish a connection with the device at the specified index in the device information list, and the result of the connection is stored in a variable named status.

  2. if (!status.isOK()) {
    Here begins a conditional statement that checks if status indicates a successful connection (status is OK). If the connection is not successful, the code block within the conditional statement is executed.

  3. showError(status);
    If the connection fails, the program calls a function named showError and passes the connection status status as a parameter. This function is used to display connection error messages.

  4. return -1;
    If the connection fails, the program returns a non-zero value (-1), indicating an error in the program execution.

  5. std::cout << "Connected to the Mech-Eye device successfully." << std::endl;
    If the connection is successful (i.e., the status in the conditional statement is OK), this line of code outputs a message to the console, indicating a successful connection to the Mech-Eye device.

  6. device.disconnect();
    This line of code performs disconnection from the Mech-Eye device.

  7. std::cout << "Disconnected from the Mech-Eye device successfully." << std::endl;
    This line of code, after disconnecting, outputs a message to the console indicating a successful disconnection from the Mech-Eye device.

  8. return 0;
    Finally, the program returns 0, indicating successful completion of the program.
    image