Re: [PATCH] serial: allow specifying baudrate to use via udev tags

2017-03-22 Thread Aleksander Morgado
Hey Jan,

See comments inline below.

>
> When you are saying not to mix e-mail threads you mean not to reply all? I am 
> only replying to e-mails which are related to my problem.

It's ok to reply-all; but we're now talking in an email thread about
the ID_MM_TTY_BAUDRATE related patch, which you didn't even test :)
The original thread you opened had subject "Could not acquire the
'org.freedesktop.ModemManager1' service name"; and things have evolved
from that original issue to the fact that the TTY isn't correctly
probed, and now we're talking in the email thread about a patch I sent
last week which is already merged in git master; a bit of a mess! ;)

BTW, now that we're into mailing list etiquette, top-posting is also
not a good way to write to the mailing list, see:
http://www.idallen.com/topposting.html

These two previous things are so that everything is kept tidy for
everyone to easily follow; not everyone is interested in every topic
posted here. :)

> I have done mmcli -S and that command response with "successfully requested 
> to scan devices". Here is the output from ModemManager debug session:
>
> ModemManager[1532]:  [1490186663.752548] [mm-plugin.c:767] 
> mm_plugin_supports_port(): (Generic) [ttymxc2] probe required: 'at, qcdm'
> ModemManager[1532]:  [1490186663.752733] [mm-port-probe.c:1353] 
> mm_port_probe_run(): (tty/ttymxc2) launching port probing: 'qcdm'
> ModemManager[1532]:  [1490186663.752965] [mm-port-probe.c:658] 
> serial_probe_qcdm(): (tty/ttymxc2) probing QCDM...
> ModemManager[1532]:  [1490186663.753384] [mm-port-serial.c:1099] 
> mm_port_serial_open(): (ttymxc2) opening serial port...
> ModemManager[1532]:  [1490186663.755754] [mm-port-serial.c:1237] 
> mm_port_serial_open(): (ttymxc2) device open count is 1 (open)
> ModemManager[1532]:  [1490186663.756270] [mm-port-serial-qcdm.c:201] 
> debug_log(): (ttymxc2): --> 7e 00 78 f0 7e
> ModemManager[1532]:  [149018.742982] [mm-port-serial-qcdm.c:201] 
> debug_log(): (ttymxc2): --> 7e 00 78 f0 7e
> ModemManager[1532]:  [1490186669.743253] [mm-port-probe.c:258] 
> mm_port_probe_set_result_qcdm(): (tty/ttymxc2) port is not QCDM-capable
> ModemManager[1532]:  [1490186669.746282] [mm-port-serial.c:1296] 
> mm_port_serial_close(): (ttymxc2) device open count is 0 (close)
> ModemManager[1532]:  [1490186669.748909] [mm-port-serial.c:1312] 
> mm_port_serial_close(): (ttymxc2) closing serial port...
> ModemManager[1532]:  [1490186669.759468] [mm-port-serial.c:1361] 
> mm_port_serial_close(): (ttymxc2) serial port closed
> ModemManager[1532]:  [1490186669.759689] [mm-port-serial.c:1415] 
> port_serial_close_force(): (ttymxc2) forced to close port
> ModemManager[1532]:  [1490186669.760001] [mm-plugin-manager.c:462] 
> plugin_supports_port_ready(): (Plugin Manager) (Generic) [ttymxc2] found best 
> plugin for port
> ModemManager[1532]:  [1490186669.760300] [mm-plugin-manager.c:316] 
> port_probe_context_finished(): (Plugin Manager) 'ttymxc2' port probe 
> finished, last one in device
> ModemManager[1532]:  [1490186669.760459] [mm-plugin-manager.c:138] 
> find_device_support_context_complete_and_free(): (Plugin Manager) 
> [/sys/devices/soc0/soc/210.aips-bus/21ec000.serial] device support check 
> finished in '15.800204' seconds
> ModemManager[1532]:   [1490186669.760657] [mm-device.c:509] 
> mm_device_create_modem(): Creating modem with plugin 'Generic' and '1' ports
> ModemManager[1532]:   [1490186669.773671] [mm-plugin.c:905] 
> mm_plugin_create_modem(): Could not grab port (tty/ttymxc2): 'Cannot add port 
> 'tty/ttymxc2', unhandled serial type'
> ModemManager[1532]:  [1490186669.774134] [mm-base-modem.c:1485] 
> finalize(): Modem (Generic) 
> '/sys/devices/soc0/soc/210.aips-bus/21ec000.serial' completely disposed
> ModemManager[1532]:   [1490186669.774314] [mm-base-manager.c:158] 
> find_device_support_ready(): Couldn't create modem for device at 
> '/sys/devices/soc0/soc/210.aips-bus/21ec000.serial': Failed to find 
> primary AT port
>
> It looks like the ttymxc2 modem port is not QCDM-capable. Is there anything I 
> can do to make it QCDM-capable? The ModemManager software version running on 
> my development board is 1.4.0. Does this make difference?
>

