can-utils/slcanpty.c pseudo-terminal interface
PATCH 1/1 can-utils/slcanpty.c pseudo-terminal interface
Add Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N
please take a look over the little Patch.
Thanks
slcanpty.c +30 -0
@@ -26,6 +26,11 @@* */ +#ifndef _GNU_SOURCE +// To get ptsname grantpt and unlockpt definitions from stdlib.h +#define _GNU_SOURCE +#endif +#include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -45,6 +50,8 @@/* maximum rx buffer len: extended CAN frame with timestamp */ #define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1) +#define DEVICE_NAME_PTMX "/dev/ptmx" +#define DEBUG static int asc2nibble (char c)
@@ -387,6 +394,8 @@ int main(int argc, char **argv)fprintf (stderr,"Usage: %s <pty> <can interface>\n" , argv[0 ]);fprintf (stderr,"e.g. '%s /dev/ptyc0 can0' creates" " /dev/ttyc0 for the slcan application\n" , argv[0 ]); +fprintf (stderr,"e.g. for pseudo-terminal '%s /dev/ptmx can0' creates" +" /dev/pts/N\n" , argv[0 ]);fprintf (stderr,"\n" );return 1 ; }
@@ -408,6 +417,27 @@ int main(int argc, char **argv) ECHONL | ECHOPRT | ECHOKE | ICRNL);tcsetattr (p,TCSANOW , &topts); +//Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N +if (strcmp (argv[1 ],DEVICE_NAME_PTMX ) ==0 ) { +if (grantpt (p) <0 ) { +perror ("grantpt" ); +return 1 ; + } + +if (unlockpt (p) <0 ) { +perror ("unlockpt" ); +return 1 ; + } + +char * name_pts =NULL ;/* slave pseudo-terminal device name */ + name_pts =ptsname (p); +if (name_pts ==NULL ) { +perror ("ptsname" ); +return 1 ; + } +printf ("open: %s: slave pseudo-terminal is %s\n" , argv[1 ], name_pts); + } +/* open socket */ s =socket (PF_CAN ,SOCK_RAW ,CAN_RAW );if (s <0 ) {
Marc Kleine-Budde
maintainerHello,
Quoted 1 line · uescher
Add Support for the Unix 98 pseudo-terminal interface
/dev/ptmx/dev/pts/N
Cool, what kind of cool things can we do if this tool supports ptys?
Quoted 3 lines
please take a look over the little Patch.
Thanks
Can you add a Signed-off-by[1] to your patch?
[1]
http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L298
Please don't use C++ comments, use Standard C comments. /* comment */. Please remove any trailing whitespace from your patch.
Some nitpicking inline:
slcanpty.c line 28
Quoted 12 lines
patch.diff
slcanpty.c +0
-0@@ -26,6 +26,11 @@* */
I think it's okay to just define _GNU_SOURCE.
Quoted 18 lines
slcanpty.c +7
-0+#ifndef _GNU_SOURCE +// To get ptsname grantpt and unlockpt definitions from stdlib.h +#define _GNU_SOURCE +#endif +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -45,6 +50,8 @@/* maximum rx buffer len: extended CAN frame with timestamp */ #define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1) +#define DEVICE_NAME_PTMX "/dev/ptmx" +#define DEBUG static int asc2nibble (char c)
slcanpty.c int main(int argc, char **argv) · line 397
Quoted 4 lines
slcanpty.c +1
-0@@ -387,6 +394,8 @@ int main(int argc, char **argv)fprintf (stderr,"Usage: %s <pty> <can interface>\n" , argv[0 ]);fprintf (stderr,"e.g. '%s /dev/ptyc0 can0' creates" " /dev/ttyc0 for the slcan application\n" , argv[0 ]); + fprintf(stderr, "e.g. for pseudo-terminal '%s /dev/ptmx can0' creates"
^^^^^^^^^
Please use %s....
slcanpty.c int main(int argc, char **argv) · line 398
Quoted 1 line
slcanpty.c +1
-0+ " /dev/pts/N\n", argv[0]);
^^^
...and add ", DEVICE_NAME_PTMX" here.
slcanpty.c int main(int argc, char **argv) · line 421
Quoted 9 lines
slcanpty.c +2
-0fprintf (stderr,"\n" );return 1 ; }@@ -408,6 +417,27 @@ int main(int argc, char **argv) ECHONL | ECHOPRT | ECHOKE | ICRNL);tcsetattr (p,TCSANOW , &topts); +//Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N +if (strcmp (argv[1 ],DEVICE_NAME_PTMX ) ==0 ) {
^^^
Please add a space after the comma.
slcanpty.c int main(int argc, char **argv) · line 432
Quoted 11 lines
slcanpty.c +11
-0+if (grantpt (p) <0 ) { +perror ("grantpt" ); +return 1 ; + } + +if (unlockpt (p) <0 ) { +perror ("unlockpt" ); +return 1 ; + } + +char * name_pts =NULL ;/* slave pseudo-terminal device name */
^^^
Please make it "char *name_pts".
slcanpty.c int main(int argc, char **argv) · line 443
Quoted 11 lines
slcanpty.c +8
-0+ name_pts =ptsname (p); +if (name_pts ==NULL ) { +perror ("ptsname" ); +return 1 ; + } +printf ("open: %s: slave pseudo-terminal is %s\n" , argv[1 ], name_pts); + } +/* open socket */ s =socket (PF_CAN ,SOCK_RAW ,CAN_RAW );if (s <0 ) {
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Thank you Marc for your feedback.
I have no time for the next two weeks.
I will report again in two weeks.
Ulrich
Next try :)
Add Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N
http://www.kernel.org/doc/man-pages/online/pages/man4/pts.4.html
My change is like this change:
http://sourceforge.net/tracker/index.php?func=detail&aid=3467521&group_id=146269&atid=764681
most Linux distributions do not configure their kernels to use the BSD pseudo-terminal interface (/dev/pty* and /dev/tty*) anymore; they uses the Unix 98 pseudo-terminal interface instead (/dev/ptmx and /dev/pts/*). Maybe is it possible to add this patch for the next release.
Thanks.
--- slcanpty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
slcanpty.c +27 -0
@@ -22,6 +22,9 @@* */ +/* To get ptsname grantpt and unlockpt definitions from stdlib.h */ +#define _GNU_SOURCE +#include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -40,6 +43,7 @@/* maximum rx buffer len: extended CAN frame with timestamp */ #define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1) +#define DEVICE_NAME_PTMX "/dev/ptmx"#define DEBUG
@@ -383,6 +387,8 @@ int main(int argc, char **argv)fprintf (stderr,"Usage: %s <pty> <can interface>\n" , argv[0 ]);fprintf (stderr,"e.g. '%s /dev/ptyc0 can0' creates" " /dev/ttyc0 for the slcan application\n" , argv[0 ]); +fprintf (stderr,"e.g. for pseudo-terminal '%s %s can0' creates" +" /dev/pts/N\n" , argv[0 ],DEVICE_NAME_PTMX );fprintf (stderr,"\n" );return 1 ; }
@@ -404,6 +410,27 @@ int main(int argc, char **argv) ECHONL | ECHOPRT | ECHOKE | ICRNL);tcsetattr (p,TCSANOW , &topts); +/* Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N */ +if (strcmp (argv[1 ],DEVICE_NAME_PTMX ) ==0 ) { +if (grantpt (p) <0 ) { +perror ("grantpt" ); +return 1 ; + } + +if (unlockpt (p) <0 ) { +perror ("unlockpt" ); +return 1 ; + } + +char *name_pts =NULL ;/* slave pseudo-terminal device name */ + name_pts =ptsname (p); +if (name_pts ==NULL ) { +perror ("ptsname" ); +return 1 ; + } +printf ("open: %s: slave pseudo-terminal is %s\n" , argv[1 ], name_pts); + } +/* open socket */ s =socket (PF_CAN ,SOCK_RAW ,CAN_RAW );if (s <0 ) {
--
Oliver Hartkopp
Acked-byPlease re-send with proper whitespaces.
Something (your mail client?) replaced tabs with spaces ...
@Marc: If there're new no remarks from your side you can add my
for the re-posted patch.
Tnx Ulrich for the pts support!
Regards,
Oliver
Quoted 81 lines · uescher
Next try :)
Add Support for the Unix 98 pseudo-terminal interface/dev/ptmx/dev/pts/N
http://www.kernel.org/doc/man-pages/online/pages/man4/pts.4.html
My change is like this change:
http://sourceforge.net/tracker/index.php?func=detail&aid=3467521&group_id=146269&atid=764681most Linux distributions do not configure their kernels to use the BSD pseudo-terminal interface (
/dev/pty*and/dev/tty*) anymore; they uses the Unix 98 pseudo-terminal interface instead (/dev/ptmxand/dev/pts/*). Maybe is it possible to add this patch for the next release. Thanks.Signed-off-by Ulrich Escher<[email protected]>--- slcanpty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)slcanpty.c +27
-0@@ -22,6 +22,9 @@* */ +/* To get ptsname grantpt and unlockpt definitions from stdlib.h */ +#define _GNU_SOURCE +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -40,6 +43,7 @@/* maximum rx buffer len: extended CAN frame with timestamp */ #define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1) +#define DEVICE_NAME_PTMX "/dev/ptmx"#define DEBUG @@ -383,6 +387,8 @@ int main(int argc, char **argv)fprintf (stderr,"Usage: %s <pty> <can interface>\n" , argv[0 ]);fprintf (stderr,"e.g. '%s /dev/ptyc0 can0' creates" " /dev/ttyc0 for the slcan application\n" , argv[0 ]); +fprintf (stderr,"e.g. for pseudo-terminal '%s %s can0' creates" +" /dev/pts/N\n" , argv[0 ],DEVICE_NAME_PTMX );fprintf (stderr,"\n" );return 1 ; }@@ -404,6 +410,27 @@ int main(int argc, char **argv) ECHONL | ECHOPRT | ECHOKE | ICRNL);tcsetattr (p,TCSANOW , &topts); +/* Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N */ +if (strcmp (argv[1 ],DEVICE_NAME_PTMX ) ==0 ) { +if (grantpt (p) <0 ) { +perror ("grantpt" ); +return 1 ; + } + +if (unlockpt (p) <0 ) { +perror ("unlockpt" ); +return 1 ; + } + +char *name_pts =NULL ;/* slave pseudo-terminal device name */ + name_pts =ptsname (p); +if (name_pts ==NULL ) { +perror ("ptsname" ); +return 1 ; + } +printf ("open: %s: slave pseudo-terminal is %s\n" , argv[1 ], name_pts); + } +/* open socket */ s =socket (PF_CAN ,SOCK_RAW ,CAN_RAW );if (s <0 ) {Signature · 4 lines
-- To unsubscribe from this list: send the line "unsubscribe linux-can" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ok, thunderbird html ... is not so good :)
now in an extra complete File.
LG
Am 16.12.2012 17:02, schrieb Oliver Hartkopp:
Quoted 11 lines
Please re-send with proper whitespaces.
Something (your mail client?) replaced tabs with spaces ...
@Marc: If there're new no remarks from your side you can add my
Acked-by Oliver Hartkopp <[email protected]>for the re-posted patch.
Tnx Ulrich for the pts support!
From a6604f8e6a7ec558579ff523603a9a7892af54fd Mon Sep 17 00:00:00 2001
From: ulrich <[email protected]>
Date: Sat, 15 Dec 2012 12:31:11 +0100
Subject: [PATCH] Support for the Unix 98 pseudo-terminal interface /dev/ptmx
/dev/pts/N
Add Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N
http://www.kernel.org/doc/man-pages/online/pages/man4/pts.4.html
My change is like this change:
http://sourceforge.net/tracker/index.php?func=detail&aid=3467521&group_id=146269&atid=764681
most Linux distributions do not configure their kernels to use the BSD pseudo-terminal interface (/dev/pty* and /dev/tty*) anymore; they uses the Unix 98 pseudo-terminal interface instead (/dev/ptmx and /dev/pts/*). Maybe is it possible to add this patch for the next release. Thanks.
--- slcanpty.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
slcanpty.c +27 -0
@@ -22,6 +22,9 @@* */ +/* To get ptsname grantpt and unlockpt definitions from stdlib.h */ +#define _GNU_SOURCE +#include <stdio.h> #include <stdlib.h> #include <string.h>
@@ -40,6 +43,7 @@/* maximum rx buffer len: extended CAN frame with timestamp */ #define SLC_MTU (sizeof("T1111222281122334455667788EA5F\r")+1) +#define DEVICE_NAME_PTMX "/dev/ptmx"#define DEBUG
@@ -383,6 +387,8 @@ int main(int argc, char **argv)fprintf (stderr,"Usage: %s <pty> <can interface>\n" , argv[0 ]);fprintf (stderr,"e.g. '%s /dev/ptyc0 can0' creates" " /dev/ttyc0 for the slcan application\n" , argv[0 ]); +fprintf (stderr,"e.g. for pseudo-terminal '%s %s can0' creates" +" /dev/pts/N\n" , argv[0 ],DEVICE_NAME_PTMX );fprintf (stderr,"\n" );return 1 ; }
@@ -404,6 +410,27 @@ int main(int argc, char **argv) ECHONL | ECHOPRT | ECHOKE | ICRNL);tcsetattr (p,TCSANOW , &topts); +/* Support for the Unix 98 pseudo-terminal interface /dev/ptmx /dev/pts/N */ +if (strcmp (argv[1 ],DEVICE_NAME_PTMX ) ==0 ) { +if (grantpt (p) <0 ) { +perror ("grantpt" ); +return 1 ; + } + +if (unlockpt (p) <0 ) { +perror ("unlockpt" ); +return 1 ; + } + +char *name_pts =NULL ;/* slave pseudo-terminal device name */ + name_pts =ptsname (p); +if (name_pts ==NULL ) { +perror ("ptsname" ); +return 1 ; + } +printf ("open: %s: slave pseudo-terminal is %s\n" , argv[1 ], name_pts); + } +/* open socket */ s =socket (PF_CAN ,SOCK_RAW ,CAN_RAW );if (s <0 ) {
Signature · 1 line
1.7.9.5
Oliver Hartkopp
AppliedHello Ulrich,
applied to the can-utils git repo.
I moved the name_pts definition at the {} section start and reordered the commit message information.
Tnx,
Oliver
Quoted 19 lines · uescher
Ok, thunderbird html ... is not so good :)
now in an extra complete File.
LG
Am 16.12.2012 17:02, schrieb Oliver Hartkopp:
Quoted 11 lines
Please re-send with proper whitespaces.
Something (your mail client?) replaced tabs with spaces ...
@Marc: If there're new no remarks from your side you can add my
Acked-by Oliver Hartkopp <[email protected]>for the re-posted patch.
Tnx Ulrich for the pts support!