* Pavel Machek <pavel@???> [200429 21:34]:
> Hi!
>
> > * Pavel Machek <pavel@???> [200425 18:34]:
> > > Hmm, I like motmdm* interface. I'd suggest we keep it.
> > >
> > > > Based on comments from Johan, we want to keep the /dev/gsmmux* support
> > > > as is for serdev users too. Presumably most serdev-ngsm users would
> > > > not need any custom handling, and only we are really stuck with the
> > > > custom packet IDs AFAIK.
> > >
> > > ? I'm not sure I understand this or its implications.
> >
> > Well if we can use /dev/gsmmux* interface directly, we save about
> > 300 lines of kernel code that does not really help us because it
> > still does not make the modem AT compatible.
>
> True. But you still need that code for /dev/gnss0 and for the mixers,
> right?
Nope. I think the only part remaining to sort out for the kernel
driver is the notifications for voice to deal with the audio
mixer. The gnss and audio drivers won't need that. Well I've so
far confirmed only with the gnss driver. And I still have few bugs
remainging before I can post an updated kernel driver series.
> And using motmdm* manually is possible, why doing the same with
> gsmmux* will be more tricky.
Yes but not by much compared to how much extra complexity we
avoid on the kernel. For reference, below is my quick fix for
the droid4-agps.c I've been using for testing.
And we can always do a channel specific kernel driver spinning up
the chardev interface if really needed.
> > Earlier I was thinking we may not want to use /dev/gsmmux* at all
> > with serdev drivers. But it's already there and working, using it
> > leaves out a bunch of code compared to maintaining the additional
> > chardev support.
>
> > > > For sending continuation messages, they start with just "U" with no
> > > > packet ID. And for the packet ID, we can just use something similar
> > > > to what kernel is using with jiffies % 10000.
> > >
> > > But yes, this should be doable, too.
> >
> > OK. So let's try to first figure out a way for ofono raw read/write
> > functions using the current /dev/motmdm* interface. Then after that
> > works, let's try to flip over to using /dev/gsmmux* interface. I need
> > to update the kernel patches for that too for a generic serdev-ngsm.
>
> I'm not saying this is impossible. ofono accesses qmi, and writing raw
> data into device files is not exactly a rocket science. But it might
> be a bit of work...
Yeah OK, you'd assume it's doable in ofono.. And I think there too
we don't need to care about out-of-order command responses to keep
things simple.
Regards,
Tony
8< -------------------
diff --git a/droid4-agps.c b/droid4-agps.c
--- a/droid4-agps.c
+++ b/droid4-agps.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include <sys/ioctl.h>
@@ -30,11 +31,18 @@ static int download_almanac(const char **file)
static int motmdm_send_command(int dlci, const char *fmt, const char *cmd,
const char *expect)
{
+ char mcmd[BUF_SIZE];
char resp[BUF_SIZE];
char dbg[BUF_SIZE + 3];
struct timespec ts;
struct pollfd pfd;
+ unsigned int id;
int error;
+ char *c;
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+ id = (ts.tv_sec % 100) * 100;
+ id += (ts.tv_nsec / 1000000) / 10;
ts.tv_sec = 3;
ts.tv_nsec = 0;
@@ -42,14 +50,19 @@ static int motmdm_send_command(int dlci, const char *fmt, const char *cmd,
pfd.events = POLLIN;
pfd.revents = 0;
+ memset(mcmd, 0, BUF_SIZE);
+ c = mcmd;
+ c += sprintf(c, "U%04u", id);
+ c += sprintf(c, fmt, cmd);
+
if (debug) {
memset(dbg, 0, BUF_SIZE);
sprintf(dbg, "> ");
- sprintf(dbg + 2, fmt, cmd);
+ sprintf(dbg + 2, mcmd);
printf("%s\n", dbg);
}
- error = dprintf(dlci, fmt, cmd);
+ error = dprintf(dlci, mcmd);
if (error < 0)
return error;
@@ -79,7 +92,7 @@ static int motmdm_send_command(int dlci, const char *fmt, const char *cmd,
printf("%s\n", dbg);
}
- if (strncmp(expect, resp, strlen(expect)))
+ if (strncmp(expect, resp + 5, strlen(expect)))
return -EIO;
return 0;
@@ -112,7 +125,7 @@ static void motmdm_kick_hung(int dlci)
*/
static int motmdm_add_almanac(const char *file)
{
- const char *channel = "/dev/motmdm6";
+ const char *channel = "/dev/gsmtty6";
unsigned char buf[MOTMDM_MAX_BYTES];
char cmd[MOTMDM_MAX_CMDLEN];
int error, dlci, data, i;