All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: "Karch, Joshua" <jkarch@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Xenomai serial port c++ code and / or xeno--	(xenomm-0.0.1) install problem
Date: Wed, 23 Apr 2008 02:12:58 +0200	[thread overview]
Message-ID: <18446.32522.986935.299094@domain.hid> (raw)
In-Reply-To: <51B669A8A7D2914E9AB2B3F40AC6553E646F13@domain.hid>

Karch, Joshua wrote:
 > 
 > Hello,
 > 
 > I recently installed Xenomai on a PC/104 and began writing a C++ program that makes use of the serial port.  I tried using the Xenomai Serial port example program cross-link.c and I was successful in getting that to run. I edited cross-link.c to read only from a device running at 115200 on the serial port.  I have found the standard /dev/ttyS0 serial port to be useless for my application since I get overrun errors on my system.  
 > 
 > My C++ program reads byte at a time from a serial port, processes the byte, then repeats until a checksummed packet is received.  I have two specific questions as to how to get the serial port to work under Xenomai with c++
 > 
 > The way I understand port reading is as follows:
 > 
 > 1) Open device using read_fd = rt_dev_open( READ_FILE, 0 ) and set it up
 >     err = rt_dev_ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, &read_config);
 > 2) It is necessary to create an RT_TASK analogous to a thread to service the serial port task
 >     err = rt_task_create(&read_task, "read_task", 0, 51, 0);
 > 3) for each byte read, activate the read task with rt_task_start
 >     err = rt_task_start(&read_task,&read_task_proc,NULL);

I do not think it is a good idea to call rt_task_start for each byte
read. At least, I do not think it is what rt_task_start was initially
designed for.

 >     4) Within the Real Time read_task_proc, request one byte at a time within the rt_task_process using
 >         err = rt_dev_ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event);
 >         read = rt_dev_read(read_fd, buffer, 1);

What is the point of waiting for an event before reading ? If you read
directly, it will make one less system call, and rt_dev_read will
block just like rt_dev_ioctl.

 > 5)  read from the buffer into the user application in non-real time mode
 > 
 > 6)  close when done
 > 
 > The problem I am having with this method is that 
 > int 	rt_task_start (RT_TASK *task, void(*fun)(void *cookie), void *cookie)
 > won't accept a pointer to an object method and requires a pointer to an instance to map into the void(*fun)(void *cookie), void *cookie section.
 > 
 > With Pthreads, I instantiate a threaded main loop within an object as follows:
 > void * serial::thunk(void * param)
 > {
 > 	serial *instance = (serial *) param;
 > 	instance->read_task_proc();
 > 
 > }

 > 
 > Is there a similar way to do this with rt_tasks?  In particular, if a c++ based serial read example were available for byte-at-a-time, that would be very useful.

There is no difference between pthread_create and rt_task_start. The
usual trick is to pass them a pointer to a class static method: a class
static method pointer is a valid C function pointer.

 > 
 > Also, xenomm-0.0.1 failed under ./configure with "checking value of TM_UNSET in native/timer.h"-- any ideas on how to get xenomm (xeno--) working?

Maybe xenomm was made for an earlier version of xenomai and has not been
updated since Xenomai was updated ?

 >  Is it useful?

I guess it has a nice C++ wrapper class to rt_task_create/rt_task_start.

-- 


					    Gilles.


  reply	other threads:[~2008-04-23  0:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 22:46 [Xenomai-help] Xenomai serial port c++ code and / or xeno-- (xenomm-0.0.1) install problem Karch, Joshua
2008-04-23  0:12 ` Gilles Chanteperdrix [this message]
     [not found]   ` <51B669A8A7D2914E9AB2B3F40AC6553E646F15@domain.hid>
2008-04-23 13:58     ` [Xenomai-help] Xenomai serial port c++ code and / or xeno--(xenomm-0.0.1) " Gilles Chanteperdrix
2008-04-23 14:25       ` Karch, Joshua
2008-04-23 14:30         ` Gilles Chanteperdrix
2008-04-23 15:43           ` Karch, Joshua
2008-04-23 18:10             ` Gilles Chanteperdrix
     [not found]               ` <51B669A8A7D2914E9AB2B3F40AC6553E646F1D@afsexc01.aurora.aero>
2008-04-23 21:20                 ` [Xenomai-help] FW: " Karch, Joshua
2008-04-23 21:28                 ` [Xenomai-help] " Gilles Chanteperdrix
2008-04-23 21:36                   ` Karch, Joshua
2008-04-23 22:14                   ` [Xenomai-help] serial port overrun problem RT TASK Karch, Joshua
2008-04-24  6:43                     ` Gilles Chanteperdrix
2008-04-24  7:04                       ` Jan Kiszka
2008-04-24 14:16                         ` Karch, Joshua
2008-04-24 14:30                           ` Gilles Chanteperdrix
2008-04-24 16:58                             ` Karch, Joshua
2008-04-24 17:16                               ` Gilles Chanteperdrix
2008-04-24 22:37                                 ` [Xenomai-help] serial port overrun problem RT TASK geode latencies too high Karch, Joshua
2008-04-24 22:59                                   ` Gilles Chanteperdrix
2008-04-25 16:04                                     ` [Xenomai-help] Geode Latency Problem (Was: serial port overrun problem) Karch, Joshua
2008-04-25 16:12                                       ` Gilles Chanteperdrix
2008-04-24 13:59                       ` [Xenomai-help] serial port overrun problem RT TASK Karch, Joshua
2008-04-24 14:01                         ` Gilles Chanteperdrix
     [not found] ` <51B669A8A7D2914E9AB2B3F40AC6553E646F52@domain.hid>
     [not found]   ` <18454.9396.476627.446653@domain.hid>
     [not found]     ` <51B669A8A7D2914E9AB2B3F40AC6553E646F54@domain.hid>
     [not found]       ` <48162C69.6040101@domain.hid>
     [not found]         ` <18454.12323.344999.258031@domain.hid>
     [not found]           ` <51B669A8A7D2914E9AB2B3F40AC6553E646F55@domain.hid>
     [not found]             ` <48163EE7.5000604@domain.hid>
     [not found]               ` <18454.17297.451664.334250@domain.hid>
     [not found]                 ` <48164652.5090102@domain.hid>
     [not found]                   ` <2ff1a98a0804290252j1c9dc444kffb345ebaeb123d@domain.hid>
     [not found]                     ` <48187366.2060006@domain.hid>
2008-04-30 18:13                       ` [Xenomai-help] Segfault Problems with Message Queues Karch, Joshua
2008-04-30 18:31                         ` Philippe Gerum
2008-04-30 18:41                           ` Karch, Joshua
2008-04-30 18:48                             ` Philippe Gerum
2008-04-30 19:22                               ` Karch, Joshua
2008-04-30 18:36                         ` Philippe Gerum
2008-04-30 19:19                         ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18446.32522.986935.299094@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=jkarch@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.