All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC 2/5] CAN device test command
Date: Sun, 01 Nov 2009 17:24:59 +0100	[thread overview]
Message-ID: <4AEDB65B.4080102@grandegger.com> (raw)
In-Reply-To: <200911010945.12254.vapier@gentoo.org>

Mike Frysinger wrote:
> On Sunday 01 November 2009 06:33:34 Wolfgang Grandegger wrote:
>> +	if (op == 's') {
>> +	else if (op == 'i') {
>> +	else if (op == 'r') {
>> +	} else if (op == 'x') {
>> +	} else {
> 
> your if style here is inconsistent, but ignoring that, shouldnt this really be 
> a switch() ?  although, by only checking the first char, you allow people to 
> encode typos into their commands and not realize it until some point in the 
> future where things get stricter.  i.e. people can do `can ilovecandy ...`

Will fix.

>> +		unsigned int dev_num = 0, ibaud = 0;
>> +		struct can_dev *dev;
>> +
>> +		if (argc > 2)
>> +			dev_num = simple_strtoul (argv[2], NULL, 10);
>> +		if (argc > 3) {
>> +			ibaud = simple_strtoul (argv[3], NULL, 10);
>> +			if (ibaud > 2)
>> +				ibaud = 2;
>> +		}
>> +		dev = can_init (dev_num, ibaud);
>> +		if (!dev)
>> +			return 1;
>> +		can_dev = dev;
> 
> if i told CAN to init an unknown device, i would expect to get an error and 
> the command state to remain in said error state until i selected a proper CAN 
> device.  otherwise, a script that didnt check the can init status would 
> incorrectly operate on the previously selected can device.

can_init will already print an error message. But that might be changed.

> how do other commands work ?  am i complaining about common convention here ?
> 
>> +		printf ("Usage:\n%s\n", cmdtp->usage);
> 
> cmd_usage() ?

OK.

>> +	can, 3,	1, do_can,
>> +	"can - CAN bus commands\n",
>> +	"can status [level]\n"
>> +	"can init [dev] [baud-index]\n"
>> +	"can xmit [id] [d0] [d1] ... [d7]\n"
>> +	"can recv, abort with CTRL-C\n"
> 
> does the help really display correctly here ?  i think the "can status" line 
> will have too many "can"'s ?

I think the output was OK. But I will check later next week.

Note that this is a RFC trying to discuss the real requirements of a CAN
interface in U-Boot. I think it would also be nice to have can_xmit()
and can_recv() with a timeout parameter, e.g.:

  can_xmit(struct can_dev *dev, int timeout_us);

And maybe also a can_xmit_done() function.

Wolfgang.

  reply	other threads:[~2009-11-01 16:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-01 11:33 [U-Boot] [RFC 0/5] CAN framework for U-Boot Wolfgang Grandegger
2009-11-01 11:33 ` [U-Boot] [RFC 1/5] CAN interface library Wolfgang Grandegger
2009-11-01 11:33   ` [U-Boot] [RFC 2/5] CAN device test command Wolfgang Grandegger
2009-11-01 11:33     ` [U-Boot] [RFC 3/5] CAN device driver for the SJA1000 Wolfgang Grandegger
2009-11-01 11:33       ` [U-Boot] [RFC 4/5] CAN device driver for the Intel 82527 Wolfgang Grandegger
2009-11-01 11:33         ` [U-Boot] [RFC 5/5] CAN interface support for the TQM855L module Wolfgang Grandegger
2009-11-02 12:02       ` [U-Boot] [RFC 3/5] CAN device driver for the SJA1000 Matthias Fuchs
2009-11-02 12:50         ` Wolfgang Grandegger
2009-11-02 14:22           ` Matthias Fuchs
2009-11-02 20:20             ` Wolfgang Grandegger
2009-11-05 20:28               ` Wolfgang Denk
2009-11-01 14:45     ` [U-Boot] [RFC 2/5] CAN device test command Mike Frysinger
2009-11-01 16:24       ` Wolfgang Grandegger [this message]
2009-11-01 18:07         ` Mike Frysinger
2009-11-01 14:36   ` [U-Boot] [RFC 1/5] CAN interface library Mike Frysinger
2009-11-01 16:16     ` Wolfgang Grandegger
2009-11-01 18:05       ` Mike Frysinger
2009-11-01 22:00         ` Wolfgang Grandegger

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=4AEDB65B.4080102@grandegger.com \
    --to=wg@grandegger.com \
    --cc=u-boot@lists.denx.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.