[OpenWrt-Devel] [PATCH] Comgt: Add option to ignore ioctl errors
John Crispin
blogic at openwrt.org
Thu Jan 8 15:30:07 EST 2015
On 29/12/2014 17:54, Matti Laakso wrote:
> Some Huawei mobile broadband sticks utilizing the NCM protocol expose
> the control channel as a cdc-wdm device node instead of a virtual serial
> port. This device node does not support the serial port ioctls. Add command
> line option to not check whether ioctls are successful so that AT commands
> can also be sent to these devices.
>
can you instead of calling the ioctl and then ignoring the error change
it to not call the ioctls if the device is not a tty ?
> Signed-off-by: Matti Laakso <malaakso at elisanet.fi>
> ---
> .../utils/comgt/patches/004-add_force_option.patch | 66 ++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
> create mode 100644 package/network/utils/comgt/patches/004-add_force_option.patch
>
> diff --git a/package/network/utils/comgt/patches/004-add_force_option.patch b/package/network/utils/comgt/patches/004-add_force_option.patch
> new file mode 100644
> index 0000000..1690e5c
> --- /dev/null
> +++ b/package/network/utils/comgt/patches/004-add_force_option.patch
> @@ -0,0 +1,66 @@
> +--- a/comgt.c
> ++++ b/comgt.c
> +@@ -91,6 +91,7 @@ unsigned long hstart,hset;
> + char NullString[]={ "" };
> + BOOL lastcharnl=1; /* Indicate that last char printed from getonebyte
> + was a nl, so no new one is needed */
> ++BOOL force=0;
> +
> +
> + //"open com \"/dev/modem\"\nset com 38400n81\nset senddelay 0.05\nsend \"ATi^m\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response :\",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\n\n";
> +@@ -920,7 +921,7 @@ BOOL getonoroff(void) {
> + void setcom(void) {
> + stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
> + stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
> +- if (ioctl(comfd, TCSETA, &stbuf) < 0) {
> ++ if (ioctl(comfd, TCSETA, &stbuf) < 0 && !force) {
> + serror("Can't ioctl set device",1);
> + }
> + }
> +@@ -1224,7 +1225,7 @@ void doclose(void) {
> + if(strcmp(token,"hardcom")==0) {
> + if(comfd== -1) serror("Com device not open",1);
> + vmsg("Closing device");
> +- if (ioctl(comfd, TCSETA, &svbuf) < 0) {
> ++ if (ioctl(comfd, TCSETA, &svbuf) < 0 && !force) {
> + sprintf(msg,"Can't ioctl set device %s.\n",device);
> + serror(msg,1);
> + }
> +@@ -1266,7 +1267,7 @@ void opengt(void) {
> + ext(1);
> + }
> + }
> +- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
> ++ if (ioctl (comfd, TCGETA, &svbuf) < 0 && !force) {
> + sprintf(msg,"Can't control %s, please try again.\n",device);
> + serror(msg,1);
> + }
> +@@ -1303,7 +1304,7 @@ void opendevice(void) {
> + }
> + else comfd=0;
> +
> +- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
> ++ if (ioctl (comfd, TCGETA, &svbuf) < 0 && !force) {
> + sprintf(msg,"Can't ioctl get device %s.\n",device);
> + serror(msg,1);
> + }
> +@@ -1567,7 +1568,7 @@ int main(int argc,char **argv) {
> + for(a=0;a<strlen(argv[0]);a++) {
> + if(argv[0][a]=='/') b=a+1;
> + }
> +- while((aa=getopt(argc,argv,"xheVvd:t:sb:"))!= -1) {
> ++ while((aa=getopt(argc,argv,"xheVvd:t:sb:f"))!= -1) {
> + switch(aa) {
> + case 0:
> + ext(0);
> +@@ -1605,6 +1606,10 @@ int main(int argc,char **argv) {
> + printf("High speed overide (115200 is now 57600).\n");
> + high_speed =1;
> + break;
> ++ case 'f':
> ++ force=1;
> ++ vmsg("Ignoring ioctl errors");
> ++ break;
> + default:
> + ext(1);
> + }
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list