[PATCH v2 03/13] ublox: define port type hints for the TOBY-L4
Aleksander Morgado
aleksander at aleksander.es
Fri Sep 15 05:00:59 UTC 2017
The TOBY-L4 exposes multiple TTY ports, but each of them has different
purposes:
The TTY at interface #2 is a fully capable AT port but shouldn't be
used to start connections, so we flag it as secondary.
The TTY at interface #4 is a non-AT debug port, so we explicitly
ignore it to make probing faster.
The TTY at interface #6 is the fully capable AT port that must be used
as primary port.
The TTY at interface #8 is an AT-capable port but dedicated to FOTA
update operations.
---
plugins/Makefile.am | 2 ++
plugins/ublox/77-mm-ublox-port-types.rules | 20 ++++++++++++++++++++
plugins/ublox/mm-plugin-ublox.c | 29 +++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 plugins/ublox/77-mm-ublox-port-types.rules
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d3575522..98a95f53 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -899,6 +899,8 @@ test_udev_rules_LDADD = \
# plugin: u-blox
################################################################################
+dist_udevrules_DATA += ublox/77-mm-ublox-port-types.rules
+
PLUGIN_UBLOX_COMPILER_FLAGS = \
-I$(top_srcdir)/plugins/ublox \
-I$(top_builddir)/plugins/ublox \
diff --git a/plugins/ublox/77-mm-ublox-port-types.rules b/plugins/ublox/77-mm-ublox-port-types.rules
new file mode 100644
index 00000000..0c5b0961
--- /dev/null
+++ b/plugins/ublox/77-mm-ublox-port-types.rules
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+ACTION!="add|change|move", GOTO="mm_ublox_port_types_end"
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="1546", GOTO="mm_ublox_port_types"
+GOTO="mm_ublox_port_types_end"
+
+LABEL="mm_ublox_port_types"
+
+SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
+
+# Toby-L4 port types
+# ttyACM0 (if #2): secondary
+# ttyACM1 (if #4): debug port (ignore)
+# ttyACM2 (if #6): primary
+# ttyACM3 (if #8): AT port for FOTA (ignore)
+ATTRS{idVendor}=="1546", ATTRS{idProduct}=="1010", ENV{.MM_USBIFNUM}=="02", ENV{ID_MM_UBLOX_SECONDARY_PORT}="1"
+ATTRS{idVendor}=="1546", ATTRS{idProduct}=="1010", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
+ATTRS{idVendor}=="1546", ATTRS{idProduct}=="1010", ENV{.MM_USBIFNUM}=="06", ENV{ID_MM_UBLOX_PRIMARY_PORT}="1"
+ATTRS{idVendor}=="1546", ATTRS{idProduct}=="1010", ENV{.MM_USBIFNUM}=="08", ENV{ID_MM_PORT_IGNORE}="1"
+
+LABEL="mm_ublox_port_types_end"
\ No newline at end of file
diff --git a/plugins/ublox/mm-plugin-ublox.c b/plugins/ublox/mm-plugin-ublox.c
index 6ebd8711..13d95816 100644
--- a/plugins/ublox/mm-plugin-ublox.c
+++ b/plugins/ublox/mm-plugin-ublox.c
@@ -59,6 +59,34 @@ create_modem (MMPlugin *self,
product));
}
+static gboolean
+grab_port (MMPlugin *self,
+ MMBaseModem *modem,
+ MMPortProbe *probe,
+ GError **error)
+{
+ MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
+ MMKernelDevice *port;
+ MMPortType port_type;
+
+ port_type = mm_port_probe_get_port_type (probe);
+ port = mm_port_probe_peek_port (probe);
+
+ if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_UBLOX_PRIMARY_PORT")) {
+ mm_dbg ("(%s/%s)' port flagged as primary",
+ mm_port_probe_get_port_subsys (probe),
+ mm_port_probe_get_port_name (probe));
+ pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
+ } else if (mm_kernel_device_get_property_as_boolean (port, "ID_MM_UBLOX_SECONDARY_PORT")) {
+ mm_dbg ("(%s/%s) port flagged as secondary",
+ mm_port_probe_get_port_subsys (probe),
+ mm_port_probe_get_port_name (probe));
+ pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
+ }
+
+ return mm_base_modem_grab_port (modem, port, port_type, pflags, error);
+}
+
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
@@ -90,4 +118,5 @@ mm_plugin_ublox_class_init (MMPluginUbloxClass *klass)
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
+ plugin_class->grab_port = grab_port;
}
--
2.14.1
More information about the ModemManager-devel
mailing list