From 72b2811532f0fe2ce9a2325cd0c105de00e2bef3 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 16 Jul 2015 10:52:28 +0545 Subject: Make serial ports glob cope with many more possibilities It originally coped with things like cuau1 cuau1.1 Then I made it cope with things like cuau1 cuau11 but it stopped working for cuau1.1 This one copes with: cuau1 cuau1.1 cuau1.11 cuau11 cuau11.1 cuau11.11 That should allow for all sorts of reasonable device name files without matching other stuff in /dev (like cuau1.init cuau1.lock) that we need to ignore. Please think if I have covered the bases here. --- usr/local/www/interfaces_ppps_edit.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/interfaces_ppps_edit.php b/usr/local/www/interfaces_ppps_edit.php index 44d44a0..7781025 100644 --- a/usr/local/www/interfaces_ppps_edit.php +++ b/usr/local/www/interfaces_ppps_edit.php @@ -493,9 +493,9 @@ $types = array("select" => gettext("Select"), "ppp" => "PPP", "pppoe" => "PPPoE" // Match files in /dev starting with "cua" then: // ? = any single character e.g. like "cuau" // [0-9] = a digit from 0 to 9 - // {,[0-9]} = nothing (the empty before the comma) or a digit from 0 to 9 - // This supports up to 100 devices (0 to 99), e.g. cuau0 cuau1 ... cuau10 cuau11 ... cuau99 - $serialports = glob("/dev/cua?[0-9]{,[0-9]}", GLOB_BRACE); + // stuff in {} = the various possible digit and dot combinations to allow an optional 2nd digit, dot, followed by 1 or 2 optional digits + // This supports up to 100 devices (0 to 99), e.g. cuau0 cuau1 ... cuau10 cuau11 ... cuau99 and also possibilities like cuau1.1 cuau1.11 cuau11.1 cuau11.11 + $serialports = glob("/dev/cua?[0-9]{,.[0-9],.[0-9][0-9],[0-9],[0-9].[0-9],[0-9].[0-9][0-9]}", GLOB_BRACE); $serport_count = 0; foreach ($serialports as $port) { $serport_count++; -- cgit v1.1 From 8235e7304e97a750e1a48926c69e65b4836cbffa Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 16 Jul 2015 21:35:51 +0545 Subject: Restrict serial ports glob to cua followed by alpha Improve this a little more to match only alpha after /dev/cua (/dev/cuau for example) --- usr/local/www/interfaces_ppps_edit.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/interfaces_ppps_edit.php b/usr/local/www/interfaces_ppps_edit.php index 7781025..2a7eaf9 100644 --- a/usr/local/www/interfaces_ppps_edit.php +++ b/usr/local/www/interfaces_ppps_edit.php @@ -491,11 +491,11 @@ $types = array("select" => gettext("Select"), "ppp" => "PPP", "pppoe" => "PPPoE" } // $serialports = pfSense_get_modem_devices(); // Match files in /dev starting with "cua" then: - // ? = any single character e.g. like "cuau" + // [a-zA-Z] = any single alpha character e.g. like "cuau" // [0-9] = a digit from 0 to 9 // stuff in {} = the various possible digit and dot combinations to allow an optional 2nd digit, dot, followed by 1 or 2 optional digits - // This supports up to 100 devices (0 to 99), e.g. cuau0 cuau1 ... cuau10 cuau11 ... cuau99 and also possibilities like cuau1.1 cuau1.11 cuau11.1 cuau11.11 - $serialports = glob("/dev/cua?[0-9]{,.[0-9],.[0-9][0-9],[0-9],[0-9].[0-9],[0-9].[0-9][0-9]}", GLOB_BRACE); + // This supports up to 100 device numbers (0 to 99), e.g. cuau0 cuau1 ... cuau10 cuau11 ... cuau99 and also possibilities like cuau1.1 cuau1.11 cuau11.1 cuau11.11 + $serialports = glob("/dev/cua[a-zA-Z][0-9]{,.[0-9],.[0-9][0-9],[0-9],[0-9].[0-9],[0-9].[0-9][0-9]}", GLOB_BRACE); $serport_count = 0; foreach ($serialports as $port) { $serport_count++; -- cgit v1.1