tty: n_gsm: CR bit value should be 0 when config "initiator=0"
PATCH v2 1/1 tty: n_gsm: CR bit value should be 0 when config "initiator=0"
From: Zhenguo Zhao <[email protected]>
config "initiator=0",gsmld will receives dlci SABM/DISC control command frame,as slaver,the CR bit value check should be 1.
if check "cr == 0",it will goto invalid,so it can't send UA response frame and open slaver dlci.
--- drivers/tty/n_gsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/n_gsm.c +2 -2
@@ -1779,7 +1779,7 @@ static void gsm_queue(struct gsm_mux *gsm)switch (gsm->control) {case SABM |PF : -if (cr ==0 ) +if (cr ==1 ) goto invalid;if (dlci ==NULL ) dlci =gsm_dlci_alloc (gsm, address);
@@ -1793,7 +1793,7 @@ static void gsm_queue(struct gsm_mux *gsm) }break ;case DISC |PF : -if (cr ==0 ) +if (cr ==1 ) goto invalid;if (dlci ==NULL || dlci->state ==DLCI_CLOSED ) {gsm_response (gsm, address,DM );
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 4 lines · Zhenguo Zhao
From: Zhenguo Zhao <[email protected]>
config "initiator=0",gsmld will receives dlci SABM/DISC control command frame,as slaver,the CR bit value check should be 1.
I am really sorry, but I do not understand this changelog comment. Can you try rewriting it again?
Quoted 3 lines
if check "cr == 0",it will goto invalid,so it can't send UA response frame and open slaver dlci.
Same here, I do not understand.
thanks,
greg k-h
A message that is not in the archive (sent off-list or not yet received): 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;
Greg KH
maintainerQuoted 1 line · 赵振国
Dear Jiri,Greg
<snip>
still html :(
Please fix your email client, there are instructions on how to do that in the Documentation/ directory.
greg k-h
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;
Dear Jiri,Greg
ngsm as responser,pls review the process again.
because according to this process, it can't work.
Thanks!
Quoted 81 lines · 赵振国 <[email protected]> 于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/ttyGS2int 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 followsint
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 voidgsm_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;