From: Oliver Hartkopp <socketcan@hartkopp.net>
To: uescher <linux-can_ger.kernel.org@myvdr.de>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [Patch] can-utils/slcanpty.c pseudo-terminal interface
Date: Sun, 16 Dec 2012 17:02:12 +0100 [thread overview]
Message-ID: <50CDF084.8030002@hartkopp.net> (raw)
In-Reply-To: <50CBCEF2.9020904@myvdr.de>
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 <socketcan@hartkopp.net>
for the re-posted patch.
Tnx Ulrich for the pts support!
Regards,
Oliver
On 15.12.2012 02:14, uescher wrote:
> 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.
>
> Signed-off-by: Ulrich Escher<git@myvdr.de>
> ---
> slcanpty.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/slcanpty.c b/slcanpty.c
> index 67a7491..13ed96c 100644
> --- a/slcanpty.c
> +++ b/slcanpty.c
> @@ -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) {
> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-12-16 16:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-16 22:12 [Patch] can-utils/slcanpty.c pseudo-terminal interface uescher
2012-09-17 7:40 ` Marc Kleine-Budde
2012-09-21 8:28 ` uescher
2012-12-15 1:14 ` uescher
2012-12-16 16:02 ` Oliver Hartkopp [this message]
2012-12-17 18:09 ` uescher
2012-12-20 10:43 ` Oliver Hartkopp
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=50CDF084.8030002@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=linux-can@vger.kernel.org \
--cc=linux-can_ger.kernel.org@myvdr.de \
--cc=mkl@pengutronix.de \
/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).