I'm not sure why it didn't re-probe "AT" in the TTY... Please test
"mmcli -S" using ModemManager git master, because a recent patch there
allowed to fully re-probe ports that were not acquired by any modem,
as in your case.

-- 
Aleksander
https://aleksander.es
___
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel


RE: [PATCH] serial: allow specifying baudrate to use via udev tags

2017-03-22 Thread Jan Graczyk
Hello Aleksander,

When you are saying not to mix e-mail threads you mean not to reply all? I am 
only replying to e-mails which are related to my problem. I have done mmcli -S 
and that command response with "successfully requested to scan devices". Here 
is the output from ModemManager debug session:

ModemManager[1532]:  [1490186663.752548] [mm-plugin.c:767] 
mm_plugin_supports_port(): (Generic) [ttymxc2] probe required: 'at, qcdm'
ModemManager[1532]:  [1490186663.752733] [mm-port-probe.c:1353] 
mm_port_probe_run(): (tty/ttymxc2) launching port probing: 'qcdm'
ModemManager[1532]:  [1490186663.752965] [mm-port-probe.c:658] 
serial_probe_qcdm(): (tty/ttymxc2) probing QCDM...
ModemManager[1532]:  [1490186663.753384] [mm-port-serial.c:1099] 
mm_port_serial_open(): (ttymxc2) opening serial port...
ModemManager[1532]:  [1490186663.755754] [mm-port-serial.c:1237] 
mm_port_serial_open(): (ttymxc2) device open count is 1 (open)
ModemManager[1532]:  [1490186663.756270] [mm-port-serial-qcdm.c:201] 
debug_log(): (ttymxc2): --> 7e 00 78 f0 7e
ModemManager[1532]:  [149018.742982] [mm-port-serial-qcdm.c:201] 
debug_log(): (ttymxc2): --> 7e 00 78 f0 7e
ModemManager[1532]:  [1490186669.743253] [mm-port-probe.c:258] 
mm_port_probe_set_result_qcdm(): (tty/ttymxc2) port is not QCDM-capable
ModemManager[1532]:  [1490186669.746282] [mm-port-serial.c:1296] 
mm_port_serial_close(): (ttymxc2) device open count is 0 (close)
ModemManager[1532]:  [1490186669.748909] [mm-port-serial.c:1312] 
mm_port_serial_close(): (ttymxc2) closing serial port...
ModemManager[1532]:  [1490186669.759468] [mm-port-serial.c:1361] 
mm_port_serial_close(): (ttymxc2) serial port closed
ModemManager[1532]:  [1490186669.759689] [mm-port-serial.c:1415] 
port_serial_close_force(): (ttymxc2) forced to close port
ModemManager[1532]:  [1490186669.760001] [mm-plugin-manager.c:462] 
plugin_supports_port_ready(): (Plugin Manager) (Generic) [ttymxc2] found best 
plugin for port
ModemManager[1532]:  [1490186669.760300] [mm-plugin-manager.c:316] 
port_probe_context_finished(): (Plugin Manager) 'ttymxc2' port probe finished, 
last one in device
ModemManager[1532]:  [1490186669.760459] [mm-plugin-manager.c:138] 
find_device_support_context_complete_and_free(): (Plugin Manager) 
[/sys/devices/soc0/soc/210.aips-bus/21ec000.serial] device support check 
finished in '15.800204' seconds
ModemManager[1532]:   [1490186669.760657] [mm-device.c:509] 
mm_device_create_modem(): Creating modem with plugin 'Generic' and '1' ports
ModemManager[1532]:   [1490186669.773671] [mm-plugin.c:905] 
mm_plugin_create_modem(): Could not grab port (tty/ttymxc2): 'Cannot add port 
'tty/ttymxc2', unhandled serial type'
ModemManager[1532]:  [1490186669.774134] [mm-base-modem.c:1485] 
finalize(): Modem (Generic) 
'/sys/devices/soc0/soc/210.aips-bus/21ec000.serial' completely disposed
ModemManager[1532]:   [1490186669.774314] [mm-base-manager.c:158] 
find_device_support_ready(): Couldn't create modem for device at 
'/sys/devices/soc0/soc/210.aips-bus/21ec000.serial': Failed to find primary 
AT port

