Dear developers,
I am trying to run follwing code to open and get info about “/dev/ttyGS0” port in BBB
`
#include <linux/serial.h>
bool foo()
{
const mode_t flags = O_RDWR | O_NONBLOCK | O_NOCTTY;
const int fd = ::open("/dev/ttyGS0", flags);
if (fd != -1) {
struct serial_struct serinfo;
const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
::close(fd);
if (retval != -1 && serinfo.type != PORT_UNKNOWN)
return true;
}
return false;
}
`
But I am getting “retval = -1” when following statement is run
const int retval = ::ioctl(fd, TIOCGSERIAL, &serinfo);
On further analysis I found that ioctl function call, return errno 25.
Can you please inform me what can be the reason for this error and how can i solve it.
Please inform me if you need any other information from me.
Many thanks
Regards
Saurabh Jain