Udev rule to match multiple node USB device












6














I have a 3G/GPS device that creates 5 tty nodes, although it's only one physical USB connection. Basically, a multi port usb-serial adapter.



I'm trying to create some udev rules to make sure those nodes always have the same name, or at least a symlink to them.



I can indeed find the device at /sys/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/. Inside are 1-2.2:1.0/ to 1-2.2:1.4/, for the 5 nodes it creates.



I can also find it at /sys/bus/usb/devices/1-2.2 .



The udev info for the device is as follows:



udevadm info -a -p /sys/bus/usb/devices/1-2.2/1-2.2:1.0
looking at device '/bus/usb/devices/1-2.2/1-2.2:1.0':
KERNEL=="1-2.2:1.0"
SUBSYSTEM=="usb"
DRIVER=="option"
ATTR{bInterfaceNumber}=="00"
ATTR{bAlternateSetting}==" 0"
ATTR{bNumEndpoints}=="03"
ATTR{bInterfaceClass}=="ff"
ATTR{bInterfaceSubClass}=="01"
ATTR{bInterfaceProtocol}=="01"
ATTR{modalias}=="usb:v12D1p1506d0000dc00dsc00dp00icFFisc01ip01"
ATTR{supports_autosuspend}=="0"


From this point on, all the nodes have the same info. And the only thing varying between nodes is the bInterfaceNumber property, and the device path. So, I thought of writing a rule by dev path.



Now, for some reason, the following rule gets matched by all those nodes.



ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0" SYMLINK+="huawey0"


So basically, huawey0 points to the last node enumerated. The device created nodes from ttyUSB2 to 6, and this link points to USB6.



So, I tried by kernel node:



ACTION=="add", KERNEL=="1-2.2:1.0" SYMLINK+="huawey0"


Now, nothing appears on /dev.



After this, I tried using the bInterfaceNumber to separate them. I used the following rule



ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]" ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


And still, nothing happens. I even tried a trimmed down version of the rule..



ACTION=="add", ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


And still nothing happens. Why is it not matching?










