Hello !
I hope you can understand me. My english is bad ;-(
Since one week i have portet my linux server to freebsd 6.3 server.
Now i must compile my source to connect my LCD2041 serial display.
The problem is that the write command after time period produce
Input/output error's (code 5). I think it's the problem is initialising the display or full write buffer or another application will work on serial port and chrashes my application ?
Here is my code snipped (without error handling) :
int id = open("/dev/cuad5", O_RDWR|O_NOCTTY);
struct termios portset;
tcgetattr(id, &portset);
cfmakeraw(&portset);
cfsetospeed(&portset, B9600);
cfsetispeed(&portset, B0);
tcsetattr(id, TCSANOW, &portset);
bool bError = false;
int iWritten = 0;
char out[256] = "";
while(!bError)
{
// clear screen
snprintf(out,sizeof(out),"\xFE" "X");
if((iWritten = write(id, out, 2)) != 2)
{
fprintf(stderr,"\nError (%d)... [%d %s]", iWritten, errno, strerror(errno));
bError = true;
}
for(int i=0; i<4 && !bError; i++)
{
// set cursor
snprintf(out,sizeof(out),"\xFE" "G" "%c%c",i,i);
if((iWritten = write(id, out, 4)) != 4)
{
fprintf(stderr,"\nError (%d)... [%d %s]", iWritten, errno, strerror(errno));
bError = true;
}
// write text
if((iWritten = write(id, "0123456789", 10)) != 10)
{
fprintf(stderr,"\nError (%d)... [%d %s]", iWritten, errno, strerror(errno));
bError = true;
}
// waiting a while
// usleep(100000); // 0.1 sec
}
}
}
}
close(id);
}
------->
after a time period betwen 10 minutes to 2 hours the write command in the middle from the script fails an produce error 5 - Input/output error ?
Can someone tell me what i can doing ?
Thanx 4 ever !
...Jaro (from Germany)
Write "Input/output error" after Timeperiod on Fre
Write "Input/output error" after Timeperiod on Fre
- Attachments
-
- main.cpp
- The cpp source...
- (1.35 KiB) Downloaded 518 times
Hello!Ray wrote:Didn't see any explicit mention of it in your source, so it might be by default but make sure flow control (Xon/Xoff and CTS/RTS) is tunred off.
Now i have added follow lines...
portset.c_cflag &= ~(CNEW_RTSCTS);
portset.c_iflag &= ~(IXON|IXOFF|IXANY);
I hope thats all and it works ?
Sorry !
The script is running over night without errors ?! Wow !!
Now after restart the same comes errors back ?! Fu...
Here my logfile...
1903 1328 Starting...
1903 1330 Errror on write (-1) [5 Input/output error]
1903 1330 Exiting...
1903 1353 Starting...
1903 1358 Error on write (-1) [5 Input/output error]
1903 1358 Exiting...
1903 1412 Starting...
1903 1417 Error on write (-1) [5 Input/output error]
1903 1417 Exiting...
Here is my modifyed code :
---> SNIP
int id = open("/dev/cuad5", O_RDWR|O_NOCTTY|O_NONBLOCK);
tcgetattr(id, &options);
// Speed to 9600 baud
cfsetospeed(&options, B9600);
cfsetispeed(&options, B9600);
// RAW Mode
cfmakeraw(&options);
// 8N1 with no Parity
options.c_cflag &= ~(CSIZE|PARENB);
options.c_cflag |= CS8;
// all flow controls off ?
options.c_cflag &= ~(CRTSCTS);
options.c_iflag &= ~(IXON|IXOFF|IXANY);
tcsetattr(id, TCSANOW, &options);
while(write(id, "0123456789", 10) == 10);
close(id);
---> SNIP
Do you have any ideas ?
Thanx...
The script is running over night without errors ?! Wow !!
Now after restart the same comes errors back ?! Fu...
Here my logfile...
1903 1328 Starting...
1903 1330 Errror on write (-1) [5 Input/output error]
1903 1330 Exiting...
1903 1353 Starting...
1903 1358 Error on write (-1) [5 Input/output error]
1903 1358 Exiting...
1903 1412 Starting...
1903 1417 Error on write (-1) [5 Input/output error]
1903 1417 Exiting...
Here is my modifyed code :
---> SNIP
int id = open("/dev/cuad5", O_RDWR|O_NOCTTY|O_NONBLOCK);
tcgetattr(id, &options);
// Speed to 9600 baud
cfsetospeed(&options, B9600);
cfsetispeed(&options, B9600);
// RAW Mode
cfmakeraw(&options);
// 8N1 with no Parity
options.c_cflag &= ~(CSIZE|PARENB);
options.c_cflag |= CS8;
// all flow controls off ?
options.c_cflag &= ~(CRTSCTS);
options.c_iflag &= ~(IXON|IXOFF|IXANY);
tcsetattr(id, TCSANOW, &options);
while(write(id, "0123456789", 10) == 10);
close(id);
---> SNIP
Do you have any ideas ?
Thanx...
Hello !
Now i hope this is the solution. The Display works now since
last night without errors.
---> SNIP
tcgetattr(id, &options);
options.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
options.c_oflag &= ~(OPOST);
options.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
options.c_cflag &= ~(CSIZE|PARENB|CRTSCTS);
options.c_cflag |= (CS8|CREAD|CLOCAL);
cfsetospeed(&options, B9600);
cfsetispeed(&options, B0);
tcsetattr(id, TCSANOW, &options);
---> SNIP
Hope, hope, hope...
I have no more any ideas ?!
...Jaro
Now i hope this is the solution. The Display works now since
last night without errors.
---> SNIP
tcgetattr(id, &options);
options.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
options.c_oflag &= ~(OPOST);
options.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
options.c_cflag &= ~(CSIZE|PARENB|CRTSCTS);
options.c_cflag |= (CS8|CREAD|CLOCAL);
cfsetospeed(&options, B9600);
cfsetispeed(&options, B0);
tcsetattr(id, TCSANOW, &options);
---> SNIP
Hope, hope, hope...
I have no more any ideas ?!
...Jaro