Re: [PATCH v9] can, tty: can327 CAN/ldisc driver for ELM327 based OBD-II adapters
From: Max Staudt
Date: Tue Jul 05 2022 - 06:39:21 EST
On Tue, 5 Jul 2022 12:16:08 +0200
Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > > I had a quick glance through the various revisions posted, and
> > > > it doesn't seem like anyone mentioned the serial bus. Would
> > > > there be any advantage in migrating to the serial bus?
> > >
> > > Does serial bus work with hot plug devices like USB Serial
> > > Adapters and/or devices that are not described in the device
> > > tree?
>
> Probably it cannot work with hot-plug devices yet.
> And devices must be described in some way (DT, ACPI), it does not
> support auto-detect.
Correct!
> So far I've seen serial bus used with e.g. bluetooth and DT.
> I'm wondering if/how people use it with bluetooth connected to a
> hot-pluggable device like usb-serial.
They don't :)
serdev is (currently, still, AFAIK) only for devices permanently
attached to a platform - hence they can be reliably described as part
of the platform itself, be it via DT or ACPI or whatever. So the fact,
say, that the "Nokia N900" has a BT module permanently soldered to "UART
2", that's something you can encode in its DT, because it applies to
this device, and this device only.
The ELM327 and clones are merely naked USB/BT-UART bridges with default
VID/PID to the computer, and some variants are classic RS232 devices.
No way to identify them, as they can appear/disappear on any UART,
anywhere. So you need to attach them manually - and to my knowledge,
such a manual mechanism is still missing from serdev. So we have to use
a line discipline, as that has an API to attach from userspace.
This also explains how to use Bluetooth via USB: Either it's a VID/PID
known to some driver speaking native USB, or... well, for UARTs there's
btattach and hciattach (both part of BlueZ), and both use the N_HCI
line discipline. No serdev involved. I don't know if any USB-UART-BT
device with a unique VID/PID exists, and I don't know whether serdev
could be attached kernel-side in this case.
Max