All of lore.kernel.org
 help / color / mirror / Atom feed
From: 赵振国 <zhenguo6858@gmail.com>
To: Jiri Slaby <jirislaby@kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: n_gsm: Fix CR bit value when initiator=0
Date: Wed, 16 Jun 2021 16:01:05 +0800	[thread overview]
Message-ID: <CAGGV+3LhweM+=42yG3N4mSuDfbJY7xsJ0PgBNFP2HPtcskDHyg@mail.gmail.com> (raw)
In-Reply-To: <e4511265-485c-915c-4567-930b658f7c0e@kernel.org>

Dear gregkh,Jiri

I think that linux ngsm is cp cmux function  (config
slaver,c.initiator = 0),pc side or ubuntu or terminal will send
"AT+CMUX" by tty dev, and send SABM.DISC.CLD command。

because project is YOCTO,YOCTO  is IOT open project,need config
slaver,after config “c.initiator = 0”,ngsm can‘t work normally.


slaver config ,it doesn't need to send "AT+CMUX"
----------------------------------------------------------
2.1 switch the serial line to using the n_gsm line discipline by using
    TIOCSETD ioctl.
2.2 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
2.3 obtain base gsmtty number for the used serial port,

  #include <stdio.h>
  #include <stdint.h>
  #include <linux/gsmmux.h>
  #include <linux/tty.h>
  #define DEFAULT_SPEED B115200
  #define SERIAL_PORT   /dev/ttyS0

    int ldisc = N_GSM0710;
    struct gsm_config c;
    struct termios configuration;
    uint32_t first;

    /* open the serial port */
    fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);

    /* configure the serial port : speed, flow control ... */

    /* use n_gsm line discipline */
    ioctl(fd, TIOCSETD, &ldisc);

    /* get n_gsm configuration */
    ioctl(fd, GSMIOC_GETCONF, &c);
    /* we are responter and need encoding 0 (basic) */
    c.initiator = 0;
    c.encapsulation = 0;
    /* our modem defaults to a maximum size of 127 bytes */
    c.mru = 127;
    c.mtu = 127;
    /* set the new configuration */
    ioctl(fd, GSMIOC_SETCONF, &c);
    /* get first gsmtty device node */
    ioctl(fd, GSMIOC_GETFIRST, &first);
    printf("first muxed line: /dev/gsmtty%i\n", first);

    /* and wait for ever to keep the line discipline enabled */
    daemon(0,0);
    pause();


2021-06-16 15:45 GMT+08:00, Jiri Slaby <jirislaby@kernel.org>:
> On 16. 06. 21, 9:39, Greg KH wrote:
>>
>> A: http://en.wikipedia.org/wiki/Top_post
>> Q: Were do I find info about this thing called top-posting?
>> A: Because it messes up the order in which people normally read text.
>> Q: Why is top-posting such a bad thing?
>> A: Top-posting.
>> Q: What is the most annoying thing in e-mail?
>>
>> A: No.
>> Q: Should I include quotations after my reply?
>>
>> http://daringfireball.net/2007/07/on_top
>>
>> On Wed, Jun 16, 2021 at 03:29:11PM +0800, 赵振国 wrote:
>>> Dear gregkh
>>>
>>> 1:  Documentation/driver-api/serial/n_gsm.rst
>>>
>>> The text introduces the config of master ( c.initiator = 1), but the
>>> config of as responder is different.
>>> when set gsm->initiator=0 by GSMIOC_SETCONF ,ngsm driver should be
>>> responder(slaver)
>>>
>>> config:
>>> 	c.initiator = 0;    // set initiator=0,ngsm as responder
>>> 	ioctl(fd, GSMIOC_SETCONF, &c);
>>>
>>> 2:  if master side send SABM/DISC frame data by uart dev
>>>      DLC0 control data frame:f9 03 3f 01 1c f9
>>>      kernel log: gsmld_receive: 00000000: f9 03 3f 01 1c f9
>>>
>>> {
>>> 	cr = gsm->address & 1;		/* C/R bit */
>>> //CR value=1
>>>
>>> 	gsm_print_packet("<--", address, cr, gsm->control, gsm->buf, gsm->len);
>>>
>>> 	cr ^= 1 - gsm->initiator;	/* Flip so 1 always means command */
>>> //when gsm->initiator is 0, CR value=0 by "^=" calculation
>>> 	dlci = gsm->dlci[address];
>>>
>>> 	switch (gsm->control) {
>>> 	case SABM|PF:
>>> 		if (cr == 0)
>>> 			goto invalid;                       //if CR value=0,ngsm will goto
>>> invalid,but the dlc0 control frame data is right,if we can't modify
>>> ,ngsm can't send UA response data
>>> }
>>
>> I am sorry, but I really do not understand what you are saying here.
>> Please resubmit your patch with an updated changelog that explains why
>> this change is needed and what it does.
>
> And why it was able to work until now. I.e. isn't the Documentation wrong?
>
> thanks,
> --
> js
> suse labs
>

      reply	other threads:[~2021-06-16  8:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  2:56 [PATCH] tty: n_gsm: Fix CR bit value when initiator=0 Zhenguo Zhao
2021-06-16  6:19 ` Greg KH
2021-06-16  7:29   ` 赵振国
2021-06-16  7:39     ` Greg KH
2021-06-16  7:45       ` Jiri Slaby
2021-06-16  8:01         ` 赵振国 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGGV+3LhweM+=42yG3N4mSuDfbJY7xsJ0PgBNFP2HPtcskDHyg@mail.gmail.com' \
    --to=zhenguo6858@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.