It looks like the ttymxc2 modem port is not QCDM-capable. Is there anything I 
can do to make it QCDM-capable? The ModemManager software version running on my 
development board is 1.4.0. Does this make difference?

Best Regards,
Jan Graczyk

This email message may contain confidential and privileged information.  Any 
unauthorized use is prohibited.  If you are not the intended recipient, please 
contact the sender by reply email and destroy all copies of the original 
message.


-Original Message-
From: Aleksander Morgado [mailto:aleksan...@aleksander.es] 
Sent: Wednesday, March 22, 2017 1:39 AM
To: Jan Graczyk <j...@nytec.com>
Cc: Dan Williams <d...@redhat.com>; modemmanager-devel@lists.freedesktop.org
Subject: Re: [PATCH] serial: allow specifying baudrate to use via udev tags

Hey Jan,

On Tue, Mar 21, 2017 at 11:16 PM, Jan Graczyk <j...@nytec.com> wrote:
> I have tried running ModemManager with /dev/ttymxc2 port set to 57600 baud 
> rate. It looks like as I can see from ModemManager debug logging the QUECTEL 
> UC20 device is not recognized. I have looked into the ModemManager supported 
> devices website 
> https://www.freedesktop.org/wiki/Software/ModemManager/SupportedDevices/#index2h1
>  and there is no support for this device. I would need to create a new plugin 
> for this device.

Maybe, or maybe not.

The first step is to have the TTY recognized by ModemManager. If it is an AT 
port, ModemManager should be able to do basic AT probing there and fallback to 
the "generic" plugin if it doesn't find any specific plugin.

