#include #include #include #define PIPE_MINOR 0 #define TASK_PRIO 2 /* Highest RT priority */ #define TASK_MODE T_FPU|T_CPU(0) /* Uses FPU, bound to CPU #0 */ #define TASK_STKSZ 4096 /* Stack size (in bytes) */ RT_TASK task_desc; RT_PIPE pipe_desc; void task_body (void *cookie) { RT_PIPE_MSG *msgout, *msgin; int len = sizeof("HELLO"); msgout = rt_pipe_alloc(len); if (msgout) { strcpy( P_MSGPTR(msgout), "HELLO"); if (rt_pipe_send(&pipe_desc, msgout, len, 0) != len) { rt_pipe_free(msgout); } msgout = rt_pipe_alloc(len); strcpy( P_MSGPTR(msgout), "JODEL"); if (rt_pipe_send(&pipe_desc, msgout, len, 0) != len) { rt_pipe_free(msgout); } rt_pipe_receive(&pipe_desc, &msgin, TM_INFINITE); printk("received msg> %s, size=%d\n",P_MSGPTR(msgin),P_MSGSIZE(msgin)); rt_pipe_free(msgin); } else { printk("ERROR: rt_pipe_alloc\n"); } } int __init init_module (void) { int err; err = rt_pipe_create(&pipe_desc, "pipetest", PIPE_MINOR); if (!err) { err = rt_task_create(&task_desc, "MyTaskName", TASK_STKSZ, TASK_PRIO, TASK_MODE); if (!err) { rt_task_start(&task_desc, &task_body, NULL); } else { printk("ERROR: cannot create task\n"); return 0; } } else { printk("ERROR: cannot create pipe\n"); } printk("INIT DONE\n"); return 0; } void __exit cleanup_module (void) { rt_pipe_delete(&pipe_desc); rt_task_delete(&task_desc); printk("CLEANUP DONE\n"); } MODULE_LICENSE("GPL");