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 <[EMAIL PROTECTED]> 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
>
>
>
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help