From: Greg KH <greg@kroah.com>
To: Marcel Janssen <korgull@home.nl>
Cc: stefan_kopp@agilent.com, stern@rowland.harvard.edu,
oliver@neukum.org, linux-usb@vger.kernel.org, me@felipebalbi.com,
linux-kernel@vger.kernel.org,
Marcel Janssen <marcel.janssen@admesy.nl>
Subject: Re: [PATCH] USB: add USB test and measurement class driver - round 2
Date: Fri, 29 Aug 2008 13:01:33 -0700 [thread overview]
Message-ID: <20080829200133.GA20682@kroah.com> (raw)
In-Reply-To: <200808291841.15853.korgull@home.nl>
On Fri, Aug 29, 2008 at 06:41:15PM +0200, Marcel Janssen wrote:
> On Friday 29 August 2008 16:39:02 Greg KH wrote:
> > > The issue with using cat on the shell level is that it uses fread
> > > which has the (in this case) ugly behaviour of recalling the driver's
> > > read method until the full number of characters requested has been
> > > accumulated (or until zero characters are returned, indicating the end
> > > of file). With USBTMC instruments, this behavour is bad because the
> > > retry will not just return zero characters, it will cause a timeout
> > > with the associated error condition in the device. So, to enable the
> > > use of echo/cat, I added some fread handling to the driver (which
> > > catches the retries). I believe this also has been removed, so I
> > > assume cat/fread will not work (?).
> >
> > I do not know, but we do not do wierd things in the kernel just because
> > of broken userspace programs. This logic should be done in userspace,
> > and programs should look at the return value of read() and handle it
> > properly. Otherwise it is a bug.
>
> I don't think this is broken in user space. The problem is that when you issue
> a measurement command it is not known how many bytes it will return. This is
> probably due to ASCII output being very common in T&M devices instead of raw
> data (int, float etc). The ASCII formatting is done in the device and this
> returns just a string which may or may not be terminated by the term char.
> This is of course not true for all T&M devices, but the majority works this
> way.
>
> I admit that the above produces a lot of overhead, but it's just a fact that
> T&M devices work this way, including ours for most of their data processing
> (not all though).
How is this overhead in userspace, just do something like the following:
char big_buffer[16000]; /* bigger than any possible request */
size = read(file_desc, &big_buffer[0], sizeof(big_buffer));
and size is the amount of data you actually read from the device, i.e.
one request.
> I think the USBTMC spec is quite clear on how it should be implemented on
> messaging level. Basically when you issue the command "*IDN?" the device
> will process this and return the device ID string. The length of this string
> is set in the TransferSize of the 12 byte header that the device returns. The
> problem when you issue a read command is that the read command does not yet
> know how much data to expect. It should issue the REQUEST_DEV_DEP_MSG_IN
> first and set the TransferSize value high enough.
> In the USBTMC_488 extension you find an example (chapter 3.3.1 page 7) that
> shows the REQUEST_DEV_DEP_MSG_IN TransferSize being set to 64 although the
> actual data being returned from the device is less (only 36 bytes).
>
> What you do see in practice is that when someone would issue a read command
> and asking for less bytes than are available is that the user program may
> handle this as a warning telling the user that he did not request all
> available data.
Then that's a userspace bug, don't do that in your program that reads
from these types of devices :)
> Stefan's driver works exactly the way I would expect from a users point of
> view. Whether the implementation can be improved is another issue, but the
> behaviour is correct and compliant with other usbtmc drivers on other
> platforms.
But it's not compliant with the "standard" way of using a file
descriptor in unix, and might break some POSIX requirements as well (I'm
not a good POSIX follower, so I don't know for sure...)
As this is trivial to handle in userspace, and requires no additional
wierd code in the kernel driver, I don't see this as something we should
change the driver for.
thanks,
greg k-h
next prev parent reply other threads:[~2008-08-30 3:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 17:20 [PATCH] USB: add USB test and measurement class driver - round 2 Greg KH
2008-08-27 18:28 ` Alan Stern
2008-08-27 18:36 ` Greg KH
2008-08-27 18:58 ` Alan Stern
2008-08-27 19:05 ` Oliver Neukum
2008-08-27 19:16 ` Alan Stern
2008-08-27 23:48 ` Greg KH
2008-08-27 23:47 ` Greg KH
2008-08-28 10:10 ` Oliver Neukum
2008-08-28 16:17 ` Greg KH
2008-08-28 21:29 ` Oliver Neukum
2008-08-28 16:58 ` Marcel Janssen
2008-08-28 20:38 ` Greg KH
2008-08-29 6:57 ` stefan_kopp
2008-08-29 7:46 ` Oliver Neukum
2008-08-29 8:14 ` stefan_kopp
2008-08-29 8:34 ` Oliver Neukum
2008-08-29 9:13 ` stefan_kopp
2008-08-29 11:33 ` Oliver Neukum
2008-08-29 14:39 ` Greg KH
2008-08-29 16:41 ` Marcel Janssen
2008-08-29 20:01 ` Greg KH [this message]
2008-08-27 18:37 ` Oliver Neukum
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=20080829200133.GA20682@kroah.com \
--to=greg@kroah.com \
--cc=korgull@home.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marcel.janssen@admesy.nl \
--cc=me@felipebalbi.com \
--cc=oliver@neukum.org \
--cc=stefan_kopp@agilent.com \
--cc=stern@rowland.harvard.edu \
/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