All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] CP-118U RTDM Driver
@ 2007-12-12 13:48 DOURNES Guillaume
  2007-12-13  0:03 ` Jan Kiszka
  2007-12-14 15:47 ` Maksym Veremeyenko
  0 siblings, 2 replies; 10+ messages in thread
From: DOURNES Guillaume @ 2007-12-12 13:48 UTC (permalink / raw)
  To: xenomai@xenomai.org

[-- Attachment #1: Type: text/plain, Size: 5605 bytes --]

Hi,

 

I have a kernel 2.6.20.9 with Xenomai 2.3.4.

I chose a Moxa CP-118U board on my project, to be able to drive this PCI board with the xeno_16550A module.

So I tried to drive one port of this board by calling :

 

modprobe mxser

rmmod mxser

modprobe xeno_16550A ioaddr=0xb500 irq=5

 

And I run my simple software of test.

 

But when the task is started, my computer become very slow, as a process eats a lot of CPU load.

This state stay even if I stop the software by CTRL+C, and even if I discharge the xeno_16550A module.

Only a reboot allow to go I a good state.

 

My question is why the CPU become very loaded, whereas my software do nothing.

 

I tried my software with the serial port on my mother board, and with this port, the system stay in a good state. It becomes not very slow.

 

Moreover, I contact Moxa and his response was :

"I am afraid that you cannot use 16550A module to driver CP-118U.

The reason is because we use MU860 but not 16550A in CP118U."

 

So, Does the CP-118U board work with the xeno_16550A module ??

Else how can I drive the CP-118U board with rtdm ?

 

Thanks,

 

Guillaume.

 

/*********************** test.c *****************************/

#include <stdio.h>

#include <signal.h>

#include <unistd.h>

#include <sys/mman.h>

 

#include <native/task.h>

#include <native/timer.h>

 

#include <rtdm/rtserial.h>

 

#define LOG_PREFIX    "rt_serial_uprog: "

#define RTASK_PREFIX  "read_task : "

 

#define PORT_0                                   "rtser0"

 

int timer_started = 0;

int my_fd_0 = -1;

 

#define STATE_FILE_OPENED_PORT_0           0x01

#define STATE_FILE_OPENED_PORT_7           0x02

#define STATE_TASK_EVENT_CREATED                     0x04

#define STATE_TASK_READ_CREATED                                   0x08

#define STATE_TASK_WRITE_CREATED                      0x10

 

unsigned int my_state = 0;

RT_TASK read_task;

 

 

static int close_file( int fd, unsigned char *name)

{

            int ret,i=0;

            do

            {

                        i++;

                        ret = rt_dev_close(fd);

                        switch(-ret)

                        {

                                   case EBADF:

                                               printf(LOG_PREFIX "%s -> invalid fd or context\n",name);

                                   break;

 

                                   case EAGAIN:

                                               printf(LOG_PREFIX "%s -> EAGAIN (%d times)\n",name,i);

                        rt_task_sleep(50000); // wait 50us

            break;

 

            case 0:

                        printf(LOG_PREFIX "%s -> closed\n",name);

            break;

 

            default:

                        printf(LOG_PREFIX "%s -> ???\n",name);

            break;

                        }

            } while (ret == -EAGAIN && i < 10);

            return ret;

}

 

void close_all_file(void)

{

            if (my_state & STATE_FILE_OPENED_PORT_0)

            {

                        close_file( my_fd_0, PORT_0);

                        my_state &= ~STATE_FILE_OPENED_PORT_0;

            }

}

 

void cleanup_all(void)

{

            if (my_state & STATE_FILE_OPENED_PORT_0)

            {

                        close_file( my_fd_0, PORT_0);

                        my_state &= ~STATE_FILE_OPENED_PORT_0;

            }

            if (my_state & STATE_TASK_READ_CREATED)

            {

                        printf(LOG_PREFIX "delete read_task\n");

                        rt_task_delete(&read_task);

                        my_state &= ~STATE_TASK_READ_CREATED;

            }

}

 

void catch_signal(int sig)

{

            cleanup_all();

            printf(LOG_PREFIX "exit\n");

            return;

}

 

void read_task_proc(void *arg)

{

 

}

 

int main(int argc, char* argv[])

{

            int ret = 0;

            signal(SIGTERM, catch_signal);

            signal(SIGINT, catch_signal);

 

            printf(LOG_PREFIX "PRESS CTRL-C to EXIT\n");

            /* no memory-swapping for this programm */

            mlockall(MCL_CURRENT | MCL_FUTURE);

 

            /* open PORT_0 */

            my_fd_0 = rt_dev_open( PORT_0, 0);

            if (my_fd_0 < 0)

            {

                        printf(LOG_PREFIX "can't open %s car my_fd = %d\n", PORT_0, my_fd_0);

                        goto error;

            }

            my_state |= STATE_FILE_OPENED_PORT_0;

 

  /* create read_task */

  ret = rt_task_create(&read_task,"read_task",0,51,0);

  if (ret)

  {

            printf(LOG_PREFIX "failed to create read_task, code %d\n",ret);

            goto error;

  }

  my_state |= STATE_TASK_READ_CREATED;

  printf(LOG_PREFIX "La tache read-task créée avec succés\n");

 

  /* start read_task */

  printf(LOG_PREFIX "Demarrage de la tache read-task\n");

  ret = rt_task_start(&read_task,&read_task_proc,NULL);

  if (ret)

  {

            printf(LOG_PREFIX "failed to start read_task, code %d\n",ret);

            goto error;

  }

 

            pause();

 

  return 0;

 

error:

            cleanup_all();

            return ret;

}

 

/********************* End test.c**************************************/

 


[-- Attachment #2: Type: text/html, Size: 102828 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-12-20  9:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-12 13:48 [Xenomai-help] CP-118U RTDM Driver DOURNES Guillaume
2007-12-13  0:03 ` Jan Kiszka
2007-12-14 15:47 ` Maksym Veremeyenko
2007-12-18 14:27   ` DOURNES Guillaume
2007-12-18 16:51     ` Maksym Veremeyenko
2007-12-18 17:25       ` DOURNES Guillaume
2007-12-18 17:40         ` Maksym Veremeyenko
2007-12-19 10:16           ` DOURNES Guillaume
2007-12-20  1:47             ` Maksym Veremeyenko
2007-12-20  9:59               ` DOURNES Guillaume

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.