linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: 赵振国 <zhenguo6858@gmail.com>
To: 赵振国 <zhenguo6858@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"
Date: Wed, 7 Jul 2021 14:08:40 +0800	[thread overview]
Message-ID: <CAGGV+3L+VgU75kKt30EoThQ3yhyfFDhkEvoK9N-hAQrv8XxiUA@mail.gmail.com> (raw)
In-Reply-To: <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>

Dear Jiri,Greg

 1:   our development board uses linux kernel , uart dev node is "/dev/ttyGS2"
 2:   config uart "/dev/ttyGS2" ,we use ngsm ldisc,and config
"c.initiator = 0;" code is as follows

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

     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();

3:  connect to ubuntu by uart serial port cable,ubuntu uart dev node
is /"dev/ttyUSB0"
send  DLC0 SABM command by "/dev/ttyUSB0",but linux development board
can't response,code is as follows

int main(int argc, char **argv)
{
    int fd;
fd = open("/dev/ttyUSB0,O_RDWR | O_NOCTTY | O_NDELAY);
char buf[256]={0xf9,0x03,0x3f,0x01,0x1c,0xf9};
write(fd,buf,6);
close(fd);
}

4:  linux development board receive data,by uart,gsm_queue will check
CR,find CR=1.so go to invalid,pls check again.
static void gsm_queue(struct gsm_mux *gsm)
{
cr ^= 1 - gsm->initiator; /* Flip so 1 always means command */
dlci = gsm->dlci[address];

switch (gsm->control) {
case SABM|PF:
if (cr == 0)
goto invalid;
if (dlci == NULL)
dlci = gsm_dlci_alloc(gsm, address);
if (dlci == NULL)
return;
if (dlci->dead)
gsm_response(gsm, address, DM);
else {
gsm_response(gsm, address, UA);
gsm_dlci_open(dlci);
}
break;

  parent reply	other threads:[~2021-07-07  6:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 11:53 [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0" Zhenguo Zhao
2021-06-24 12:58 ` Greg KH
     [not found] ` <CAGGV+3LgLdohhYhH+qJTokeNU_WdV9oRNHMc9a_5YTTVA3U8ow@mail.gmail.com>
2021-07-07  6:08   ` 赵振国 [this message]
2021-07-07  6:10   ` Greg KH
2021-07-07  6:12 ` 赵振国
2021-07-15  2:29   ` 赵振国

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+3L+VgU75kKt30EoThQ3yhyfFDhkEvoK9N-hAQrv8XxiUA@mail.gmail.com \
    --to=zhenguo6858@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).