 |
|
| Linux Forum Index » Linux Development - System » Character Drivers in User-Space... |
|
Page 2 of 2 Goto page Previous 1, 2 |
|
| Author |
Message |
| Bob Smith... |
Posted: Fri Oct 16, 2009 1:34 pm |
|
|
|
Guest
|
Jan Kandziora wrote:
Quote: Bob Smith schrieb:
OK, but this might come down to personal preference. I like the
idea of telling a stepper motor to step 2000 steps with the command:
echo "2000" > /dev/dp/step_count
Sure, it's personal preference, but I think not mine alone. The thing above
is not a commonly expected way to work with device nodes. It more
resembles /proc or /sys nodes. To a device node, nearly all users expect
they once open the node, then continously talk to it. I would also not
expect to talk in ascii, except for terminal devices.
You are correct. This is a poor example. Let's divide a driver into
two parts -- the stream data and driver configuration. For a stepper
motor step_count would be the stream data and something you set once,
like step_rate, would be configuration. Most often stream data is
binary, agreed. Configuration, because it is done so seldom can be
either binary (e.g. an ioctl()) or ASCII (e.g. /proc). Whether to do
ASCII or binary encoding might be a separate discussion, but our initial
intent is to use binary for stream data and ASCII for configuration.
Quote: The thing above could be implemented through FUSE, though -- "owfs" does it
that way. Google it, it pretty much does the same hardware muxer job your
program does.
When I first started into all of this I pinned my hopes on FUSE. FUSE
was very definitely "Plan A". But FUSE is just not ready for use for
bidirectional data with select() support and good flow control. I wish
it was. As a FUSE client, owfs has the same limitation that FUSE does.
Quote: Um, you have an ascii protocol above... It's a piece of cake just sending
name+SPACE+value+LF through a TCP connection, any reasonable high-level
language could do that by printf() or similar. It would even be
network-enabled ootb.
Right. All character drivers have the problem of how to send data
that is larger than one byte. The /dev/input system solves this by
sending data in packets with a guaranteed byte pattern to mark the
start of a packet. Another solution to the same problem is to use
ASCII encoding and mark the end of the packet with a newline. The
/dev/input approach is more CPU efficient, and the ASCII approach
is a little easier to experiment with.
Quote: I did not mention "concurrent access" but perhaps this refers to
the idea of broadcast? One writer and many concurrent readers?
As any reader must be known to the writer in your case, I would not call
it "broadcast". Broadcast means "shouting out into space". For that, it
needs a common media, e.g. shared memory or a network with broadcast
features.
OK. Let's call it "fanout" instead of broadcast.
Quote: Both named pipes and pty devices allow you to write up to 4K bytes
when just one end is open. I wanted to block all writes until
both ends were open. "Flow control" to me refers to select() in
a way. I need bidirectional transfer (ruling out named pipes)
and wanted flow control to flow in both directions up to the
select() on each side. One side being the driver daemon and the
other side being the high-level robot application. I hope this
makes sense.
It does. Your previous design choices, especially the one to allow arbitrary
programs to control anything like they want to, narrow it down to that.
Jan, the reason I posted originally was to improve on what I did,
to find a better way. If you had to write 30 or so device drivers
quickly and with minimal code, how would you do it?
thanks
Bob Smith |
|
|
| Back to top |
|
|
|
| Jan Kandziora... |
Posted: Fri Oct 16, 2009 3:33 pm |
|
|
|
Guest
|
Bob Smith schrieb:
Quote: [...]
select() on each side. One side being the driver daemon and the
other side being the high-level robot application. I hope this
makes sense.
It does. Your previous design choices, especially the one to allow
arbitrary programs to control anything like they want to, narrow it down
to that.
Jan, the reason I posted originally was to improve on what I did,
to find a better way. If you had to write 30 or so device drivers
quickly and with minimal code, how would you do it?
Hmm. The thing which let *me* shudder most is the kernel module required.
I have a H+/DXR3 MPEG decoder card in my private PC as a TV-out device. It
has some I²C chips on it and requires a kernel driver. Ok, nearly
unavoidable in that case.
What's kind of horrible is that the I²C subsystem of the Linux kernel had an
incompatible change with *any* version since 2.6.15 until now. That means
the people doing the DXR3 driver had to do some tweaking and testing to
their sources *15* times. And I always had to wait with kernel upgrade
until they caught up.
I think about it a little more tomorrow.
Kind regards
Jan |
|
|
| Back to top |
|
|
|
| Grant Edwards... |
Posted: Fri Oct 16, 2009 7:22 pm |
|
|
|
Guest
|
On 2009-10-16, Jan Kandziora <jjj at (no spam) gmx.de> wrote:
Quote: I have a H+/DXR3 MPEG decoder card in my private PC as a
TV-out device. It has some I?C chips on it and requires a
kernel driver. Ok, nearly unavoidable in that case.
What's kind of horrible is that the I?C subsystem of the Linux
kernel had an incompatible change with *any* version since
2.6.15 until now. That means the people doing the DXR3 driver
had to do some tweaking and testing to their sources *15*
times.
Such is the life of a Linux driver maintainer. Sometimes I
think the kernel maintainers are actively trying to punish
people who's job it is to maintain out-of-tree device drivers.
I've come to believe that there's a certain amount of disdain
in the Linux world for third-party drivers (even if they're
open-source and GPL compatible).
--
Grant |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Sat Nov 28, 2009 3:50 pm
|
|