From nobody Mon Oct 21 20:21:16 2024 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XXRXq6t7Qz5ZjkF for ; Mon, 21 Oct 2024 20:21:31 +0000 (UTC) (envelope-from tomek@cedro.info) Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XXRXq00QHz4bL4 for ; Mon, 21 Oct 2024 20:21:30 +0000 (UTC) (envelope-from tomek@cedro.info) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cedro.info header.s=google header.b=OX34laCZ; spf=none (mx1.freebsd.org: domain of tomek@cedro.info has no SPF policy when checking 2607:f8b0:4864:20::b36) smtp.mailfrom=tomek@cedro.info; dmarc=none Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-e297c8f8c86so4866525276.2 for ; Mon, 21 Oct 2024 13:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cedro.info; s=google; t=1729542089; x=1730146889; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=j71IBIcqvML13vc6caPfbldOIU72CR5QuWPV18W/Wqc=; b=OX34laCZRqpG7JkRQe924T4lzbmzlTrJT6ll1eoN7Opvx8Dj402jFaPO97kcOyQrZ7 NyA1PuH73Nx4DdcdcwhfFOIMfXLC6j7aQL4VGeR0DVHje2qT/+tq9nCkLMY5cVgzpJJw c4o6zUiuJ7y6vQ5Aj4SqJtkibmWuUu5cfkBhf5GVMRGNXkMXZyoYNcixfRt6Icyc2N/L d7nZj/xjXIGt8s8OXkdbY5rjVnJNfSqKkF9tG5/9KOuJUNyiirv98wGGpQxx8S6IrXom VZ/pBHFAE1eNjGnsvRqmjNsMO8ddr6J9q7LfC7XAyp1MBEsyB+GmD9S8i9KRG8Qm+hUG UySA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729542089; x=1730146889; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j71IBIcqvML13vc6caPfbldOIU72CR5QuWPV18W/Wqc=; b=ua3ynHHyhM+T1LD4jkivqv7byIIcdUK0Ldi5to/LJyjsgAiZQuQLBNJdjVeqvmLk1X k1qAppmaKQ7Vm0TjCa1WFcWk3flbR8t9vSxbWUeGJRuCkXUK1k1b1UQAuhONW8GIJfGd +RLhwCr+gwomqAiwR/z1GTo2w4bFqOnviI99gXl3kdgQimzKyQ/nfLH3b54OKeeJLSU/ Fi5rzVJbLtQdmJ0a5r9GTWGSOH+VzLnsM2TkCaWZumvLR9QlCE6wH2CJ3qWE49pQUhC4 +TzAQIbl8VSA7iYFfBA9h0oGQLm2ZSDsUluGj29NwMk9zRBN8qfkoovpfvqZ/2slsUD1 sz/A== X-Gm-Message-State: AOJu0YyNEF/XYCeyBY5Rx3em6+mwSkWRXf1VLEdNtv64xDJr1CxwZnBz RoE6wD9jcngrEZCOGGdr6yxVDUyd3UYPOeNrcc4rW50kMqkJUugAr3Q4DbrfvS8pL3fnTlyfVJQ = X-Google-Smtp-Source: AGHT+IFvLHjWBmRPdyAr7DMgh5rzECm2E2L7HW7z8UXKcvUlOj6pK/Gprm2I9QQkWmt2ygzJJt2z5A== X-Received: by 2002:a05:690c:dc8:b0:6e2:f61e:8c9 with SMTP id 00721157ae682-6e5bfd4ca84mr127425237b3.30.1729542089223; Mon, 21 Oct 2024 13:21:29 -0700 (PDT) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e5f5ccb641sm8080047b3.83.2024.10.21.13.21.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Oct 2024 13:21:28 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e29756dc019so4579317276.3 for ; Mon, 21 Oct 2024 13:21:28 -0700 (PDT) X-Received: by 2002:a05:690c:fc2:b0:6e3:39c1:1692 with SMTP id 00721157ae682-6e5bfbebc36mr110691737b3.6.1729542088125; Mon, 21 Oct 2024 13:21:28 -0700 (PDT) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: <202410210954.49L9s9sD076618@critter.freebsd.dk> <203ADA8C-A4ED-4849-B89D-6D18664D67D0@webweaving.org> In-Reply-To: <203ADA8C-A4ED-4849-B89D-6D18664D67D0@webweaving.org> From: Tomek CEDRO Date: Mon, 21 Oct 2024 22:21:16 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: pyserial.tools.list_port improvement for FreeBSD To: Poul-Henning Kamp Cc: hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.23 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.93)[-0.934]; R_DKIM_ALLOW(-0.20)[cedro.info:s=google]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_SPF_NA(0.00)[no SPF record]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[cedro.info]; RCPT_COUNT_TWO(0.00)[2]; MLMMJ_DEST(0.00)[hackers@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::b36:from,209.85.219.180:received]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[hackers@freebsd.org]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[cedro.info:+] X-Rspamd-Queue-Id: 4XXRXq00QHz4bL4 X-Spamd-Bar: --- On Mon, Oct 21, 2024 at 9:04=E2=80=AFPM Dirk-Willem van Gulik wrote: > On 21 Oct 2024, at 11:54, Poul-Henning Kamp wrote: > > I have had reason to muck about with pyserial. One result is much bette= r pyserial.tools.list_port implementation for FreeBSD. > > I would appreciate it, if somebody else could give it a spin, before I = upstream: > > https://github.com/bsdphk/pyserial > > Works for me (provided /usr/sbin is in the path); and nicely picks up a u= gen0.2 that the ESP32 tooling would always need an explicit path for prior = despite it having a tty name. Very cool PHK! But I have some more ideas below :-) :-P % uname -a FreeBSD octagon 13.3-RELEASE-p7 FreeBSD 13.3-RELEASE-p7 GENERIC amd64 On current 3.5 system py311 package: >>> list_ports.main() /dev/cuaU0 /dev/cuaU1 /dev/cuaU2 /dev/cuaU3 /dev/cuaU4 /dev/cuau0 6 ports found On Your repo from 3.9 venv: (venv3.9embedded) python3 list_ports_freebsd.py /dev/cuaU0 - ugen0.7: usb /dev/cuaU1 - ugen0.8: usb /dev/cuaU2 - ugen0.9: usb /dev/cuaU3 - ugen0.10: usb /dev/cuaU4 - ugen0.11: usb /dev/cuau0 - cuau0: uart Now lets take a look at two example descriptors: % usbconfig -d ugen0.7 dump_device_desc ugen0.7: at usbus0, cfg=3D0 md=3DHOST spd=3DFULL (12Mbps) pwr=3DON (100mA) bLength =3D 0x0012 bDescriptorType =3D 0x0001 bcdUSB =3D 0x0110 bDeviceClass =3D 0x0000 bDeviceSubClass =3D 0x0000 bDeviceProtocol =3D 0x0000 bMaxPacketSize0 =3D 0x0040 idVendor =3D 0x10c4 idProduct =3D 0xea60 bcdDevice =3D 0x0100 iManufacturer =3D 0x0001 iProduct =3D 0x0002 iSerialNumber =3D 0x0003 <0001> bNumConfigurations =3D 0x0001 % usbconfig -d ugen0.8 dump_device_desc ugen0.8: at usbus0, cfg=3D0 md=3DHOST spd=3DFULL (12Mbps) pwr=3DON (500mA) bLength =3D 0x0012 bDescriptorType =3D 0x0001 bcdUSB =3D 0x0200 bDeviceClass =3D 0x00ef bDeviceSubClass =3D 0x0002 bDeviceProtocol =3D 0x0001 bMaxPacketSize0 =3D 0x0040 idVendor =3D 0x303a idProduct =3D 0x1001 bcdDevice =3D 0x0101 iManufacturer =3D 0x0001 iProduct =3D 0x0002 iSerialNumber =3D 0x0003 <60:XX:F9:CC:XX:XX> bNumConfigurations =3D 0x0001 % usbconfig -d ugen0.9 dump_device_desc ugen0.9: at usbus0, cfg=3D0 md=3DHOST spd=3DFULL (12Mbps) pwr=3DON (300mA) bLength =3D 0x0012 bDescriptorType =3D 0x0001 bcdUSB =3D 0x0200 bDeviceClass =3D 0x00ef bDeviceSubClass =3D 0x0002 bDeviceProtocol =3D 0x0001 bMaxPacketSize0 =3D 0x0040 idVendor =3D 0x0483 idProduct =3D 0x374b bcdDevice =3D 0x0100 iManufacturer =3D 0x0001 iProduct =3D 0x0002 iSerialNumber =3D 0x0003 <0667XXXX49558575671XXXXX> bNumConfigurations =3D 0x0001 It would be amazingly useful to also have SerialNumber, VID/PID, Manufacturer + Product printed out in a single line delimeted for easy parse (maybe a table?), something like: /dev/cuaU0: ugen0.9, usb, tty?, 0667XXXX49558575671XXXXX, 0483:374b, STMicroelectronics STM32 STLink. We are building distributed build and testing farm for NuttX RTOS where different boards are attached over multiport USB HUB(s). Build will be repeated with different tools and commits in order to verify a firmware image build, then firmware will be flashed to a physical board in order to perform on-board runtime tests. Logs will be gathered and sent back to a server for analysis (PASS / FAIL + logs). This comes as complementary action to build only verification on GitHub and recent cuts in CI availability (we exceed CI quota by a lot with just standard PR verification). Plus we will have real world hardware runtime verification :-) Also we plan to use https://github.com/mvp/uhubctl for single USB HUB port control. I did not play with that guy yet, is supposed to work on FreeBSD, will have to add support for my i-Tec U3CHARGEHUB16. ugen device is nice to know, but it will change depending on what will be attached to what port, maybe even change in time as HUB ports are cycled, SN is better for target board/interface identification in scripting :-) Thank you :-) Tomek --=20 CeDeROM, SQ7MHZ, http://www.tomek.cedro.info