Re: [PATCH v2] tty: n_gsm: CR bit value should be 0 when config "initiator=0"

From: 赵振国
Date: Wed Jul 14 2021 - 22:30:07 EST


Dear Jiri,Greg

ngsm as responser,pls review the process again.
because according to this process, it can't work.

Thanks!

赵振国 <zhenguo6858@xxxxxxxxx> 于2021年7月7日周三 下午2:12写道:
>
> 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;