Hello Friends
I am working on RTLinux. In the work I am facing a problem. The problem is that
When I run the program given below then it gives me a number of errors which when
comes continue to come continuously and my screen is filled with errors rather it
overfills and then continues so I am not able to see first few errors.
Please help me to provide some GUI Interface to solve this problem or tell me some
other way.
Waiting for Reply
Vishwajeet
/**********Program**************/
#include<rtl.h>
#include<pthread.h>
#include<stdio.h>
#include<string.h>
#include<rtl_fifo.h>
int fd_fifo;
int fifo_size=100;
pthread_t rthread,wthread;
void * reader(void * file)
{
char *word;
FILE *fp;
struct sched_param p;
p.sched_priority=1;
pthread_setschedparam(pthread_self(),SCHED_FIFO,&p);
fp=fopen((char *)file,"r");
fd_fifo=open("/dev/rtf0",O_NONBLOCK);
while(!feof(fp))
{
strcpy(word,fscanf(fp,"%s"));
write(fd_fifo,word,strlen(word));
}
write(fd_fifo,"ENDFILE",7);
fclose(fp);
}
void * writer(void * file)
{
char *word;
FILE *fp;
struct sched_param p;
p.sched_priority=1;
pthread_setschedparam(pthread_self(),SCHED_FIFO,&p);
fp=fopen((char *)file,"w");
while(1)
{
fd_fifo=open("/dev/rtf0",O_NONBLOCK);
read(fd_fifo,word,strlen(word));
if(!strcmp(word,"ENDFILE"))
break;
fprintf(fp,"%s",strrev(word));
}
fclose(fp);
}
int init_module(void)
{
char *source,*dest;
int fifo_status;
fifo_status=rtf_create(0,fifo_size);
if(fifo_status<0)
{
rtl_printf("\n ERROR : No FIFO queue created.");
pthread_exit(0);
}
else
{
rtl_printf("\n Please enter the file to encrypt : %s",source);
rtl_printf("\n Please enter the destination file : %s",dest);
pthread_create(&wthread,NULL,writer,(void *)source);
pthread_create(&rthread,NULL,reader,(void *)dest);
}
}
void cleanup_module(void)
{
close(fd_fifo);
rtf_destroy(0);
pthread_delete_np(&wthread);
pthread_delete_np(&rthread);
}
_______________________________________________
Rtl mailing list
[EMAIL PROTECTED]
http://www2.fsmlabs.com/mailman/listinfo.cgi/rtl