* [Xenomai-help] adding PCI support to 16550A.c
@ 2007-09-10 13:14 Bachman Kharazmi
2007-09-10 18:24 ` Jan Kiszka
0 siblings, 1 reply; 24+ messages in thread
From: Bachman Kharazmi @ 2007-09-10 13:14 UTC (permalink / raw)
To: xenomai
I've tried to make the pci serial controller visable to the 16550
driver by adding:
## FROM 16550A.c
static int rt_16550_interrupt(rtdm_irq_t * irq_context)
{
struct rt_16550_context *ctx;
unsigned long base;
int mode;
int iir;
uint64_t timestamp = rtdm_clock_read();
int rbytes = 0;
int events = 0;
int modem;
int ret = RTDM_IRQ_NONE;
// TEST
struct pci_dev *pdev = NULL; // from
http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c
pdev = pci_get_device(0, 0, pdev); // from
http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c
//
ctx = rtdm_irq_get_arg(irq_context, struct rt_16550_context);
base = ctx->base_addr;
mode = rt_16550_io_mode_from_ctx(ctx);
rtdm_lock_get(&ctx->lock);
while (1) {
iir = rt_16550_reg_in(mode, base, IIR) & IIR_MASK;
if (testbits(iir, IIR_PIRQ))
break;
Loading module:
insmod ./xeno_16550A.ko io=0x3f8,0xbc00 irq=4,3 tx_fifo=10,20 start_index=0
running crosslink test:
sandbox:/usr/src/xenomai/examples/rtdm/profiles/serial# ./cross-link
main : write-file opened
main : write-config written
main : read-file opened
main : read-config written
main : write-task created
main : read-task created
main : starting write-task
main : starting read-task
Nr | write->irq | irq->read | write->read |
-----------------------------------------------------------
read_task: error on RTSER_RTIOC_WAIT_EVENT, Connection timed out
read_task: error on RTSER_RTIOC_WAIT_EVENT, Connection timed out
any ideas?
regards /Bachman
On 09/09/2007, Jan Kiszka <jan.kiszka@domain.hid> wrote:
> > Are there any chance that modifications in the source will get it going?
>
> Maybe we are just lacking some pci_enable_device() on the right pci_dev.
> That would mean extending xeno_16550A to deal with PCI devices. Surely
> feasible, but it takes time and hardware to test - I'm lacking both.
>
> Are you willing to play a bit with it? Then, as a prototype, you could
> pick up the lookup and enabling code from the snx driver and hack it
> into xeno_16550A. If that works, we could discuss how to establish
> something generic for PCI-based adapters.
>
> Note that I haven't read through that driver in details. There is a
> slight risk that some more bits are different. On the other hand, the
> 16650 UART that seems to be on that card is advertised as
> 16550-compatible, thus it /should/ work...
>
> Jan
>
>
>
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-10 13:14 [Xenomai-help] adding PCI support to 16550A.c Bachman Kharazmi @ 2007-09-10 18:24 ` Jan Kiszka 2007-09-10 18:42 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Jan Kiszka @ 2007-09-10 18:24 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 831 bytes --] Bachman Kharazmi wrote: > I've tried to make the pci serial controller visable to the 16550 > driver by adding: > ## FROM 16550A.c > static int rt_16550_interrupt(rtdm_irq_t * irq_context) > { > struct rt_16550_context *ctx; > unsigned long base; > int mode; > int iir; > uint64_t timestamp = rtdm_clock_read(); > int rbytes = 0; > int events = 0; > int modem; > int ret = RTDM_IRQ_NONE; > // TEST > struct pci_dev *pdev = NULL; // from > http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c > pdev = pci_get_device(0, 0, pdev); // from ^^^^^^ You need to provide the fitting vendor and device ID here. Then you have to call pci_device_enable on that pdev - if it's not NULL (ie. not found). That should tell us if it's already enough to enable the device. Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 250 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-10 18:24 ` Jan Kiszka @ 2007-09-10 18:42 ` Bachman Kharazmi 2007-09-10 18:51 ` Jan Kiszka 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-10 18:42 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai A guy recommended me to try to get things going with the working mobo-serialport first before playing with linux drivers and serial controllers.. probabily a good point to start at. Anyhow I tried to used your cross-link.c to write ASCII to serialport rtser0. I connected the cable to the dc motor drive which accepts ASCII commands with CR(\r\n) at the end of every command line. The light version of your code that I was testing with looks like: http://pastebin.ca/690561 I'm trying to write two simple commands in the example, but I couldn't get it working. Don't know why :/ First when I got that working it would be even nicer to be able to give a argument to the binary which is a ASCII command(string) written to rtser0. thanks /Bachman On 10/09/2007, Jan Kiszka <jan.kiszka@domain.hid> wrote: > Bachman Kharazmi wrote: > > I've tried to make the pci serial controller visable to the 16550 > > driver by adding: > > ## FROM 16550A.c > > static int rt_16550_interrupt(rtdm_irq_t * irq_context) > > { > > struct rt_16550_context *ctx; > > unsigned long base; > > int mode; > > int iir; > > uint64_t timestamp = rtdm_clock_read(); > > int rbytes = 0; > > int events = 0; > > int modem; > > int ret = RTDM_IRQ_NONE; > > // TEST > > struct pci_dev *pdev = NULL; // from > > http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c > > pdev = pci_get_device(0, 0, pdev); // from > ^^^^^^ > You need to provide the fitting vendor and device ID here. Then you have > to call pci_device_enable on that pdev - if it's not NULL (ie. not > found). That should tell us if it's already enough to enable the device. > > Jan > > > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-10 18:42 ` Bachman Kharazmi @ 2007-09-10 18:51 ` Jan Kiszka 2007-09-11 15:37 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Jan Kiszka @ 2007-09-10 18:51 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 1248 bytes --] Bachman Kharazmi wrote: > A guy recommended me to try to get things going with the working > mobo-serialport first before playing with linux drivers and serial > controllers.. probabily a good point to start at. For sure. You may also test against a different PC running Linux or a Windoz box with terminal programs installed, BTW. > > Anyhow I tried to used your cross-link.c to write ASCII to serialport > rtser0. I connected the cable to the dc motor drive which accepts > ASCII commands with CR(\r\n) at the end of every command line. > The light version of your code that I was testing with looks like: > http://pastebin.ca/690561 <Quick glance mode> You write strings of different length in lines 152 and 153, but you pass the same size (sz = sizeof(RTIME), ie. 8). > > I'm trying to write two simple commands in the example, but I couldn't > get it working. Don't know why :/ > > First when I got that working it would be even nicer to be able to > give a argument to the binary which is a ASCII command(string) written > to rtser0. Go wild and write such a trivial, command line driver tool to test serial ports! Would be highly appreciated, and quickly accepted into the tree (if it's clean). Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 250 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-10 18:51 ` Jan Kiszka @ 2007-09-11 15:37 ` Bachman Kharazmi 2007-09-11 19:54 ` Jan Kiszka 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-11 15:37 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 2064 bytes --] Now I've a modified crosslink (attached) which take argument and write to rtser0. I know it's ugly. But it's working and that's always good ;) Anyhow. From what I've heard it will be inefficient if my java code would call "/usr/src/xenomai/example/crosslink string" even time a string should be written to serial. And as it looks now I can't even run the binary as user else than root (since it starts a xenmai thread?). How can I as a 'user' open a device, write to it and close it without keeping starting processes or threads every time? I would like to be able to do something like: file = open("/dev/myTestSerialDevice"); while (...) file.write(...) and finally close file.close() when there's no more to write. /Bachman On 10/09/2007, Jan Kiszka <jan.kiszka@domain.hid> wrote: > Bachman Kharazmi wrote: > > A guy recommended me to try to get things going with the working > > mobo-serialport first before playing with linux drivers and serial > > controllers.. probabily a good point to start at. > > For sure. You may also test against a different PC running Linux or a > Windoz box with terminal programs installed, BTW. > > > > > Anyhow I tried to used your cross-link.c to write ASCII to serialport > > rtser0. I connected the cable to the dc motor drive which accepts > > ASCII commands with CR(\r\n) at the end of every command line. > > The light version of your code that I was testing with looks like: > > http://pastebin.ca/690561 > > <Quick glance mode> You write strings of different length in lines 152 > and 153, but you pass the same size (sz = sizeof(RTIME), ie. 8). > > > > > I'm trying to write two simple commands in the example, but I couldn't > > get it working. Don't know why :/ > > > > First when I got that working it would be even nicer to be able to > > give a argument to the binary which is a ASCII command(string) written > > to rtser0. > > Go wild and write such a trivial, command line driver tool to test > serial ports! Would be highly appreciated, and quickly accepted into the > tree (if it's clean). > > Jan > > > [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: cross-link.c --] [-- Type: text/x-csrc; name="cross-link.c", Size: 6180 bytes --] /* * cross-link.c * * Userspace test program (Xenomai native skin) for RTDM-based UART drivers * Copyright 2005 by Joerg Langenberg <joergel75@gmx.net> * * Updates by Jan Kiszka <jan.kiszka@web.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/mman.h> #include <string.h> #include <stdlib.h> #include <native/task.h> #include <native/timer.h> #include <rtdm/rtserial.h> #define MAIN_PREFIX "main : " #define WTASK_PREFIX "write_task: " //#define RTASK_PREFIX "read_task: " #define WRITE_FILE "rtser0" int write_fd = -1; #define STATE_FILE_OPENED 1 #define STATE_TASK_CREATED 2 unsigned int write_state = 0; /* --s-ms-us-ns */ RTIME write_task_period_ns = 100000000llu; RT_TASK write_task; static const struct rtser_config read_config = { .config_mask = 0xFFFF, .baud_rate = 115200, .parity = RTSER_DEF_PARITY, .data_bits = RTSER_DEF_BITS, .stop_bits = RTSER_DEF_STOPB, .handshake = RTSER_DEF_HAND, .fifo_depth = RTSER_DEF_FIFO_DEPTH, .rx_timeout = RTSER_DEF_TIMEOUT, .tx_timeout = RTSER_DEF_TIMEOUT, .event_timeout = 1000000000, /* 1 s */ .timestamp_history = RTSER_RX_TIMESTAMP_HISTORY, .event_mask = RTSER_EVENT_RXPEND, }; static const struct rtser_config write_config = { .config_mask = RTSER_SET_BAUD | RTSER_SET_TIMESTAMP_HISTORY, .baud_rate = 115200, .timestamp_history = RTSER_DEF_TIMESTAMP_HISTORY, /* the rest implicitely remains default */ }; static int close_file( int fd, char *name) { int err, i=0; do { i++; err = rt_dev_close(fd); switch (err) { case -EAGAIN: printf(MAIN_PREFIX "%s -> EAGAIN (%d times)\n", name, i); rt_task_sleep(50000); /* wait 50us */ break; case 0: printf(MAIN_PREFIX "%s -> closed\n", name); break; default: printf(MAIN_PREFIX "%s -> %s\n", name, strerror(-err)); break; } } while (err == -EAGAIN && i < 10); return err; } void cleanup_all(void) { if (write_state & STATE_FILE_OPENED) { close_file(write_fd, WRITE_FILE " (write)"); write_state &= ~STATE_FILE_OPENED; } if (write_state & STATE_TASK_CREATED) { printf(MAIN_PREFIX "delete write_task\n"); rt_task_delete(&write_task); write_state &= ~STATE_TASK_CREATED; } } void catch_signal(int sig) { cleanup_all(); printf(MAIN_PREFIX "exit\n"); return; } //void write_task_proc(void *arg){ void write_task_proc(void *arg){ char* myString1=arg; //printf("%s\n",myString1); int err; // RTIME write_time; int write_time; ssize_t sz = sizeof(RTIME); ssize_t written = 0; int counter=0; err = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(write_task_period_ns)); if (err) { printf(WTASK_PREFIX "error on set periodic, %s\n", strerror(-err)); goto exit_write_task; } while (counter==0) { err = rt_task_wait_period(NULL); if (err) { printf(WTASK_PREFIX "error on rt_task_wait_period, %s\n", strerror(-err)); break; } //write_time = rt_timer_read(); //write_time = 1; // char *mystringa = "EN\r\n"; // char *mystringb = "V0\r\n"; //int test=3; written = rt_dev_write(write_fd, myString1, strlen(myString1)); // written = rt_dev_write(write_fd, mystringb, strlen(mystringb)); if (written < 0 ) { printf(WTASK_PREFIX "error on rt_dev_write, %s\n", strerror(-err)); break; } else if (written != sz) { // printf(WTASK_PREFIX "only %d / %d byte transmitted\n", // written, sz); break; } counter++; } exit(0); exit_write_task: if ((write_state & STATE_FILE_OPENED) && close_file(write_fd, WRITE_FILE " (write)") == 0) write_state &= ~STATE_FILE_OPENED; // printf(WTASK_PREFIX "exit\n"); } int main(int argc , char *argv[]){ int err = 0; //printf("%s\n",argv[1]); char *myString = argv[1]; //printf("%s\n",myString); //printf("%s\n",myString); //char finalString = strcat( char *myString, char *cr ); char *finalString = (char*) malloc(sizeof(char)*(strlen(myString)+3)); sprintf(finalString, "%s\r\n", myString); // signal(SIGTERM, catch_signal); signal(SIGINT, catch_signal); /* no memory-swapping for this programm */ mlockall(MCL_CURRENT | MCL_FUTURE); /* open rtser0 */ write_fd = rt_dev_open( WRITE_FILE, 0); if (write_fd < 0) { printf(MAIN_PREFIX "can't open %s (write), %s\n", WRITE_FILE, strerror(-write_fd)); goto error; } write_state |= STATE_FILE_OPENED; // printf(MAIN_PREFIX "write-file opened\n"); /* writing write-config */ err = rt_dev_ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, &write_config); if (err) { printf(MAIN_PREFIX "error while RTSER_RTIOC_SET_CONFIG, %s\n", strerror(-err)); goto error; } // printf(MAIN_PREFIX "write-config written\n"); /* create write_task */ err = rt_task_create(&write_task, "write_task", 0, 50, 0); if (err) { printf(MAIN_PREFIX "failed to create write_task, %s\n", strerror(-err)); goto error; } write_state |= STATE_TASK_CREATED; // printf(MAIN_PREFIX "write-task created\n"); /* start write_task */ // printf(MAIN_PREFIX "starting write-task\n"); //err = rt_task_start(&write_task, &write_task_proc, NULL); err = rt_task_start(&write_task, &write_task_proc, finalString); if (err) { printf(MAIN_PREFIX "failed to start write_task, %s\n", strerror(-err)); goto error; } pause(); return 0; error: cleanup_all(); return err; } ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-11 15:37 ` Bachman Kharazmi @ 2007-09-11 19:54 ` Jan Kiszka 2007-09-12 14:02 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Jan Kiszka @ 2007-09-11 19:54 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 1989 bytes --] Bachman Kharazmi wrote: > Now I've a modified crosslink (attached) which take argument and write > to rtser0. > I know it's ugly. But it's working and that's always good ;) > > Anyhow. From what I've heard it will be inefficient if my java code > would call "/usr/src/xenomai/example/crosslink string" even time a > string should be written to serial. Yes, it is better to avoid continuous process generations/destructions for such kind of work, rather write a native Java binding to Xenomai in order to talk to the serial port. Hmm... Java... that makes me wonder again if your control loop is ought to be closed over Java and where you got/will get the RT-capable Java engine from. Could you tell us more about the architecture? > > And as it looks now I can't even run the binary as user else than root > (since it starts a xenmai thread?). There is a module parameter of the nucleus called xenomai_gid. Provide a group ID, and all users of that group will gain "Xenomai-power" (means also the power to toast the box by spawning a CPU hog etc.). That allows you to do at least /some/ kind of privilege separation between RT users and root, though not a strictly secure one. Did we already document this feature outside the code? Can't remember right now though I hacked it... :-/ > > How can I as a 'user' open a device, write to it and close it without > keeping starting processes or threads every time? > > I would like to be able to do something like: > file = open("/dev/myTestSerialDevice"); > while (...) > file.write(...) > and finally close > file.close() when there's no more to write. You can copy this code almost unmodified into an application and compile it against the Xenomai POSIX skin. The serial port configuration apart (same under Linux, though), it will open "rtser<whatever>", even if given like "/dev/rtser...", and work on that port as if it where a Linux one. Life can be simple, sometimes. Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 250 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-11 19:54 ` Jan Kiszka @ 2007-09-12 14:02 ` Bachman Kharazmi 2007-09-12 16:22 ` Bachman Kharazmi ` (2 more replies) 0 siblings, 3 replies; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-12 14:02 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai > You can copy this code almost unmodified into an application and compile > it against the Xenomai POSIX skin. The serial port configuration apart > (same under Linux, though), it will open "rtser<whatever>", even if > given like "/dev/rtser...", and work on that port as if it where a Linux > one. Life can be simple, sometimes. Simple? ;) I've tried to write a c-program which basiclly should open the device rtser0 and write 100x to it and then close. The simple program can be found here: http://pastebin.ca/693873 I've connected the serial cable to a reading terminal, but there's no data at all, when I run the binary. :/ /Bachman ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 14:02 ` Bachman Kharazmi @ 2007-09-12 16:22 ` Bachman Kharazmi 2007-09-12 16:33 ` Gilles Chanteperdrix 2007-09-12 16:32 ` Gilles Chanteperdrix 2007-09-12 23:25 ` Jan Kiszka 2 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-12 16:22 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai another example which confuse me: ## void write_task_proc(void *arg){ int err; RTIME write_time; ssize_t sz = sizeof(RTIME); ssize_t written = 0; err = rt_task_set_periodic(NULL, TM_NOW,rt_timer_ns2ticks(write_task_period_ns)); printf("%d\n",err); if (err) { printf(WTASK_PREFIX "error on set periodic, %s\n", strerror(-err)); } while (1) { printf("test1\n"); err = rt_task_wait_period(NULL); printf("%d\n",err); printf("test2\n"); if (err) { printf(WTASK_PREFIX "error on rt_task_wait_period, %s\n", strerror(-err)); break; } .... ## the code does compile, test1 is printed but neither err or test2. so what makes my code stoping executing there? The documentation sais "If NULL, this count will never be copied back." about the argument, but exactlly what does that mean? Why does the work in other code examples I have? /Bachman On 12/09/2007, Bachman Kharazmi <bahkha@domain.hid> wrote: > > You can copy this code almost unmodified into an application and compile > > it against the Xenomai POSIX skin. The serial port configuration apart > > (same under Linux, though), it will open "rtser<whatever>", even if > > given like "/dev/rtser...", and work on that port as if it where a Linux > > one. Life can be simple, sometimes. > > Simple? ;) > I've tried to write a c-program which basiclly should open the device > rtser0 and write 100x to it and then close. > > The simple program can be found here: http://pastebin.ca/693873 > > I've connected the serial cable to a reading terminal, but there's no > data at all, when I run the binary. :/ > > /Bachman > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 16:22 ` Bachman Kharazmi @ 2007-09-12 16:33 ` Gilles Chanteperdrix 2007-09-12 16:43 ` Gilles Chanteperdrix 0 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-12 16:33 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai, Jan Kiszka On 9/12/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > another example which confuse me: > ## > void write_task_proc(void *arg){ > int err; > RTIME write_time; > ssize_t sz = sizeof(RTIME); > ssize_t written = 0; > err = rt_task_set_periodic(NULL, > TM_NOW,rt_timer_ns2ticks(write_task_period_ns)); How much is writ_task_period_ns ? If it is 10000000011, then you should wait around 10 s before "test2" is displayed. -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 16:33 ` Gilles Chanteperdrix @ 2007-09-12 16:43 ` Gilles Chanteperdrix 2007-09-12 19:30 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-12 16:43 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai, Jan Kiszka On 9/12/07, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > On 9/12/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > another example which confuse me: > > ## > > void write_task_proc(void *arg){ > > int err; > > RTIME write_time; > > ssize_t sz = sizeof(RTIME); > > ssize_t written = 0; > > err = rt_task_set_periodic(NULL, > > TM_NOW,rt_timer_ns2ticks(write_task_period_ns)); > > How much is writ_task_period_ns ? If it is 10000000011, then you > should wait around 10 s before "test2" is displayed. Sorry, I confused 1 with l. -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 16:43 ` Gilles Chanteperdrix @ 2007-09-12 19:30 ` Bachman Kharazmi 2007-09-12 22:50 ` Gilles Chanteperdrix 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-12 19:30 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai, Jan Kiszka Sorry I didn't paste my code, http://pastebin.ca/694397 The output from it is: sandbox:/home/bkw/code/driver# ./simpledriver 0 test1 And then it exits, no test2 printed at all.. :/ And nothing in the while loop seem to write to the serialport as I expected. what am I doing wrong? /Bachman On 12/09/2007, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > On 9/12/07, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > > On 9/12/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > > another example which confuse me: > > > ## > > > void write_task_proc(void *arg){ > > > int err; > > > RTIME write_time; > > > ssize_t sz = sizeof(RTIME); > > > ssize_t written = 0; > > > err = rt_task_set_periodic(NULL, > > > TM_NOW,rt_timer_ns2ticks(write_task_period_ns)); > > > > How much is writ_task_period_ns ? If it is 10000000011, then you > > should wait around 10 s before "test2" is displayed. > > Sorry, I confused 1 with l. > -- > Gilles Chanteperdrix > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 19:30 ` Bachman Kharazmi @ 2007-09-12 22:50 ` Gilles Chanteperdrix 0 siblings, 0 replies; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-12 22:50 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai, Jan Kiszka Bachman Kharazmi wrote: > Sorry I didn't paste my code, http://pastebin.ca/694397 > The output from it is: > sandbox:/home/bkw/code/driver# ./simpledriver > 0 > test1 > > And then it exits, no test2 printed at all.. :/ > And nothing in the while loop seem to write to the serialport as I expected. > > what am I doing wrong? You are returning from the main thread, which terminates the whole application. -- Gilles Chanteperdrix. ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 14:02 ` Bachman Kharazmi 2007-09-12 16:22 ` Bachman Kharazmi @ 2007-09-12 16:32 ` Gilles Chanteperdrix 2007-09-12 19:17 ` Bachman Kharazmi 2007-09-12 23:25 ` Jan Kiszka 2 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-12 16:32 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai, Jan Kiszka On 9/12/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > You can copy this code almost unmodified into an application and compile > > it against the Xenomai POSIX skin. The serial port configuration apart > > (same under Linux, though), it will open "rtser<whatever>", even if > > given like "/dev/rtser...", and work on that port as if it where a Linux > > one. Life can be simple, sometimes. > > Simple? ;) > I've tried to write a c-program which basiclly should open the device > rtser0 and write 100x to it and then close. > > The simple program can be found here: http://pastebin.ca/693873 > > I've connected the serial cable to a reading terminal, but there's no > data at all, when I run the binary. :/ You are missing a call to rt_task_shadow. Note that with the POSIX skin, this would not happen, because the main thread is automatically shadowed. > > /Bachman > > _______________________________________________ > Xenomai-help mailing list > Xenomai-help@domain.hid > https://mail.gna.org/listinfo/xenomai-help > -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 16:32 ` Gilles Chanteperdrix @ 2007-09-12 19:17 ` Bachman Kharazmi 0 siblings, 0 replies; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-12 19:17 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai, Jan Kiszka http://pastebin.ca/694372 I did add "err = rt_task_shadow(&task_desc,"mytask",20,T_CPU(0));" and _something_ is sent out on the serialport at least, but not what I expect. What I do get on the other side of my nullmodem looks like: 00 00 00 00 00 00 000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 000000b0: 00 00 00 00 00 00 not what I expected.. :( thanks. /Bachman On 12/09/2007, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > On 9/12/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > > You can copy this code almost unmodified into an application and compile > > > it against the Xenomai POSIX skin. The serial port configuration apart > > > (same under Linux, though), it will open "rtser<whatever>", even if > > > given like "/dev/rtser...", and work on that port as if it where a Linux > > > one. Life can be simple, sometimes. > > > > Simple? ;) > > I've tried to write a c-program which basiclly should open the device > > rtser0 and write 100x to it and then close. > > > > The simple program can be found here: http://pastebin.ca/693873 > > > > I've connected the serial cable to a reading terminal, but there's no > > data at all, when I run the binary. :/ > > You are missing a call to rt_task_shadow. Note that with the POSIX > skin, this would not happen, because the main thread is automatically > shadowed. > > > > > /Bachman > > > > _______________________________________________ > > Xenomai-help mailing list > > Xenomai-help@domain.hid > > https://mail.gna.org/listinfo/xenomai-help > > > > > -- > Gilles Chanteperdrix > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 14:02 ` Bachman Kharazmi 2007-09-12 16:22 ` Bachman Kharazmi 2007-09-12 16:32 ` Gilles Chanteperdrix @ 2007-09-12 23:25 ` Jan Kiszka 2007-09-13 6:14 ` Jan Kiszka 2 siblings, 1 reply; 24+ messages in thread From: Jan Kiszka @ 2007-09-12 23:25 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 1876 bytes --] Bachman Kharazmi wrote: >> You can copy this code almost unmodified into an application and compile >> it against the Xenomai POSIX skin. The serial port configuration apart >> (same under Linux, though), it will open "rtser<whatever>", even if >> given like "/dev/rtser...", and work on that port as if it where a Linux >> one. Life can be simple, sometimes. > > Simple? ;) > I've tried to write a c-program which basiclly should open the device > rtser0 and write 100x to it and then close. > > The simple program can be found here: http://pastebin.ca/693873 > > I've connected the serial cable to a reading terminal, but there's no > data at all, when I run the binary. :/ > [Untested late-night hack after some Maß of beer - please excuse potential nonsense.] POSIX skin ---------- (use xeno-config --posix-cflags --posix-ldflags as compiler args) #include bla bla bla static const struct rtser_config write_config = { .config_mask = RTSER_SET_BAUD, .baud_rate = 115200, }; int main(int argc, char *argv[]) { int fd; fd = open("/dev/rtser0", O_RDWR); ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); write(fd, argv[1], strlen(argv[1])); close(fd); return 0; } Native skin ----------- ... int main(int argc, char *argv[]) { int fd; RT_TASK task; fd = rt_dev_open("/dev/rtser0", O_RDWR); rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); rt_task_shadow(&task, NULL, 0, 0); /* may be done earlier, but not later */ rt_dev_write(fd, argv[1], strlen(argv[1])); rt_dev_close(fd); return 0; } Similar is imaginable for reading from the serial port. Completed and tested versions, maybe also taking the baudrate as argument, will be happily accepted to the examples or tools repos. Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 250 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-12 23:25 ` Jan Kiszka @ 2007-09-13 6:14 ` Jan Kiszka 2007-09-13 9:38 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Jan Kiszka @ 2007-09-13 6:14 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai [-- Attachment #1: Type: text/plain, Size: 2169 bytes --] Jan Kiszka wrote: > Bachman Kharazmi wrote: >>> You can copy this code almost unmodified into an application and compile >>> it against the Xenomai POSIX skin. The serial port configuration apart >>> (same under Linux, though), it will open "rtser<whatever>", even if >>> given like "/dev/rtser...", and work on that port as if it where a Linux >>> one. Life can be simple, sometimes. >> Simple? ;) >> I've tried to write a c-program which basiclly should open the device >> rtser0 and write 100x to it and then close. >> >> The simple program can be found here: http://pastebin.ca/693873 >> >> I've connected the serial cable to a reading terminal, but there's no >> data at all, when I run the binary. :/ >> > > [Untested late-night hack after some Maß of beer - please excuse > potential nonsense.] > > POSIX skin > ---------- > (use xeno-config --posix-cflags --posix-ldflags as compiler args) > > #include bla bla bla > > static const struct rtser_config write_config = { > .config_mask = RTSER_SET_BAUD, > .baud_rate = 115200, > }; > > int main(int argc, char *argv[]) > { > int fd; > > fd = open("/dev/rtser0", O_RDWR); > ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > write(fd, argv[1], strlen(argv[1])); > close(fd); > > return 0; > } > > > Native skin > ----------- > > ... > int main(int argc, char *argv[]) > { > int fd; > RT_TASK task; > > fd = rt_dev_open("/dev/rtser0", O_RDWR); The first error, copy&paste: This must be just "rtser0". > rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > > rt_task_shadow(&task, NULL, 0, 0); /* may be done earlier, > but not later */ > > rt_dev_write(fd, argv[1], strlen(argv[1])); > rt_dev_close(fd); > > return 0; > } > > > Similar is imaginable for reading from the serial port. > > Completed and tested versions, maybe also taking the baudrate as > argument, will be happily accepted to the examples or tools repos. BTW, a generic serial dump tool should, of course, also take the port number as parameter. Jan [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 250 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 6:14 ` Jan Kiszka @ 2007-09-13 9:38 ` Bachman Kharazmi 2007-09-13 9:45 ` Gilles Chanteperdrix 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-13 9:38 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai int main(int argc) { int fd; char* myString = "helloworld\n"; fd = open("rtser0", O_RDWR); ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); write(fd, myString, strlen(myString)); close(fd); return 0; } Is supposed to be the POSIX skin. It does compile, but nothing sent on my serial port. On 13/09/2007, Jan Kiszka <jan.kiszka@domain.hid> wrote: > Jan Kiszka wrote: > > Bachman Kharazmi wrote: > >>> You can copy this code almost unmodified into an application and compile > >>> it against the Xenomai POSIX skin. The serial port configuration apart > >>> (same under Linux, though), it will open "rtser<whatever>", even if > >>> given like "/dev/rtser...", and work on that port as if it where a Linux > >>> one. Life can be simple, sometimes. > >> Simple? ;) > >> I've tried to write a c-program which basiclly should open the device > >> rtser0 and write 100x to it and then close. > >> > >> The simple program can be found here: http://pastebin.ca/693873 > >> > >> I've connected the serial cable to a reading terminal, but there's no > >> data at all, when I run the binary. :/ > >> > > > > [Untested late-night hack after some Maß of beer - please excuse > > potential nonsense.] > > > > POSIX skin > > ---------- > > (use xeno-config --posix-cflags --posix-ldflags as compiler args) > > > > #include bla bla bla > > > > static const struct rtser_config write_config = { > > .config_mask = RTSER_SET_BAUD, > > .baud_rate = 115200, > > }; > > > > int main(int argc, char *argv[]) > > { > > int fd; > > > > fd = open("/dev/rtser0", O_RDWR); > > ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > > write(fd, argv[1], strlen(argv[1])); > > close(fd); > > > > return 0; > > } > > > > > > Native skin > > ----------- > > > > ... > > int main(int argc, char *argv[]) > > { > > int fd; > > RT_TASK task; > > > > fd = rt_dev_open("/dev/rtser0", O_RDWR); > > The first error, copy&paste: This must be just "rtser0". > > > rt_dev_ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > > > > rt_task_shadow(&task, NULL, 0, 0); /* may be done earlier, > > but not later */ > > > > rt_dev_write(fd, argv[1], strlen(argv[1])); > > rt_dev_close(fd); > > > > return 0; > > } > > > > > > Similar is imaginable for reading from the serial port. > > > > Completed and tested versions, maybe also taking the baudrate as > > argument, will be happily accepted to the examples or tools repos. > > BTW, a generic serial dump tool should, of course, also take the port > number as parameter. > > Jan > > > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 9:38 ` Bachman Kharazmi @ 2007-09-13 9:45 ` Gilles Chanteperdrix 2007-09-13 9:51 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-13 9:45 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai, Jan Kiszka On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > int main(int argc) > { > int fd; > char* myString = "helloworld\n"; > fd = open("rtser0", O_RDWR); > ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > write(fd, myString, strlen(myString)); > close(fd); > return 0; > } > Is supposed to be the POSIX skin. It does compile, but nothing sent on > my serial port. This code is crappy. You do not check the return values of functions which return a result so you have no chance to understand what happens. -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 9:45 ` Gilles Chanteperdrix @ 2007-09-13 9:51 ` Bachman Kharazmi 2007-09-13 9:56 ` Gilles Chanteperdrix 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-13 9:51 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai int main(int argc){ int fd,err; char* myString = "helloworld\n"; fd = open("rtser0", O_RDWR); printf("fd is %d\n", fd); ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); err=write(fd, myString, strlen(myString)); printf("err is %d\n", err); close(fd); return 0; } gives sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 fd is -1 err is -1 Which means that fd didn't open the device successfully? :/ /B On 13/09/2007, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > int main(int argc) > > { > > int fd; > > char* myString = "helloworld\n"; > > fd = open("rtser0", O_RDWR); > > ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > > write(fd, myString, strlen(myString)); > > close(fd); > > return 0; > > } > > Is supposed to be the POSIX skin. It does compile, but nothing sent on > > my serial port. > > This code is crappy. You do not check the return values of functions > which return a result so you have no chance to understand what > happens. > > -- > Gilles Chanteperdrix > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 9:51 ` Bachman Kharazmi @ 2007-09-13 9:56 ` Gilles Chanteperdrix [not found] ` <1ce16a2c0709130307k5e1955d4na694e90503084d0d@domain.hid> 0 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-13 9:56 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: xenomai On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > int main(int argc){ > int fd,err; > char* myString = "helloworld\n"; > fd = open("rtser0", O_RDWR); > printf("fd is %d\n", fd); > ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > err=write(fd, myString, strlen(myString)); > printf("err is %d\n", err); > close(fd); > return 0; > } > > gives > sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 > fd is -1 > err is -1 > > Which means that fd didn't open the device successfully? :/ > /B This is POSIX, when a function call returns -1, check errno to see the failure reason. BTW, you did not check the return value of ioctl. -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
[parent not found: <1ce16a2c0709130307k5e1955d4na694e90503084d0d@domain.hid>]
* Re: [Xenomai-help] adding PCI support to 16550A.c [not found] ` <1ce16a2c0709130307k5e1955d4na694e90503084d0d@domain.hid> @ 2007-09-13 12:18 ` Gilles Chanteperdrix 2007-09-13 12:41 ` Bachman Kharazmi 0 siblings, 1 reply; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-13 12:18 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: Xenomai On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > int main(int argc){ > int fd,err; > char* myString = "helloworld\n"; > fd = open("rtser0", O_RDWR); > if (fd < 0) { > printf(MAIN_PREFIX "1 : can't open %s (write), %s\n", WRITE_FILE, > strerror(-fd)); > return fd; > } > err=ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > if (err < 0) { > printf(MAIN_PREFIX "2 : error %s (write), %s\n", WRITE_FILE, strerror(-fd)); > return err; > } > err=write(fd, myString, strlen(myString)); > if (err < 0) { > printf(MAIN_PREFIX "3 : error %s (write), %s\n", WRITE_FILE, strerror(-fd)); > return err; > } > printf("err is %d\n", err); > close(fd); > return 0; > } > > sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 > main : 1 : can't open rtser0 (write), Operation not permitted > > why that, I'm running as root? :/ > /BK When a posix function returns -1, the reason for the failure is stored in errno. You are not checking errno. If you do not know what errno is, type simply "man errno". -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 12:18 ` Gilles Chanteperdrix @ 2007-09-13 12:41 ` Bachman Kharazmi 2007-09-13 12:48 ` Gilles Chanteperdrix 0 siblings, 1 reply; 24+ messages in thread From: Bachman Kharazmi @ 2007-09-13 12:41 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: Xenomai #include <errno.h> ... int main(int argc){ int fd,err; extern int errno; char* myString = "helloworld\n"; errno=0; fd = open("rtser0", O_RDWR); printf("errno is : %d\n",errno); if (fd < 0) { printf(MAIN_PREFIX "1 : can't open %s (write), %s\n", WRITE_FILE, strerror(-fd)); return fd; } sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 errno is : 2 main : 1 : can't open rtser0 (write), Operation not permitted Correct way of using errno? Hope so.. /Bachman On 13/09/2007, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > > int main(int argc){ > > int fd,err; > > char* myString = "helloworld\n"; > > fd = open("rtser0", O_RDWR); > > if (fd < 0) { > > printf(MAIN_PREFIX "1 : can't open %s (write), %s\n", WRITE_FILE, > > strerror(-fd)); > > return fd; > > } > > err=ioctl(fd, RTSER_RTIOC_SET_CONFIG, &write_config); > > if (err < 0) { > > printf(MAIN_PREFIX "2 : error %s (write), %s\n", WRITE_FILE, strerror(-fd)); > > return err; > > } > > err=write(fd, myString, strlen(myString)); > > if (err < 0) { > > printf(MAIN_PREFIX "3 : error %s (write), %s\n", WRITE_FILE, strerror(-fd)); > > return err; > > } > > printf("err is %d\n", err); > > close(fd); > > return 0; > > } > > > > sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 > > main : 1 : can't open rtser0 (write), Operation not permitted > > > > why that, I'm running as root? :/ > > /BK > > When a posix function returns -1, the reason for the failure is stored > in errno. You are not checking errno. > If you do not know what errno is, type simply "man errno". > > -- > Gilles Chanteperdrix > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [Xenomai-help] adding PCI support to 16550A.c 2007-09-13 12:41 ` Bachman Kharazmi @ 2007-09-13 12:48 ` Gilles Chanteperdrix 0 siblings, 0 replies; 24+ messages in thread From: Gilles Chanteperdrix @ 2007-09-13 12:48 UTC (permalink / raw) To: Bachman Kharazmi; +Cc: Xenomai On 9/13/07, Bachman Kharazmi <bahkha@domain.hid> wrote: > #include <errno.h> > ... > int main(int argc){ > int fd,err; > extern int errno; > char* myString = "helloworld\n"; > errno=0; > fd = open("rtser0", O_RDWR); > printf("errno is : %d\n",errno); > if (fd < 0) { > printf(MAIN_PREFIX "1 : can't open %s (write), %s\n", WRITE_FILE, > strerror(-fd)); > return fd; > } > > sandbox:/home/bkw/code/driver_v4# ./simpledriver_v4 > errno is : 2 > main : 1 : can't open rtser0 (write), Operation not permitted > > Correct way of using errno? No, as indicated in errno manual page, the value of errno is defined only if a system call indicates a failure. So, the correct way of using errno is: fd = open("rtser0", O_RDWR) if (fd == -1) { fprintf(stderr, "open(rtser0): %s\n", strerror(errno)); exit(EXIT_FAILURE); } or: if (fd == -1) { perror("open(rtser0)"); exit(EXIT_FAILURE); } Anyway, 2 is ENOENT strerror(2) is "No such file or directory" It probably means that you are not compiling your program with the flags returned by xeno-config. -- Gilles Chanteperdrix ^ permalink raw reply [flat|nested] 24+ messages in thread
* [Xenomai-help] adding PCI support to 16550A.c
@ 2007-09-10 13:14 Bachman Kharazmi
0 siblings, 0 replies; 24+ messages in thread
From: Bachman Kharazmi @ 2007-09-10 13:14 UTC (permalink / raw)
To: xenomai
I've tried to make the pci serial controller visable to the 16550
driver by adding:
## FROM 16550A.c
static int rt_16550_interrupt(rtdm_irq_t * irq_context)
{
struct rt_16550_context *ctx;
unsigned long base;
int mode;
int iir;
uint64_t timestamp = rtdm_clock_read();
int rbytes = 0;
int events = 0;
int modem;
int ret = RTDM_IRQ_NONE;
// TEST
struct pci_dev *pdev = NULL; // from
http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c
pdev = pci_get_device(0, 0, pdev); // from
http://bachman.tor.lindesign.se/tmp/driver/sunix/snx_golden.c
//
ctx = rtdm_irq_get_arg(irq_context, struct rt_16550_context);
base = ctx->base_addr;
mode = rt_16550_io_mode_from_ctx(ctx);
rtdm_lock_get(&ctx->lock);
while (1) {
iir = rt_16550_reg_in(mode, base, IIR) & IIR_MASK;
if (testbits(iir, IIR_PIRQ))
break;
Loading module:
insmod ./xeno_16550A.ko io=0x3f8,0xbc00 irq=4,3 tx_fifo=10,20 start_index=0
running crosslink test:
sandbox:/usr/src/xenomai/examples/rtdm/profiles/serial# ./cross-link
main : write-file opened
main : write-config written
main : read-file opened
main : read-config written
main : write-task created
main : read-task created
main : starting write-task
main : starting read-task
Nr | write->irq | irq->read | write->read |
-----------------------------------------------------------
read_task: error on RTSER_RTIOC_WAIT_EVENT, Connection timed out
read_task: error on RTSER_RTIOC_WAIT_EVENT, Connection timed out
any ideas?
regards /Bachman
On 09/09/2007, Jan Kiszka <jan.kiszka@domain.hid> wrote:
> > Are there any chance that modifications in the source will get it going?
>
> Maybe we are just lacking some pci_enable_device() on the right pci_dev.
> That would mean extending xeno_16550A to deal with PCI devices. Surely
> feasible, but it takes time and hardware to test - I'm lacking both.
>
> Are you willing to play a bit with it? Then, as a prototype, you could
> pick up the lookup and enabling code from the snx driver and hack it
> into xeno_16550A. If that works, we could discuss how to establish
> something generic for PCI-based adapters.
>
> Note that I haven't read through that driver in details. There is a
> slight risk that some more bits are different. On the other hand, the
> 16650 UART that seems to be on that card is advertised as
> 16550-compatible, thus it /should/ work...
>
> Jan
>
>
>
^ permalink raw reply [flat|nested] 24+ messages in threadend of thread, other threads:[~2007-09-13 12:48 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 13:14 [Xenomai-help] adding PCI support to 16550A.c Bachman Kharazmi
2007-09-10 18:24 ` Jan Kiszka
2007-09-10 18:42 ` Bachman Kharazmi
2007-09-10 18:51 ` Jan Kiszka
2007-09-11 15:37 ` Bachman Kharazmi
2007-09-11 19:54 ` Jan Kiszka
2007-09-12 14:02 ` Bachman Kharazmi
2007-09-12 16:22 ` Bachman Kharazmi
2007-09-12 16:33 ` Gilles Chanteperdrix
2007-09-12 16:43 ` Gilles Chanteperdrix
2007-09-12 19:30 ` Bachman Kharazmi
2007-09-12 22:50 ` Gilles Chanteperdrix
2007-09-12 16:32 ` Gilles Chanteperdrix
2007-09-12 19:17 ` Bachman Kharazmi
2007-09-12 23:25 ` Jan Kiszka
2007-09-13 6:14 ` Jan Kiszka
2007-09-13 9:38 ` Bachman Kharazmi
2007-09-13 9:45 ` Gilles Chanteperdrix
2007-09-13 9:51 ` Bachman Kharazmi
2007-09-13 9:56 ` Gilles Chanteperdrix
[not found] ` <1ce16a2c0709130307k5e1955d4na694e90503084d0d@domain.hid>
2007-09-13 12:18 ` Gilles Chanteperdrix
2007-09-13 12:41 ` Bachman Kharazmi
2007-09-13 12:48 ` Gilles Chanteperdrix
-- strict thread matches above, loose matches on Subject: below --
2007-09-10 13:14 Bachman Kharazmi
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.