Sorry for my ignorance but I do not know I do communication between
rt task and user process using exellent mbuff driver : ( I'm sorry
Tomasz )
I want read and write a lot of char ( 8000-12000 ) between rt task and
user
process. My simple and wrong program is this :
This is the user process (from demo.c example )
#include <stdio.h>
#include "mbuff.h"
volatile char * shm1;
int main (int argc,char *argv[]){
shm1 = (volatile char*) mbuff_alloc("demo1",1024*1024);
if( shm1 == NULL ) {
printf("mbuff_alloc failed\n");
exit(2);
}
sprintf((char*)shm1,"example data\n");
sleep(5);
mbuff_free("demo1",(void*)shm1);
return(0);
}
and this the rt task
================================
#include <linux/errno.h>
#include <rtl.h>
#include <time.h>
#include <rtl_sched.h>
#include "mbuff.h"
pthread_t taskA;
static char *memname = "demo1";
static int memsize = 1024*1024;
static void *addr;
char stringa[40];
void *thread_code(void *t)
{
while (1) {
int ret;
ret = pthread_wait_np();
//Can I read data from here ? and How
//sscanf(memname,"%s",stringa);
rtl_printf("I read = %s",stringa);
}
return 0;
}
int init_module(void)
{
pthread_attr_t attr;
struct sched_param sched_param;
int ret;
pthread_attr_init (&attr);
sched_param.sched_priority = 1;
pthread_attr_setschedparam (&attr, &sched_param);
ret=pthread_create (&taskA, &attr, thread_code, (void *)1);
pthread_make_periodic_np(pthread_self(), gethrtime(), 2000000000);
shm_allocate(memname, memsize, &addr);
// Must I read data from here ? I have to read a lot of data from user
process
// it are 8000 char to LPT1
return 0;
}
void cleanup_module(void)
{
shm_deallocate(addr);
pthread_cancel (taskA);
pthread_join (taskA, NULL);
}
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/