If baudrate is already 57600bps in the modem, and still isn't recognized, it 
has to be due to some other reason. Try maybe to run "mmcli -S" after some 
time, so that a manual re-scan is relaunched (but use ModemManager git master 
to do so, or it may really not work as I

RE: [PATCH] serial: allow specifying baudrate to use via udev tags

2017-03-21 Thread Jan Graczyk
Hello Dan,

I have tried running ModemManager with /dev/ttymxc2 port set to 57600 baud 
rate. It looks like as I can see from ModemManager debug logging the QUECTEL 
UC20 device is not recognized. I have looked into the ModemManager supported 
devices website 
https://www.freedesktop.org/wiki/Software/ModemManager/SupportedDevices/#index2h1
 and there is no support for this device. I would need to create a new plugin 
for this device.

Best Regards,
Jan Graczyk


This email message may contain confidential and privileged information.  Any 
unauthorized use is prohibited.  If you are not the intended recipient, please 
contact the sender by reply email and destroy all copies of the original 
message.


-Original Message-
From: ModemManager-devel 
[mailto:modemmanager-devel-boun...@lists.freedesktop.org] On Behalf Of Dan 
Williams
Sent: Tuesday, March 21, 2017 2:09 PM
To: Aleksander Morgado <aleksan...@aleksander.es>
Cc: modemmanager-devel@lists.freedesktop.org
Subject: Re: [PATCH] serial: allow specifying baudrate to use via udev tags

On Sat, 2017-03-11 at 13:15 +0100, Aleksander Morgado wrote:
> A new 'ID_MM_TTY_BAUDRATE' per-port udev tag is introduced, which 
> allows specifying the baudrate that will be used when opening a 
> specific serial port.
> 
> E.g.:
> 
> ACTION!="add|change|move", GOTO="mm_my_modem_end"
> DEVPATH=="/devices/pci:00/:00:1d.0/usb1/1-1/1-1.3/*",
> ENV{ID_MM_TTY_BAUDRATE}="115200"
> LABEL="mm_my_modem_end"
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=100158

LGTM.

Dan

> ---
> 
> Hey,
> 
> How about this patch? It really is a nice thing to have when 
> integrating non-USB RS232 modems, as we avoid requiring to stick to 
> 57600bps when the device can work perfectly with a much higher 
> baudrate.
> 
> ---
>  src/mm-base-modem.c  |   6 +++
>  src/mm-port-probe.c  |  10 +
>  src/mm-port-serial.c | 118 ++---
> --
>  3 files changed, 39 insertions(+), 95 deletions(-)
> 
> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index 
> 50717471..430ce59d 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -219,6 +219,12 @@ mm_base_modem_grab_port (MMBaseModem 
> *self,
>    "timed-out",
>    G_CALLBACK (serial_port_timed_out_cb),
>    self);
> +
> +/* For serial ports, optionally use a specific baudrate */
> +if (mm_kernel_device_has_property (kernel_device,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (port,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (kernel_device, 
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
>  }
>  /* Net ports... */
>  else if (g_str_equal (subsys, "net")) { diff --git 
> a/src/mm-port-probe.c b/src/mm-port-probe.c index f5dc90d2..c6c5897f 
> 100644
> --- a/src/mm-port-probe.c
> +++ b/src/mm-port-probe.c
> @@ -712,6 +712,11 @@ serial_probe_qcdm (MMPortProbe *self)
>  return G_SOURCE_REMOVE;
>  }
> 
> +if (mm_kernel_device_has_property (self->priv->port,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (ctx->serial,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (self->priv->port, 
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
> +
>  /* Try to open the port */
>  if (!mm_port_serial_open (ctx->serial, )) {
>  port_probe_task_return_error (self, @@ -1220,6 +1225,11 @@ 
> serial_open_at (MMPortProbe *self)
>    MM_PORT_SERIAL_AT_SEND_LF, ctx-
> >at_send_lf,
>    NULL);
> 
> +if (mm_kernel_device_has_property (self->priv->port,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (ctx->serial,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (self->priv->port, 
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
> +
>  parser = mm_serial_parser_v1_new ();
>  mm_serial_parser_v1_add_filter (parser,
>  serial_parser_filter_cb, diff 
> --git a/src/mm-port-serial.c b/src/mm-port-serial.c index 
> 470de031..2b6b92d3 100644
> --- a/src/mm-port-serial.c
> +++ b/src/mm-port-serial.c
> @@ -210,95 +210,13 @@ mm_port_serial_command (MMPortSerial *self,
> 
>  /***
> **/
> 
> -#if 0
> -static const char *
> -baud_to_string (int baud)
> -{
&g

Re: [PATCH] serial: allow specifying baudrate to use via udev tags

2017-03-21 Thread Dan Williams
On Sat, 2017-03-11 at 13:15 +0100, Aleksander Morgado wrote:
> A new 'ID_MM_TTY_BAUDRATE' per-port udev tag is introduced, which
> allows specifying the baudrate that will be used when opening a
> specific serial port.
> 
> E.g.:
> 
> ACTION!="add|change|move", GOTO="mm_my_modem_end"
> DEVPATH=="/devices/pci:00/:00:1d.0/usb1/1-1/1-1.3/*",
> ENV{ID_MM_TTY_BAUDRATE}="115200"
> LABEL="mm_my_modem_end"
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=100158

LGTM.

Dan

> ---
> 
> Hey,
> 
> How about this patch? It really is a nice thing to have when
> integrating non-USB RS232 modems, as we avoid requiring to stick to
> 57600bps when the device can work perfectly with a much higher
> baudrate.
> 
> ---
>  src/mm-base-modem.c  |   6 +++
>  src/mm-port-probe.c  |  10 +
>  src/mm-port-serial.c | 118 ++---
> --
>  3 files changed, 39 insertions(+), 95 deletions(-)
> 
> diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
> index 50717471..430ce59d 100644
> --- a/src/mm-base-modem.c
> +++ b/src/mm-base-modem.c
> @@ -219,6 +219,12 @@ mm_base_modem_grab_port
> (MMBaseModem *self,
>    "timed-out",
>    G_CALLBACK (serial_port_timed_out_cb),
>    self);
> +
> +/* For serial ports, optionally use a specific baudrate */
> +if (mm_kernel_device_has_property (kernel_device,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (port,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (kernel_device,
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
>  }
>  /* Net ports... */
>  else if (g_str_equal (subsys, "net")) {
> diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
> index f5dc90d2..c6c5897f 100644
> --- a/src/mm-port-probe.c
> +++ b/src/mm-port-probe.c
> @@ -712,6 +712,11 @@ serial_probe_qcdm (MMPortProbe *self)
>  return G_SOURCE_REMOVE;
>  }
> 
> +if (mm_kernel_device_has_property (self->priv->port,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (ctx->serial,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (self->priv->port,
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
> +
>  /* Try to open the port */
>  if (!mm_port_serial_open (ctx->serial, )) {
>  port_probe_task_return_error (self,
> @@ -1220,6 +1225,11 @@ serial_open_at (MMPortProbe *self)
>    MM_PORT_SERIAL_AT_SEND_LF, ctx-
> >at_send_lf,
>    NULL);
> 
> +if (mm_kernel_device_has_property (self->priv->port,
> "ID_MM_TTY_BAUDRATE"))
> +g_object_set (ctx->serial,
> +  MM_PORT_SERIAL_BAUD,
> mm_kernel_device_get_property_as_int (self->priv->port,
> "ID_MM_TTY_BAUDRATE"),
> +  NULL);
> +
>  parser = mm_serial_parser_v1_new ();
>  mm_serial_parser_v1_add_filter (parser,
>  serial_parser_filter_cb,
> diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
> index 470de031..2b6b92d3 100644
> --- a/src/mm-port-serial.c
> +++ b/src/mm-port-serial.c
> @@ -210,95 +210,13 @@ mm_port_serial_command (MMPortSerial *self,
> 
>  /***
> **/
> 
> -#if 0
> -static const char *
> -baud_to_string (int baud)
> -{
> -const char *speed = NULL;
> -
> -switch (baud) {
> -case B0:
> -speed = "0";
> -break;
> -case B50:
> -speed = "50";
> -break;
> -case B75:
> -speed = "75";
> -break;
> -case B110:
> -speed = "110";
> -break;
> -case B150:
> -speed = "150";
> -break;
> -case B300:
> -speed = "300";
> -break;
> -case B600:
> -speed = "600";
> -break;
> -case B1200:
> -speed = "1200";
> -break;
> -case B2400:
> -speed = "2400";
> -break;
> -case B4800:
> -speed = "4800";
> -break;
> -case B9600:
> -speed = "9600";
> -break;
> -case B19200:
> -speed = "19200";
> -break;
> -case B38400:
> -speed = "38400";
> -break;
> -case B57600:
> -speed = "57600";
> -break;
> -case B115200:
> -speed = "115200";
> -break;
> -case B460800:
> -speed = "460800";
> -break;
> -default:
> -break;
> -}
> -
> -return speed;
> -}
> -
> -void
> -mm_port_serial_print_config (MMPortSerial *port,
> - const char *detail)
> -{
> -struct termios stbuf;
> -int err;
> -
> -err = tcgetattr (self->priv->fd, );
> -if (err) {
> -mm_warn ("*** %s (%s): (%s) tcgetattr() error %d",
> - __func__, detail, mm_port_get_device (MM_PORT
> (port)), errno);
> -return;
> -