MSCL icon indicating copy to clipboard operation
MSCL copied to clipboard

Serial port connection_issue

Open Tyagi0712 opened this issue 3 years ago • 1 comments

3DM-CV5 Using MSCL Library, when we access the com port with the real com port name, we are able to establish the connection. But when we use the symbolic link in place of the actual port name, MSCL library shows an invalid port name error. Here I have attached the Image of the error, in the last vertical tab. Thanks and Regards Shivika IMU_invalid_comport suggest if we are missing out on something or if there is any other method to accomplish the same.

Tyagi0712 avatar Sep 01 '22 06:09 Tyagi0712

Unfortunately MSCL does not automatically resolve symbolic links but luckily the workaround is very simple - you should just need to use the standard realpath function to determine the actual port name prior to passing it into the Connection object. Example below.

Hope this helps, let us know if you continue to run into trouble!

Example Add to includes:

#include <stdlib.h>

Determine actual port:

const string COM_PORT = "/dev/bestGq7";
const int BAUD = 115200;

char* actualPort = realpath(COM_PORT.c_str(), NULL);
string portString(actualPort);
cout << "Attempt create connection: " << COM_PORT <<" (" << portString << "), " << BAUD << endl;

//create a SerialConnection with the COM port
mscl::Connection connection = mscl::Connection::Serial(portString, BAUD);
cout << "Connection created" << endl;

Output:

Attempt create connection: /dev/bestGq7 (/dev/ttyUSB1), 115200
Connection created

msclissa avatar Sep 08 '22 17:09 msclissa