Bug 198019 - [PATCH]: FreeBSD 10.1 fix for comms/telldus-core
Summary: [PATCH]: FreeBSD 10.1 fix for comms/telldus-core
Status: Closed DUPLICATE of bug 222790
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
: 198026 (view as bug list)
Depends on:
Blocks: 198026
  Show dependency treegraph
 
Reported: 2015-02-24 22:42 UTC by Johan Ström
Modified: 2017-10-05 07:41 UTC (History)
4 users (show)

See Also:


Attachments
Patch to bring comms/telldus-core to 2.1.2_1 (6.07 KB, patch)
2015-02-24 22:42 UTC, Johan Ström
no flags Details | Diff
poudriere testport -j 101amd64 -o comms/telldus-core (73.22 KB, text/plain)
2015-02-24 22:44 UTC, Johan Ström
no flags Details
Fix for missing $ugen (514 bytes, patch)
2015-02-25 08:36 UTC, Hans Petter Selasky
no flags Details | Diff
Revised patch to bring comms/telldus-core to 2.1.2_1 (5.86 KB, patch)
2015-02-25 12:14 UTC, Johan Ström
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Ström 2015-02-24 22:42:23 UTC
Created attachment 153482 [details]
Patch to bring comms/telldus-core to 2.1.2_1

The attached patch fixes issues with telldus-core on FreeBSD 10.1, and a few other issues:
* improved devd-script
* Fixed permissions on /var/telldus/telldus-core.conf; use new @dir style
* portlint complaints

portlint output from patched port:

WARN: Makefile: possible use of absolute pathname "/var/telldus".
WARN: Makefile: for new port, make $FreeBSD$ tag in comment section empty, to make SVN happy.
WARN: Makefile: new ports should not set PORTREVISION.
0 fatal errors and 3 warnings found.
Comment 1 Johan Ström 2015-02-24 22:44:30 UTC
Created attachment 153484 [details]
poudriere testport -j 101amd64 -o comms/telldus-core

Added testport output for 10.1 AMD64
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-02-25 08:35:50 UTC
A commit references this bug:

Author: hselasky
Date: Wed Feb 25 08:35:01 UTC 2015
New revision: 279270
URL: https://svnweb.freebsd.org/changeset/base/279270

Log:
  Add ugen keyword to USB pnpinfo. Remove extra space from existing pnpinfo.

  PR:		198015
  PR:		198019
  PR:		198026
  MFC after:	1 week

Changes:
  head/sys/dev/usb/usb_hub.c
Comment 3 Hans Petter Selasky freebsd_committer freebsd_triage 2015-02-25 08:36:59 UTC
Created attachment 153511 [details]
Fix for missing $ugen

Please use /dev/$ugen . It will be upstream in not too long.
Comment 4 Hans Petter Selasky freebsd_committer freebsd_triage 2015-02-25 08:37:58 UTC
*** Bug 198026 has been marked as a duplicate of this bug. ***
Comment 5 Johan Ström 2015-02-25 08:44:14 UTC
Thanks for quick fixes!

When can one expect this to be in 10.1-RELEASE (or 9.3-RELEASE) as available via freebsd-update?

The original submitted patch contained this workaround (at least working on FreeBSD 10.1) until proper is usable:

action "dev=`usbconfig dump_device_desc | grep $sernum -B14|grep ugen|cut -f1 -d':'`; chgrp dialer /dev/$$dev; chmod 660 /dev/$$dev;
    ..."

Unless this can be in generic relatively soon, I'd prefer to have the above hack in the port to avoid breakage. Without the chown/chmod the port is unusable.
Comment 6 Hans Petter Selasky freebsd_committer freebsd_triage 2015-02-25 08:53:23 UTC
Hi,
If you know the vendor and product IDs, then you shouldn't match for uftdiX at all.

Use:

notify 50 {
       match "system"          "USB";
       match "subsystem"       "DEVICE";
       match "type"            "ATTACH";
       match "vendor"          "0x1781";
       match "product"         "0x0c30";
       action "chgrp dialer /dev/$cdev; chmod 660 /dev/$cdev";
};

