From owner-freebsd-usb@freebsd.org Wed Sep 2 08:22:21 2020 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 742F73D099C for ; Wed, 2 Sep 2020 08:22:21 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BhH3x1wdXz4Qnf for ; Wed, 2 Sep 2020 08:22:21 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: by mailman.nyi.freebsd.org (Postfix) id 3F2763D0764; Wed, 2 Sep 2020 08:22:21 +0000 (UTC) Delivered-To: usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3EE543D0B03 for ; Wed, 2 Sep 2020 08:22:21 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router10G.digiware.nl (smtp.digiware.nl [176.74.240.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BhH3w5Csqz4R3Z; Wed, 2 Sep 2020 08:22:20 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router10g.digiware.nl (localhost.digiware.nl [127.0.0.1]) by router10G.digiware.nl (Postfix) with ESMTP id C9DA76A50F; Wed, 2 Sep 2020 10:22:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at digiware.com Received: from router10G.digiware.nl ([127.0.0.1]) by router10g.digiware.nl (router10g.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wEzOYD1snCWA; Wed, 2 Sep 2020 10:22:15 +0200 (CEST) Received: from [192.168.10.9] (vaio [192.168.10.9]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by router10G.digiware.nl (Postfix) with ESMTPSA id D77546A50E; Wed, 2 Sep 2020 10:22:15 +0200 (CEST) Subject: Re: USB-dongle modem keeps changing from cuaU0 to cuaU1 and bck To: Ian Lepore , Hans Petter Selasky , usb@freebsd.org References: <8ffb4077-b0cb-ed0c-bd86-9fa164ae140d@digiware.nl> <4007b388-4f62-bcfc-1003-0ad2f079c1d4@selasky.org> <5a58c96d-81f5-cb7d-16c5-c28250aeed7f@digiware.nl> <16a7523227a32a4551f4459c06101f1ca0206e9b.camel@freebsd.org> From: Willem Jan Withagen Message-ID: Date: Wed, 2 Sep 2020 10:22:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <16a7523227a32a4551f4459c06101f1ca0206e9b.camel@freebsd.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-Rspamd-Queue-Id: 4BhH3w5Csqz4R3Z X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; ASN(0.00)[asn:28878, ipnet:176.74.224.0/19, country:NL]; REPLY(-4.00)[] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2020 08:22:21 -0000 On 1-9-2020 17:04, Ian Lepore wrote: > On Tue, 2020-09-01 at 16:23 +0200, Willem Jan Withagen wrote: >> On 1-9-2020 16:10, Hans Petter Selasky wrote: >>> On 2020-09-01 15:54, Willem Jan Withagen wrote: >>>> Could it be because the dongle itself crashes? >>> Yes, if they reboot or there are disturbances on the USB cables, then >>> a new index number may be assigned during re-enumeration. >> There is no hub or something in between, and it is directly connected. >> So I'm guessing that the modem resets/reboots. >> >> Let's see if devd can help. >> >> It does not happen very often, but now already twice on a day that it >> should have worked. >> 8-( >> > A typical scenario when this problem happens is: > > - cuaU0 is opened by an app. > - Something Happens(tm) to make the device disconnect from the bus, > but cuaU0 is still open by the app so the devfs node remains. > - The transient problems clears, the bus is re-enumerated, but since > cuaU0 is still in use by the app, cuaU1 gets assigned. > - Eventually the app tries to read from cuaU0 and gets an error > return from the read and closes the device, freeing cuaU0 in devfs. > > If you use devd rules to assign a particular alias based on the > device's serial number or bus:hub:port tuples, the same underlying > problem is going to be there: the app may still have the old device > open and hasn't yet noticed that it has disappeared. If the way the > alias is assigned is to create a symlink, and that's done using ln -fs > then it may work out. But there may be some need to have the devd rule > signal or kill/restart your app that's doing the monitoring. Thanx for the full explanation of the cause. Nice suggestion to use in devd. The problem is also in the smsd application.... You can specify several ports to start a sub process on. But if after a while that process cannot open a port and get the modem initialized, it terminates. So it will not see a modem appearing on the new/changed port. The process that caught the correct port at start, will try about 10 times when the modem has gone, and then  close/open the port again to see if anything is out there. So creating a alias filename that is stable, and fixes the underlying redirection will also work. Restarting the daemon will work if all possible port gets a configuration, the process will stick onto the available port. --WjW