share|improve this question





























    6














    I have a 3G/GPS device that creates 5 tty nodes, although it's only one physical USB connection. Basically, a multi port usb-serial adapter.



    I'm trying to create some udev rules to make sure those nodes always have the same name, or at least a symlink to them.



    I can indeed find the device at /sys/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/. Inside are 1-2.2:1.0/ to 1-2.2:1.4/, for the 5 nodes it creates.



    I can also find it at /sys/bus/usb/devices/1-2.2 .



    The udev info for the device is as follows:



    udevadm info -a -p /sys/bus/usb/devices/1-2.2/1-2.2:1.0
    looking at device '/bus/usb/devices/1-2.2/1-2.2:1.0':
    KERNEL=="1-2.2:1.0"
    SUBSYSTEM=="usb"
    DRIVER=="option"
    ATTR{bInterfaceNumber}=="00"
    ATTR{bAlternateSetting}==" 0"
    ATTR{bNumEndpoints}=="03"
    ATTR{bInterfaceClass}=="ff"
    ATTR{bInterfaceSubClass}=="01"
    ATTR{bInterfaceProtocol}=="01"
    ATTR{modalias}=="usb:v12D1p1506d0000dc00dsc00dp00icFFisc01ip01"
    ATTR{supports_autosuspend}=="0"


    From this point on, all the nodes have the same info. And the only thing varying between nodes is the bInterfaceNumber property, and the device path. So, I thought of writing a rule by dev path.



    Now, for some reason, the following rule gets matched by all those nodes.



    ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0" SYMLINK+="huawey0"


    So basically, huawey0 points to the last node enumerated. The device created nodes from ttyUSB2 to 6, and this link points to USB6.



    So, I tried by kernel node:



    ACTION=="add", KERNEL=="1-2.2:1.0" SYMLINK+="huawey0"


    Now, nothing appears on /dev.



    After this, I tried using the bInterfaceNumber to separate them. I used the following rule



    ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]" ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


    And still, nothing happens. I even tried a trimmed down version of the rule..



    ACTION=="add", ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


    And still nothing happens. Why is it not matching?










    share|improve this question



























      6












      6








      6


      2





      I have a 3G/GPS device that creates 5 tty nodes, although it's only one physical USB connection. Basically, a multi port usb-serial adapter.



      I'm trying to create some udev rules to make sure those nodes always have the same name, or at least a symlink to them.



      I can indeed find the device at /sys/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/. Inside are 1-2.2:1.0/ to 1-2.2:1.4/, for the 5 nodes it creates.



      I can also find it at /sys/bus/usb/devices/1-2.2 .



      The udev info for the device is as follows:



      udevadm info -a -p /sys/bus/usb/devices/1-2.2/1-2.2:1.0
      looking at device '/bus/usb/devices/1-2.2/1-2.2:1.0':
      KERNEL=="1-2.2:1.0"
      SUBSYSTEM=="usb"
      DRIVER=="option"
      ATTR{bInterfaceNumber}=="00"
      ATTR{bAlternateSetting}==" 0"
      ATTR{bNumEndpoints}=="03"
      ATTR{bInterfaceClass}=="ff"
      ATTR{bInterfaceSubClass}=="01"
      ATTR{bInterfaceProtocol}=="01"
      ATTR{modalias}=="usb:v12D1p1506d0000dc00dsc00dp00icFFisc01ip01"
      ATTR{supports_autosuspend}=="0"


      From this point on, all the nodes have the same info. And the only thing varying between nodes is the bInterfaceNumber property, and the device path. So, I thought of writing a rule by dev path.



      Now, for some reason, the following rule gets matched by all those nodes.



      ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0" SYMLINK+="huawey0"


      So basically, huawey0 points to the last node enumerated. The device created nodes from ttyUSB2 to 6, and this link points to USB6.



      So, I tried by kernel node:



      ACTION=="add", KERNEL=="1-2.2:1.0" SYMLINK+="huawey0"


      Now, nothing appears on /dev.



      After this, I tried using the bInterfaceNumber to separate them. I used the following rule



      ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]" ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


      And still, nothing happens. I even tried a trimmed down version of the rule..



      ACTION=="add", ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


      And still nothing happens. Why is it not matching?










      share|improve this question















      I have a 3G/GPS device that creates 5 tty nodes, although it's only one physical USB connection. Basically, a multi port usb-serial adapter.



      I'm trying to create some udev rules to make sure those nodes always have the same name, or at least a symlink to them.



      I can indeed find the device at /sys/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/. Inside are 1-2.2:1.0/ to 1-2.2:1.4/, for the 5 nodes it creates.



      I can also find it at /sys/bus/usb/devices/1-2.2 .



      The udev info for the device is as follows:



      udevadm info -a -p /sys/bus/usb/devices/1-2.2/1-2.2:1.0
      looking at device '/bus/usb/devices/1-2.2/1-2.2:1.0':
      KERNEL=="1-2.2:1.0"
      SUBSYSTEM=="usb"
      DRIVER=="option"
      ATTR{bInterfaceNumber}=="00"
      ATTR{bAlternateSetting}==" 0"
      ATTR{bNumEndpoints}=="03"
      ATTR{bInterfaceClass}=="ff"
      ATTR{bInterfaceSubClass}=="01"
      ATTR{bInterfaceProtocol}=="01"
      ATTR{modalias}=="usb:v12D1p1506d0000dc00dsc00dp00icFFisc01ip01"
      ATTR{supports_autosuspend}=="0"


      From this point on, all the nodes have the same info. And the only thing varying between nodes is the bInterfaceNumber property, and the device path. So, I thought of writing a rule by dev path.



      Now, for some reason, the following rule gets matched by all those nodes.



      ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0" SYMLINK+="huawey0"


      So basically, huawey0 points to the last node enumerated. The device created nodes from ttyUSB2 to 6, and this link points to USB6.



      So, I tried by kernel node:



      ACTION=="add", KERNEL=="1-2.2:1.0" SYMLINK+="huawey0"


      Now, nothing appears on /dev.



      After this, I tried using the bInterfaceNumber to separate them. I used the following rule



      ACTION=="add", DEV="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]" ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


      And still, nothing happens. I even tried a trimmed down version of the rule..



      ACTION=="add", ATTR{bInterfaceNumber}=="00" SYMLINK+="huawey0"


      And still nothing happens. Why is it not matching?







      linux devices udev






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 21 '14 at 8:46









      erch

      1,995113461




      1,995113461










      asked Aug 14 '13 at 16:03









      Joao Pincho

      17818




      17818






















          4 Answers
          4






          active

          oldest

          votes


















          4














          Your rules all have syntax errors in them:





          1. = is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.

          2. You need , between all the statements, there were none before SYMLINK+=.


          Fist Rule



          ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0", SYMLINK+="huawey0"


          Second Rule



          ACTION=="add", KERNEL=="1-2.2:1.0", SYMLINK+="huawey0"


          Third Rule



          ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


          Fourth Rule



          ACTION=="add", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


          All these rules should do what you want now (I would use the first one personally).






          share|improve this answer





























            2














            Although this post was asked three years ago, and this might not address the answer, I still want to share my successful experience here for the future reference.



            According to Jens Reimann's Identify GSM modem devices using udev, "the device attribute “bInterfaceNumber” is not on the tty device, but on the usb device in the parent hierarchy", so I created two rules for my FTDI usb-to-4-port-serial adapter:



            SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"

            SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", SYMLINK+="ttyUSB_FTDI_4_PORT_%E{.LOCAL_ifNum}"



            This stores the attribute “bInterfaceNumber” into the environment variable “.LOCAL_ifNum” (the prefixed dot is a notation for temporary or hidden variables). In the second rule the same variable is pulled on using the “%E” syntax. Newer udev versions also support “$env” instead of “%E”.

            (by Jens Reimann)




            where ttyUSB_FTDI_4_PORT_ is the symlink name. 
            These two rules will create symlinks as ttyUSB_FTDI_4_PORT_00, ttyUSB_FTDI_4_PORT_01, ttyUSB_FTDI_4_PORT_02, ttyUSB_FTDI_4_PORT_03
            You can add ATTRS{serial} attribute to constrain the enumeration further.



            Jens Reimann also acknowlegfed the contribution of Ketan Patel's U&L question, Udev rule file for modem not working, with accepted answer by derobert.






            share|improve this answer































              0














              In addition to Alex's comments, there is another issue. It seems ATTR{bInterfaceNumber} doesn't work for some reason. To quote the answer to a related question, you should use something along the lines of



              SUBSYSTEM=="tty", ACTION=="add", 
              ENV{ID_VENDOR_ID}=="067b", ENV{ID_MODEL_ID}="2303",
              ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="test_USB0"





              share|improve this answer































                0














                I try to add ATTRS{serial} attribute to constrain the enumeration,
                like,



                SUBSYSTEMS=="usb", ENV{.Interface_Num}="$attr{bInterfaceNumber}" 
                SUBSYSTEMS=="usb", ENV{.Serial}="$attr{serial}"
                SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", SYMLINK+="ttyUSB_Lidar00$env{.Serial}_$env{.Interface_Num}"


                but I fail.






                share|improve this answer








                New contributor




                黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.


















                  Your Answer








                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "106"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86728%2fudev-rule-to-match-multiple-node-usb-device%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  4














                  Your rules all have syntax errors in them:





                  1. = is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.

                  2. You need , between all the statements, there were none before SYMLINK+=.


                  Fist Rule



                  ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0", SYMLINK+="huawey0"


                  Second Rule



                  ACTION=="add", KERNEL=="1-2.2:1.0", SYMLINK+="huawey0"


                  Third Rule



                  ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                  Fourth Rule



                  ACTION=="add", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                  All these rules should do what you want now (I would use the first one personally).






                  share|improve this answer


























                    4














                    Your rules all have syntax errors in them:





                    1. = is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.

                    2. You need , between all the statements, there were none before SYMLINK+=.


                    Fist Rule



                    ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0", SYMLINK+="huawey0"


                    Second Rule



                    ACTION=="add", KERNEL=="1-2.2:1.0", SYMLINK+="huawey0"


                    Third Rule



                    ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                    Fourth Rule



                    ACTION=="add", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                    All these rules should do what you want now (I would use the first one personally).






                    share|improve this answer
























                      4












                      4








                      4






                      Your rules all have syntax errors in them:





                      1. = is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.

                      2. You need , between all the statements, there were none before SYMLINK+=.


                      Fist Rule



                      ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0", SYMLINK+="huawey0"


                      Second Rule



                      ACTION=="add", KERNEL=="1-2.2:1.0", SYMLINK+="huawey0"


                      Third Rule



                      ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                      Fourth Rule



                      ACTION=="add", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                      All these rules should do what you want now (I would use the first one personally).






                      share|improve this answer












                      Your rules all have syntax errors in them:





                      1. = is for assignment == is for comparison, so you were not actually looking at what DEV equaled, you were assigning it.

                      2. You need , between all the statements, there were none before SYMLINK+=.


                      Fist Rule



                      ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.0", SYMLINK+="huawey0"


                      Second Rule



                      ACTION=="add", KERNEL=="1-2.2:1.0", SYMLINK+="huawey0"


                      Third Rule



                      ACTION=="add", DEV=="/devices/platform/pxa27x-ohci/usb1/1-2/1-2.2/1-2.2:1.[0-4]", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                      Fourth Rule



                      ACTION=="add", ATTR{bInterfaceNumber}=="00", SYMLINK+="huawey0"


                      All these rules should do what you want now (I would use the first one personally).







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Sep 1 '13 at 4:00









                      Alex Layton

                      1616




                      1616

























                          2














                          Although this post was asked three years ago, and this might not address the answer, I still want to share my successful experience here for the future reference.



                          According to Jens Reimann's Identify GSM modem devices using udev, "the device attribute “bInterfaceNumber” is not on the tty device, but on the usb device in the parent hierarchy", so I created two rules for my FTDI usb-to-4-port-serial adapter:



                          SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"

                          SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", SYMLINK+="ttyUSB_FTDI_4_PORT_%E{.LOCAL_ifNum}"



                          This stores the attribute “bInterfaceNumber” into the environment variable “.LOCAL_ifNum” (the prefixed dot is a notation for temporary or hidden variables). In the second rule the same variable is pulled on using the “%E” syntax. Newer udev versions also support “$env” instead of “%E”.

                          (by Jens Reimann)




                          where ttyUSB_FTDI_4_PORT_ is the symlink name. 
                          These two rules will create symlinks as ttyUSB_FTDI_4_PORT_00, ttyUSB_FTDI_4_PORT_01, ttyUSB_FTDI_4_PORT_02, ttyUSB_FTDI_4_PORT_03
                          You can add ATTRS{serial} attribute to constrain the enumeration further.



                          Jens Reimann also acknowlegfed the contribution of Ketan Patel's U&L question, Udev rule file for modem not working, with accepted answer by derobert.






                          share|improve this answer




























                            2














                            Although this post was asked three years ago, and this might not address the answer, I still want to share my successful experience here for the future reference.



                            According to Jens Reimann's Identify GSM modem devices using udev, "the device attribute “bInterfaceNumber” is not on the tty device, but on the usb device in the parent hierarchy", so I created two rules for my FTDI usb-to-4-port-serial adapter:



                            SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"

                            SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", SYMLINK+="ttyUSB_FTDI_4_PORT_%E{.LOCAL_ifNum}"



                            This stores the attribute “bInterfaceNumber” into the environment variable “.LOCAL_ifNum” (the prefixed dot is a notation for temporary or hidden variables). In the second rule the same variable is pulled on using the “%E” syntax. Newer udev versions also support “$env” instead of “%E”.

                            (by Jens Reimann)




                            where ttyUSB_FTDI_4_PORT_ is the symlink name. 
                            These two rules will create symlinks as ttyUSB_FTDI_4_PORT_00, ttyUSB_FTDI_4_PORT_01, ttyUSB_FTDI_4_PORT_02, ttyUSB_FTDI_4_PORT_03
                            You can add ATTRS{serial} attribute to constrain the enumeration further.



                            Jens Reimann also acknowlegfed the contribution of Ketan Patel's U&L question, Udev rule file for modem not working, with accepted answer by derobert.






                            share|improve this answer


























                              2












                              2








                              2






                              Although this post was asked three years ago, and this might not address the answer, I still want to share my successful experience here for the future reference.



                              According to Jens Reimann's Identify GSM modem devices using udev, "the device attribute “bInterfaceNumber” is not on the tty device, but on the usb device in the parent hierarchy", so I created two rules for my FTDI usb-to-4-port-serial adapter:



                              SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"

                              SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", SYMLINK+="ttyUSB_FTDI_4_PORT_%E{.LOCAL_ifNum}"



                              This stores the attribute “bInterfaceNumber” into the environment variable “.LOCAL_ifNum” (the prefixed dot is a notation for temporary or hidden variables). In the second rule the same variable is pulled on using the “%E” syntax. Newer udev versions also support “$env” instead of “%E”.

                              (by Jens Reimann)




                              where ttyUSB_FTDI_4_PORT_ is the symlink name. 
                              These two rules will create symlinks as ttyUSB_FTDI_4_PORT_00, ttyUSB_FTDI_4_PORT_01, ttyUSB_FTDI_4_PORT_02, ttyUSB_FTDI_4_PORT_03
                              You can add ATTRS{serial} attribute to constrain the enumeration further.



                              Jens Reimann also acknowlegfed the contribution of Ketan Patel's U&L question, Udev rule file for modem not working, with accepted answer by derobert.






                              share|improve this answer














                              Although this post was asked three years ago, and this might not address the answer, I still want to share my successful experience here for the future reference.



                              According to Jens Reimann's Identify GSM modem devices using udev, "the device attribute “bInterfaceNumber” is not on the tty device, but on the usb device in the parent hierarchy", so I created two rules for my FTDI usb-to-4-port-serial adapter:



                              SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"

                              SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", SYMLINK+="ttyUSB_FTDI_4_PORT_%E{.LOCAL_ifNum}"



                              This stores the attribute “bInterfaceNumber” into the environment variable “.LOCAL_ifNum” (the prefixed dot is a notation for temporary or hidden variables). In the second rule the same variable is pulled on using the “%E” syntax. Newer udev versions also support “$env” instead of “%E”.

                              (by Jens Reimann)




                              where ttyUSB_FTDI_4_PORT_ is the symlink name. 
                              These two rules will create symlinks as ttyUSB_FTDI_4_PORT_00, ttyUSB_FTDI_4_PORT_01, ttyUSB_FTDI_4_PORT_02, ttyUSB_FTDI_4_PORT_03
                              You can add ATTRS{serial} attribute to constrain the enumeration further.



                              Jens Reimann also acknowlegfed the contribution of Ketan Patel's U&L question, Udev rule file for modem not working, with accepted answer by derobert.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jun 25 '17 at 8:59









                              G-Man

                              12.9k93264




                              12.9k93264










                              answered Jun 25 '17 at 2:34









                              Roice

                              211




                              211























                                  0














                                  In addition to Alex's comments, there is another issue. It seems ATTR{bInterfaceNumber} doesn't work for some reason. To quote the answer to a related question, you should use something along the lines of



                                  SUBSYSTEM=="tty", ACTION=="add", 
                                  ENV{ID_VENDOR_ID}=="067b", ENV{ID_MODEL_ID}="2303",
                                  ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="test_USB0"





                                  share|improve this answer




























                                    0














                                    In addition to Alex's comments, there is another issue. It seems ATTR{bInterfaceNumber} doesn't work for some reason. To quote the answer to a related question, you should use something along the lines of



                                    SUBSYSTEM=="tty", ACTION=="add", 
                                    ENV{ID_VENDOR_ID}=="067b", ENV{ID_MODEL_ID}="2303",
                                    ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="test_USB0"





                                    share|improve this answer


























                                      0












                                      0








                                      0






                                      In addition to Alex's comments, there is another issue. It seems ATTR{bInterfaceNumber} doesn't work for some reason. To quote the answer to a related question, you should use something along the lines of



                                      SUBSYSTEM=="tty", ACTION=="add", 
                                      ENV{ID_VENDOR_ID}=="067b", ENV{ID_MODEL_ID}="2303",
                                      ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="test_USB0"





                                      share|improve this answer














                                      In addition to Alex's comments, there is another issue. It seems ATTR{bInterfaceNumber} doesn't work for some reason. To quote the answer to a related question, you should use something along the lines of



                                      SUBSYSTEM=="tty", ACTION=="add", 
                                      ENV{ID_VENDOR_ID}=="067b", ENV{ID_MODEL_ID}="2303",
                                      ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="test_USB0"






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 23 '17 at 12:40









                                      Community

                                      1




                                      1










                                      answered Sep 21 '15 at 5:24









                                      Dan Stahlke

                                      1011




                                      1011























                                          0














                                          I try to add ATTRS{serial} attribute to constrain the enumeration,
                                          like,



                                          SUBSYSTEMS=="usb", ENV{.Interface_Num}="$attr{bInterfaceNumber}" 
                                          SUBSYSTEMS=="usb", ENV{.Serial}="$attr{serial}"
                                          SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", SYMLINK+="ttyUSB_Lidar00$env{.Serial}_$env{.Interface_Num}"


                                          but I fail.






                                          share|improve this answer








                                          New contributor




                                          黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                          Check out our Code of Conduct.























                                            0














                                            I try to add ATTRS{serial} attribute to constrain the enumeration,
                                            like,



                                            SUBSYSTEMS=="usb", ENV{.Interface_Num}="$attr{bInterfaceNumber}" 
                                            SUBSYSTEMS=="usb", ENV{.Serial}="$attr{serial}"
                                            SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", SYMLINK+="ttyUSB_Lidar00$env{.Serial}_$env{.Interface_Num}"


                                            but I fail.






                                            share|improve this answer








                                            New contributor




                                            黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                            Check out our Code of Conduct.





















                                              0












                                              0








                                              0






                                              I try to add ATTRS{serial} attribute to constrain the enumeration,
                                              like,



                                              SUBSYSTEMS=="usb", ENV{.Interface_Num}="$attr{bInterfaceNumber}" 
                                              SUBSYSTEMS=="usb", ENV{.Serial}="$attr{serial}"
                                              SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", SYMLINK+="ttyUSB_Lidar00$env{.Serial}_$env{.Interface_Num}"


                                              but I fail.






                                              share|improve this answer








                                              New contributor




                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.









                                              I try to add ATTRS{serial} attribute to constrain the enumeration,
                                              like,



                                              SUBSYSTEMS=="usb", ENV{.Interface_Num}="$attr{bInterfaceNumber}" 
                                              SUBSYSTEMS=="usb", ENV{.Serial}="$attr{serial}"
                                              SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea70", SYMLINK+="ttyUSB_Lidar00$env{.Serial}_$env{.Interface_Num}"


                                              but I fail.







                                              share|improve this answer








                                              New contributor




                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.









                                              share|improve this answer



                                              share|improve this answer






                                              New contributor




                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.









                                              answered 10 mins ago









                                              黄绵光

                                              1




                                              1




                                              New contributor




                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.





                                              New contributor





                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.






                                              黄绵光 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.





                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                  Please pay close attention to the following guidance:


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f86728%2fudev-rule-to-match-multiple-node-usb-device%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  サソリ

                                                  広島県道265号伴広島線

                                                  Setup Asymptote in Texstudio