--HPS
Comment 7 Johan Ström 2015-02-25 09:03:34 UTC
I'm actually already doing that. The full script looks like this:

attach 10 {
        device-name "uftdi[0-9]+";
        match "vendor" "0x1781";
        match "product" "0x0c30";


        # Devd variable $bus and $devaddr ought to be what we want to identify /dev/ugenN.N.
        # Unfortunately devd overwrites $bus:
        #       https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198015
        #
        # Use this workaround instead.. Find device by serial and use that device name. -B14 should be stable: 
        #       https://github.com/freebsd/freebsd/blob/master/usr.sbin/usbconfig/dump.c#L395
        #       https://github.com/freebsd/freebsd/blob/master/lib/libusb/libusb20_desc.h#L220
        #
        # $ usbconfig dump_device_desc | grep $sernum -B14|grep ugen
        # ugen0.2: <TellStick Telldus> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (90mA)
        #
        # Old command:
        # action "chgrp dialer /dev/ugen$bus.$devaddr; chmod 660 /dev/ugen$bus.$devaddr;
        action "dev=`usbconfig dump_device_desc | grep $sernum -B14|grep ugen|cut -f1 -d':'`; chgrp dialer /dev/$$dev; chmod 660 /dev/$$dev;
                /usr/local/sbin/tdadmin --pid $product --vid $vendor --serial $sernum controller connect";
};



There is no $cdev variable provided. The event processed (same as reported in ticket 198015):

Processing event '+uftdi0 at bus=0 hubaddr=1 port=3 devaddr=2 interface=0 vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXXXXX" release=0x0600 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff  ttyname=U0 ttyports=1 on uhub1'



Verified with:

action "echo cdev for $sernum is x $cdev x"

Output:
Executing 'echo cdev for XXXX is x  x'
cdev for XXXX is x x
Comment 8 Johan Ström 2015-02-25 09:12:45 UTC
Oh, my bad. Didn't notice USB/ATTACH event matching. 

And.. Doh.
I've been testing by doing "usbconfig -d... power_off ; ... power_on". When doing that, the USB INTERFACE ATTACH event was not sent, hence I missed it..


Looking closer, these events is what I get:

Processing event '!system=USB subsystem=INTERFACE type=ATTACH ugen=ugen0.2 cdev=ugen0.2 vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXXX" release=0x0600 mode=host interface=0 endpoints=2 intclass=0xff intsubclass=0xff intprotocol=0xff'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.2'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=ttyU0'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=ttyU0.init'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=ttyU0.lock'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=cuaU0.init'
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=cuaU0.lock'
Processing event '+uftdi0 at bus=0 hubaddr=1 port=3 devaddr=2 interface=0 vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXXX" release=0x0600 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff  ttyname=U0 ttyports=1 on uhub1'


Changing to your suggestion works perfect, thanks!

I'll update the patch accordingly.
Comment 9 Hans Petter Selasky freebsd_committer freebsd_triage 2015-02-25 09:16:57 UTC
You should see two events. One "INTERFACE" one and another "DEVICE" one. You should use the "DEVICE" one if the deamon should only attach once.

--HPS
Comment 10 Johan Ström 2015-02-25 09:18:49 UTC
Right, I have 

Processing event '!system=USB subsystem=INTERFACE type=ATTACH ugen=ugen0.2 cdev=ugen0.2 vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXX" release=0x0600 mode=host interface=0 endpoints=2 intclass=0xff intsubclass=0xff intprotocol=0xff'

and 

Processing event '!system=USB subsystem=DEVICE type=ATTACH ugen=ugen0.2 cdev=ugen0.2 vendor=0x1781 product=0x0c30 devclass=0x00 devsubclass=0x00 sernum="XXX" release=0x0600 mode=host port=3 parent=ugen0.1'

