I amn't familiar with CAN, but is it possible to implement a general
CAN MAC driver on top of CAN CHAR driver like this?
+-------------------------------+
| NuttX Network driver |
| +------------+ +------------+ |
| |Syscall glue| |BSD Socket | |
| | | |glue | |
| +------------+ +------------+ |
+-------------------------------+
+-------------------------------+ file_* +-------------------------------+
| Hardware MAC driver |---------->| NuttX CAN Driver (can.c) |
+-------------------------------+ | +------------+ +------------+ |
| |Syscall glue| |Char driver | |
| | | |glue | |
| +------------+ +------------+ |
+-------------------------------+
+-------------------------------+
| Hardware CAN driver |
+-------------------------------+
So we just need write one CAN driver, but the user can select socket
or char as they want.
Thanks
Xiang
On Tue, Feb 11, 2020 at 11:21 PM Gregory Nutt <[email protected]> wrote:
>
>
> > NuttX CAN Implementation NuttX Ethernet Implementation
> >
> > +-------------------------------+ +-------------------------------+
> > | Application | | Application |
> > +-------------------------------+ +-------------------------------+
> > +-------------------------------+ +-------------------------------+
> > | POSIX Interface | | POSIX Interface |
> > +-------------------------------+ +-------------------------------+
> > +-------------+ +-------------+ +-------------+ +-------------+
> > |System calls | |VFS (fs/vfs) | |System calls | |BSD socket |
> > | | | | | | |net/sockets |
> > +-------------+ +-------------+ +-------------+ +-------------+
> > +-------------------------------+ +-------------------------------+
> > | NuttX CAN Driver (can.c) | | NuttX Network driver |
> > | +------------+ +------------+ | | +------------+ +------------+ |
> > | |Syscall glue| |Char driver | | | |Syscall glue| |BSD Socket | |
> > | | | |glue | | | | | |glue | |
> > | +------------+ +------------+ | | +------------+ +------------+ |
> > +-------------------------------+ +-------------------------------+
> > +-------------------------------+ +-------------------------------+
> > | Hardware CAN driver | | Hardware MAC driver |
> > +-------------------------------+ +-------------------------------+
> > +-------------------------------+ +-------------------------------+
> > |OS (sched/), memory manager | |OS (sched/), memory manager |
> > |(mm/), common libraries (libs/)| |(mm/), common libraries (libs/)|
> > +-------------------------------+ +-------------------------------+
> > +-------------------------------+ +-------------------------------+
> > | Hardware | | Hardware |
> > +-------------------------------+ +-------------------------------+
> > (Note this is ASCII art use a monospace font to view correctly)
> >
> I believe that both sides would be the same. Both would use BSD
> sockets, SocketCAN would be added to the network stacks, and the CAN
> drivers would be a network drivers.
>
> Your picture shows the existing implementation using character drivers.
> SocketCAN is intended to be integrated into the network.
>
>