All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: uescher <linux-can_ger.kernel.org@myvdr.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [Patch] can-utils/slcanpty.c pseudo-terminal interface
Date: Mon, 17 Sep 2012 09:40:39 +0200	[thread overview]
Message-ID: <5056D3F7.10506@pengutronix.de> (raw)
In-Reply-To: <50564EC7.7020005@myvdr.de>

[-- Attachment #1: Type: text/plain, Size: 3061 bytes --]

Hello,

On 09/17/2012 12:12 AM, uescher wrote:
> 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?

> 
> 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:

> 
> patch.diff
> 
> 
> diff --git a/slcanpty.c b/slcanpty.c
> index 67dcf35..e3b7304 100644
> --- a/slcanpty.c
> +++ b/slcanpty.c
> @@ -26,6 +26,11 @@
>   *
>   */
>  

I think it's okay to just define _GNU_SOURCE.

> +#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"
                                                              ^^^^^^^^^
Please use %s....

> +			" /dev/pts/N\n", argv[0]);
                                               ^^^
...and add ", DEVICE_NAME_PTMX" here.

>  		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) {
                          ^^^

Please add a space after the comma.

> +		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".

> +		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

-- 
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   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2012-09-17  7:40 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 [this message]
2012-09-21  8:28   ` uescher
2012-12-15  1:14   ` uescher
2012-12-16 16:02     ` Oliver Hartkopp
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=5056D3F7.10506@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-can_ger.kernel.org@myvdr.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.