Will use DEVICE, as per your example. Sorry for the confusion.
Comment 11 Johan Ström 2015-02-25 12:14:43 UTC
Created attachment 153517 [details]
Revised patch to bring comms/telldus-core to 2.1.2_1

The port patch has now been updated to use a proper devd script, which now also supports the DETACH event properly.
Comment 12 Johan Ström 2015-02-25 12:16:39 UTC
Note that "Fix for missing $ugen (514 bytes, patch)" is obsolete with my latest port patch.
Comment 13 commit-hook freebsd_committer freebsd_triage 2015-03-05 09:32:39 UTC
A commit references this bug:

Author: hselasky
Date: Thu Mar  5 09:31:37 UTC 2015
New revision: 279636
URL: https://svnweb.freebsd.org/changeset/base/279636

Log:
  MFC r279270:
  Add ugen keyword to USB pnpinfo. Remove extra space from existing pnpinfo.

  PR:		198015
  PR:		198019
  PR:		198026

Changes:
_U  stable/10/
  stable/10/sys/dev/usb/usb_hub.c
Comment 14 commit-hook freebsd_committer freebsd_triage 2015-03-05 09:35:43 UTC
A commit references this bug:

Author: hselasky
Date: Thu Mar  5 09:35:16 UTC 2015
New revision: 279637
URL: https://svnweb.freebsd.org/changeset/base/279637

Log:
  MFC r279270:
  Add ugen keyword to USB pnpinfo. Remove extra space from existing pnpinfo.

  PR:		198015
  PR:		198019
  PR:		198026

Changes:
_U  stable/9/sys/
_U  stable/9/sys/dev/
  stable/9/sys/dev/usb/usb_hub.c
Comment 15 commit-hook freebsd_committer freebsd_triage 2015-03-05 09:37:48 UTC
A commit references this bug:

Author: hselasky
Date: Thu Mar  5 09:37:28 UTC 2015
New revision: 279638
URL: https://svnweb.freebsd.org/changeset/base/279638

Log:
  MFC r279270:
  Add ugen keyword to USB pnpinfo. Remove extra space from existing pnpinfo.

  PR:		198015
  PR:		198019
  PR:		198026

Changes:
_U  stable/8/sys/
_U  stable/8/sys/dev/
_U  stable/8/sys/dev/usb/
  stable/8/sys/dev/usb/usb_hub.c
Comment 16 Bartek Rutkowski freebsd_committer freebsd_triage 2015-03-29 11:28:01 UTC
The fix has been already committed, so I am closing this PR.
Comment 17 Johan Ström 2015-03-29 14:46:11 UTC
Hi,

this issue is not resolved.

The original patch supplied here was not the one mentioned in the commit comments, those commit referred to another issue which parts of my original patches worked around.

As evident by the repo (https://github.com/freebsd/freebsd-ports/tree/master/comms/telldus-core)
the patch "Revised patch to bring comms/telldus-core to 2.1.2_1" is not applied.

(Also, repeating so it does not get lost: Note that "Fix for missing $ugen (514 bytes, patch)" is obsolete with my latest port patch.)

Thanks
Comment 18 Martin Wilke freebsd_committer freebsd_triage 2017-03-04 14:37:48 UTC
Hi,

Is this PR still relevant?
Comment 19 Johan Ström 2017-03-04 14:58:08 UTC
It's still relevant, the improved devd-script was never commited to ports.

If the now 2 year old patch still applies cleanly, can't really say.. For me personally, stuff works fine on 10.3 at least.
Comment 20 Martin Wilke freebsd_committer freebsd_triage 2017-03-04 14:59:59 UTC
Hi Johan,

Thanks for your feedback, I'll keep it open.
Comment 21 Hans Petter Selasky freebsd_committer freebsd_triage 2017-03-04 15:10:06 UTC
This patch looks good to me.

--HPS
Comment 22 Johan Ström 2017-10-05 07:41:38 UTC
New refreshed patch in 222790

*** This bug has been marked as a duplicate of bug 222790 ***