qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Writing a CAN driver for QEMU


From: Stefan Weil
Subject: Re: [Qemu-devel] Writing a CAN driver for QEMU
Date: Sun, 19 May 2013 18:14:50 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6

Am 19.05.2013 15:19, schrieb Paolo Bonzini:
> Il 19/05/2013 14:58, Paolo Bonzini ha scritto:
>> Is this CAN device just an Ethernet device?  QEMU does not support other
>> link-level protocols.  Adding them would be possible and interesting,
>> however it would add a bit to the complexity.
>>
>> Both would be the same.  In the first case, you'd probably use "-netdev
>> socket" to share a virtual network between two virtual machines.  In the
>> second, you would use something like "-netdev tap" (again assuming it's
>> just an Ethernet device).
> Ok, learnt a bit more...  You could probably implement this in two ways:
> 1) "-netdev socket" would probably work as a CAN->UDP gateway; 2)
> connecting to a virtual CAN interface in the host, created using
> SocketCAN (similar to "-netdev tap", e.g. "-netdev cantap").
>
> In the first case, it would probably be useful to write the matching
> UDP->CAN gateway program.
>
> In any case, you have to implement both the backend and the actual device.
>
> Paolo

I used TCP instead of UDP in a proprietary solution more than
10 years ago.

CAN devices are connected to CAN buses, so I had a CAN device
emulation (on CAN API level, not on hardware level like with QEMU)
and a CAN bus emulation.

The CAN bus emulation was a TCP server process. It could simulate
several CAN buses.

Each CAN controllerwas a TCP client connected to the CAN bus emulation.

The TCP clients sent CAN data packets (length, packet type and data)
to the TCP server and received such packets from the server.
They also exchanged control packets with the server (topology = which bus,
data rate, CAN filter settings).

The CAN bus emulation routed each received packet to other CAN controllers
on the same bus (CAN is a broadcast protocol) and could also simulate
error packets (for example when there was a mismatch of the data rates
between sender and receiver). In debug mode, the bus emulation could
also display the packets (raw data or CAN Open packets).

Several CAN vendors provide bidirectional CAN-Ethernet gateways,
but I don't know whether there is a standard for CAN-over-Ethernet.

Regards,
Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]