Dear all,
I am trying to develop an application which requires a serial connection. I was trying to use ttyS0, which maps to IO0 and IO1, but with no success.
I do the open with success, nevertheless, trying to use it returns error.
errno is 5 and strerror() returns Input/output error.
below you can check the code:
int main()
{
struct termios tio;
memset(&tio,0,sizeof(tio));
tio.c_iflag=0;
tio.c_oflag=0;
tio.c_cflag=CS8|CREAD|CLOCAL; // 8n1
tio.c_lflag=0;
tio.c_cc[VMIN]=1;
tio.c_cc[VTIME]=5;
screenfd = open("/dev/ttyS0", O_RDWR);
if(screenfd == -1)
{
printf("Could not open the ttyS0: %s\n",strerror(errno));
return -1;
}
cfsetospeed(&tio,B115200); // 115200 baud
cfsetispeed(&tio,B115200); // 115200 baud
int ret = tcsetattr(screenfd,TCSANOW,&tio);
if ( ret != 0)
{
printf("Error %d from tcsetattr: %s", errno,strerror(errno) );
}
close(screenfd);
return 0;
}
Removing the termios setup and just opening the device and writing falls back to the same error.
The same code works fine on ubuntu 12.04, but fails when cross compiled to galileo.
to the build environment I have followed the intel doc Quark_BSP_BuildandSWUserGuide_329687_006.
I have also followed How to program UART serial from Linux on Galileo Gen 2? with no success, performing # stty -F /dev/ttyS0 9600 returns the same error.
Doing,
root@clanton:~# echo -n "hello" >/dev/ttyS0
-sh: echo: write error: Input/output error
any ideas?
Kind regards,
tiago