Fwd: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-17 Thread arun k
Hi,
Regarding the above issue, I was checking the USB- Generic driver,
And I tried the following things and found my data loss issue is fixed.

change point

 In usb_serial_probe() function in usb-serial.c

/* set up the endpoint information */
for (i = 0; i  num_bulk_in; ++i) {
endpoint = bulk_in_endpoint[i];
port = serial-port[i];
buffer_size = max_t(int, serial-type-bulk_in_size,
usb_endpoint_maxp(endpoint));
buffer_size = 16384;
..
..

I changed the buffer_size value  used in urb, previously it was 64
bytes now it is 16384 and I found my data loss issue fixed.

Could you tell me is there any issue with this changes ?
I am using this driver in embedded platform and in my application
other devices will not use USB -Generic driver.

Regards,
Arun







On Sat, Aug 8, 2015 at 2:50 AM, Greg KH gre...@linuxfoundation.org wrote:

 On Fri, Aug 07, 2015 at 07:26:15PM +0900, arun k wrote:
  Hi,
 
  I am stuck with the above issue,
  I have some doubts regarding USB - Generic driver
  1. Could you please explain me why USB - Generic driver is slow ?

 Because it was designed that way, it is not for high-speed data
 throughput at all.  It is a stop-gap measure for dumb usb devices that
 want to emulate a serial connection.  If you need a real driver, to
 handle high rates of data, you will need to write a new driver for it.

  2. Now I am try to study USB - Generic driver implementation , I am
  confused with the function usb_serial_generic_read_bulk_callback() ,
  could you please tell me from where this function is calling ?

 I recommend reading the USB chapter in the Linux Device Drivers book
 (version 3, free online) to understand how USB drivers work.  After
 that, the answer should be obvious (hint, look at where that function
 pointer is assigned to something...)

  3. If you have any detailed doc regarding the implementation of USB -
  Generic serial driver, Please send to me,

 The source code is pretty well documented :)

 thanks,

 greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-07 Thread arun k
Hi,

I am stuck with the above issue,
I have some doubts regarding USB - Generic driver
1. Could you please explain me why USB - Generic driver is slow ?
2. Now I am try to study USB - Generic driver implementation , I am
confused with the function usb_serial_generic_read_bulk_callback() ,
could you please tell me from where this function is calling ?
3. If you have any detailed doc regarding the implementation of USB -
Generic serial driver, Please send to me,

Regards,
Arun



On Thu, Aug 6, 2015 at 3:42 PM, arun k arunkarunakara...@gmail.com wrote:
 / # lsusb -v
 Bus 002 Device 006: ID 045b:0218
 Bus 001 Device 001: ID 1d6b:0002
 Bus 002 Device 001: ID 1d6b:0001
 Bus 003 Device 001: ID 1d6b:0002
 Bus 004 Device 001: ID 1d6b:0003

 In this my device is
 Bus 002 Device 006: ID 045b:0218

 I enabled data dumping in usb_serial_generic_read_bulk_callback()
 function and found data received in this function is losing.
 In this function data is received as 64 bytes packets and two
 continuous 64 bytes having no data loss but the next packets are lost
 ie
 1st packet ok(64 byte)
 2nd packet ok(64 byte)
 .
 . packet lossing
 .
 7th packet ok(64 byte)
 8th packet ok(64 byte)
 .
 .
 In this way data loss is happening. Number of packets losing is
 different not constant always.

 I think the generic USB driver ignores baud rate. Like Greg suggested, 
 you need to
use the proper driver for your hardware.

 I did't find any other suitable driver inside Linux.
 I checked this device in windows in that usbser.sys is detecting(.inf
 file is attached with the mail).

  Could you suggest any available drivers for my device. Sorry I am
 very new to Linux drivers.
 I will post my USB device descriptor values below

 [ 1291.908071] ## udev-descriptor.bLength  0x12
 [ 1291.908089] ## udev-descriptor.bDescriptorType  0x1
 [ 1291.908147] ## udev-descriptor.bcdUSB  0x200
 [ 1291.908165] ## udev-descriptor.bDeviceClass  0xef
 [ 1291.908181] ## udev-descriptor.bDeviceSubClass  0x2
 [ 1291.908196] ## udev-descriptor.bDeviceProtocol  0x1
 [ 1291.908211] ## udev-descriptor.bMaxPacketSize0  0x40
 [ 1291.908226] ## udev-descriptor.idVendor  0x45b
 [ 1291.908241] ## udev-descriptor.idProduct  0x218
 [ 1291.908255] ## udev-descriptor.bcdDevice  0x1
 [ 1291.908270] ## udev-descriptor.iManufacturer  0x0
 [ 1291.908284] ## udev-descriptor.iProduct  0x0
 [ 1291.908298] ## udev-descriptor.iSerialNumber  0x0
 [ 1291.908313] ## udev-descriptor.bNumConfigurations  0x1

 Regards,
 Arun











 On Wed, Aug 5, 2015 at 9:31 PM, Peter Hurley pe...@hurleysoftware.com wrote:
 On 08/04/2015 11:57 PM, arun k wrote:
 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?

 I am not sure about this. I need to check this.

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line 
 rate
 and see if that fixes your data loss problem

 I tried B115200 also but issue is still there.

 I think the generic USB driver ignores baud rate. Like Greg suggested, you 
 need to
 use the proper driver for your hardware.

 What is the output from 'lsusb -v' and please identify in that output which
 device you are using.

 I am using a USB device and that sending data at a rate of *409600 
 bytes/sec*. Is this data rate have any relation with issue.

 Yes. Also, can you test this on a newer kernel like 3.18?

 Regards,
 Peter Hurley

 On Wed, Aug 5, 2015 at 11:24 AM, Peter Hurley pe...@hurleysoftware.com 
 mailto:pe...@hurleysoftware.com wrote:

 On 08/04/2015 10:00 PM, arun k wrote:
  I enabled software flow control like below
 
  tty.c_iflag |= (IXON | IXOFF | IXANY);

 Ok, but does the sending device know how to process in-band software 
 flow control
 and is it set up to respond properly?

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line 
 rate
 and see if that fixes your data loss problem.

 Regards,
 Peter Hurley


  On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley 
 pe...@hurleysoftware.com mailto:pe...@hurleysoftware.com wrote:
  On 08/03/2015 10:47 PM, arun k wrote:
  Thank you for the reply
 
  The tty layer is limiting you, just keep reading in a loop until 
 you
  run out of data, you should not ever expect to read a specific 
 number of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  I tried this method but in my case I found data loss. By changing 
 any buffer size modification in driver side , can we fix this issue ?
 
  The data loss is probably occurring because you have all flow 
 control disabled
  and the line speed is too fast for no flow control.
 
  Regards,
  Peter Hurley
 
  Please don't use the generic driver, it's slow 

Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-07 Thread Peter Hurley
On 08/06/2015 02:42 AM, arun k wrote:
 / # lsusb -v
 Bus 002 Device 006: ID 045b:0218
 Bus 001 Device 001: ID 1d6b:0002
 Bus 002 Device 001: ID 1d6b:0001
 Bus 003 Device 001: ID 1d6b:0002
 Bus 004 Device 001: ID 1d6b:0003
 
 In this my device is
 Bus 002 Device 006: ID 045b:0218

I have no idea what this device is, sorry. And the device descriptor
dump below is not very helpful because it doesn't have the configurations.
What is this for?

 I enabled data dumping in usb_serial_generic_read_bulk_callback()
 function and found data received in this function is losing.
 In this function data is received as 64 bytes packets and two
 continuous 64 bytes having no data loss but the next packets are lost
 ie
 1st packet ok(64 byte)
 2nd packet ok(64 byte)
 .
 . packet lossing
 .
 7th packet ok(64 byte)
 8th packet ok(64 byte)
 .
 .
 In this way data loss is happening. Number of packets losing is
 different not constant always.

It's unclear what you are saying here; are you saying
(a) the sending device is dropping data so the urbs do not contain the
data you expect, or
(b) all of the data is being received but the not all of it is being
buffered.

Either way, the fundamental problem you have is that your reader is
not fast enough. What is your application?

Have you tried a simple test jig that only reads data without processing
it to see if the application is the problem?

What h/w platform is this?

You mentioned earlier you're running 3.4.35. That's really old; current 3.4
is .108. Where did you get this kernel?

Regards,
Peter Hurley

PS - Please stop top-posting. See how I had to reiterate your linux version...


 I think the generic USB driver ignores baud rate. Like Greg suggested, 
 you need to
 use the proper driver for your hardware.
 
 I did't find any other suitable driver inside Linux.
 I checked this device in windows in that usbser.sys is detecting(.inf
 file is attached with the mail).
 
  Could you suggest any available drivers for my device. Sorry I am
 very new to Linux drivers.
 I will post my USB device descriptor values below
 
 [ 1291.908071] ## udev-descriptor.bLength  0x12
 [ 1291.908089] ## udev-descriptor.bDescriptorType  0x1
 [ 1291.908147] ## udev-descriptor.bcdUSB  0x200
 [ 1291.908165] ## udev-descriptor.bDeviceClass  0xef
 [ 1291.908181] ## udev-descriptor.bDeviceSubClass  0x2
 [ 1291.908196] ## udev-descriptor.bDeviceProtocol  0x1
 [ 1291.908211] ## udev-descriptor.bMaxPacketSize0  0x40
 [ 1291.908226] ## udev-descriptor.idVendor  0x45b
 [ 1291.908241] ## udev-descriptor.idProduct  0x218
 [ 1291.908255] ## udev-descriptor.bcdDevice  0x1
 [ 1291.908270] ## udev-descriptor.iManufacturer  0x0
 [ 1291.908284] ## udev-descriptor.iProduct  0x0
 [ 1291.908298] ## udev-descriptor.iSerialNumber  0x0
 [ 1291.908313] ## udev-descriptor.bNumConfigurations  0x1
 
 Regards,
 Arun
 
 
 
 
 
 
 
 
 
 
 
 On Wed, Aug 5, 2015 at 9:31 PM, Peter Hurley pe...@hurleysoftware.com wrote:
 On 08/04/2015 11:57 PM, arun k wrote:
 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?

 I am not sure about this. I need to check this.

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line 
 rate
 and see if that fixes your data loss problem

 I tried B115200 also but issue is still there.

 I think the generic USB driver ignores baud rate. Like Greg suggested, you 
 need to
 use the proper driver for your hardware.

 What is the output from 'lsusb -v' and please identify in that output which
 device you are using.

 I am using a USB device and that sending data at a rate of *409600 
 bytes/sec*. Is this data rate have any relation with issue.

 Yes. Also, can you test this on a newer kernel like 3.18?

 Regards,
 Peter Hurley

 On Wed, Aug 5, 2015 at 11:24 AM, Peter Hurley pe...@hurleysoftware.com 
 mailto:pe...@hurleysoftware.com wrote:

 On 08/04/2015 10:00 PM, arun k wrote:
  I enabled software flow control like below
 
  tty.c_iflag |= (IXON | IXOFF | IXANY);

 Ok, but does the sending device know how to process in-band software 
 flow control
 and is it set up to respond properly?

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line 
 rate
 and see if that fixes your data loss problem.

 Regards,
 Peter Hurley


  On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley 
 pe...@hurleysoftware.com mailto:pe...@hurleysoftware.com wrote:
  On 08/03/2015 10:47 PM, arun k wrote:
  Thank you for the reply
 
  The tty layer is limiting you, just keep reading in a loop until 
 you
  run out of data, you should not ever expect to read a specific 
 number of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  I tried this 

Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-07 Thread Greg KH
On Fri, Aug 07, 2015 at 07:26:15PM +0900, arun k wrote:
 Hi,
 
 I am stuck with the above issue,
 I have some doubts regarding USB - Generic driver
 1. Could you please explain me why USB - Generic driver is slow ?

Because it was designed that way, it is not for high-speed data
throughput at all.  It is a stop-gap measure for dumb usb devices that
want to emulate a serial connection.  If you need a real driver, to
handle high rates of data, you will need to write a new driver for it.

 2. Now I am try to study USB - Generic driver implementation , I am
 confused with the function usb_serial_generic_read_bulk_callback() ,
 could you please tell me from where this function is calling ?

I recommend reading the USB chapter in the Linux Device Drivers book
(version 3, free online) to understand how USB drivers work.  After
that, the answer should be obvious (hint, look at where that function
pointer is assigned to something...)

 3. If you have any detailed doc regarding the implementation of USB -
 Generic serial driver, Please send to me,

The source code is pretty well documented :)

thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-05 Thread Peter Hurley
On 08/04/2015 11:57 PM, arun k wrote:
 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?
 
 I am not sure about this. I need to check this.
 
 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line rate
 and see if that fixes your data loss problem
 
 I tried B115200 also but issue is still there.

I think the generic USB driver ignores baud rate. Like Greg suggested, you need 
to
use the proper driver for your hardware.

What is the output from 'lsusb -v' and please identify in that output which
device you are using.

 I am using a USB device and that sending data at a rate of *409600 
 bytes/sec*. Is this data rate have any relation with issue. 

Yes. Also, can you test this on a newer kernel like 3.18?

Regards,
Peter Hurley

 On Wed, Aug 5, 2015 at 11:24 AM, Peter Hurley pe...@hurleysoftware.com 
 mailto:pe...@hurleysoftware.com wrote:
 
 On 08/04/2015 10:00 PM, arun k wrote:
  I enabled software flow control like below
 
  tty.c_iflag |= (IXON | IXOFF | IXANY);
 
 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?
 
 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line 
 rate
 and see if that fixes your data loss problem.
 
 Regards,
 Peter Hurley
 
 
  On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley pe...@hurleysoftware.com 
 mailto:pe...@hurleysoftware.com wrote:
  On 08/03/2015 10:47 PM, arun k wrote:
  Thank you for the reply
 
  The tty layer is limiting you, just keep reading in a loop until you
  run out of data, you should not ever expect to read a specific 
 number of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  I tried this method but in my case I found data loss. By changing any 
 buffer size modification in driver side , can we fix this issue ?
 
  The data loss is probably occurring because you have all flow control 
 disabled
  and the line speed is too fast for no flow control.
 
  Regards,
  Peter Hurley
 
  Please don't use the generic driver, it's slow and not the best to
  use
 
  Could you tell me is generic driver is suitable for my application ( 
 My usb device sending data at a rate of 409600 bytes/sec) , ?
  or do you have any other suggestion for me ?
 
  My Linux kernel  version is 3.4.35
 
  Regards,
  Arun
 
  On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org 
 mailto:gre...@linuxfoundation.org mailto:gre...@linuxfoundation.org 
 mailto:gre...@linuxfoundation.org wrote:
 
  On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
   Hi ,
  
   I have a trouble with using usb serial generic device.
I am using USB - Generic Serial driver for communicating with 
 my usb
   device and my embedded device.
 
  Please don't use the generic driver, it's slow and not the best 
 to
  use.
 
   My usb device sending data at a rate of 409600 bytes/sec, and 
 in host
   side application I tried to read 16384 bytes in one read. But 
 the read
   size returning is always  4095
 
  The tty layer is limiting you, just keep reading in a loop until 
 you
  run out of data, you should not ever expect to read a specific 
 number of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  thanks,
 
  greg k-h
 
 
 
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fwd: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-04 Thread arun k
-- Forwarded message --
From: arun k arunkarunakara...@gmail.com
Date: Wed, Aug 5, 2015 at 12:57 PM
Subject: Re: USB - Generic Serial device : Unable to read more than 4095 bytes
To: Peter Hurley pe...@hurleysoftware.com
Cc: Greg KH gre...@linuxfoundation.org, linux-usb@vger.kernel.org


 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?

I am not sure about this. I need to check this.

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line rate
 and see if that fixes your data loss problem

I tried B115200 also but issue is still there.

I am using a USB device and that sending data at a rate of 409600
bytes/sec. Is this data rate have any relation with issue.

Regards,
Arun





On Wed, Aug 5, 2015 at 11:24 AM, Peter Hurley pe...@hurleysoftware.com wrote:

 On 08/04/2015 10:00 PM, arun k wrote:
  I enabled software flow control like below
 
  tty.c_iflag |= (IXON | IXOFF | IXANY);

 Ok, but does the sending device know how to process in-band software flow 
 control
 and is it set up to respond properly?

 Also, I doubt software flow control is going to work @ 4Mbaud line rate.
 If you're stuck using software flow control, start with a 115kbaud line rate
 and see if that fixes your data loss problem.

 Regards,
 Peter Hurley


  On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley pe...@hurleysoftware.com 
  wrote:
  On 08/03/2015 10:47 PM, arun k wrote:
  Thank you for the reply
 
  The tty layer is limiting you, just keep reading in a loop until you
  run out of data, you should not ever expect to read a specific number of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  I tried this method but in my case I found data loss. By changing any 
  buffer size modification in driver side , can we fix this issue ?
 
  The data loss is probably occurring because you have all flow control 
  disabled
  and the line speed is too fast for no flow control.
 
  Regards,
  Peter Hurley
 
  Please don't use the generic driver, it's slow and not the best to
  use
 
  Could you tell me is generic driver is suitable for my application ( My 
  usb device sending data at a rate of 409600 bytes/sec) , ?
  or do you have any other suggestion for me ?
 
  My Linux kernel  version is 3.4.35
 
  Regards,
  Arun
 
  On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org 
  mailto:gre...@linuxfoundation.org wrote:
 
  On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
   Hi ,
  
   I have a trouble with using usb serial generic device.
I am using USB - Generic Serial driver for communicating with my 
  usb
   device and my embedded device.
 
  Please don't use the generic driver, it's slow and not the best to
  use.
 
   My usb device sending data at a rate of 409600 bytes/sec, and in 
  host
   side application I tried to read 16384 bytes in one read. But the 
  read
   size returning is always  4095
 
  The tty layer is limiting you, just keep reading in a loop until you
  run out of data, you should not ever expect to read a specific number 
  of
  bytes from a tty device at a time, the read call will tell you the
  number that was read properly.
 
  thanks,
 
  greg k-h
 
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-04 Thread arun k
I enabled software flow control like below

tty.c_iflag |= (IXON | IXOFF | IXANY);

But I still having the data loss issue.

Regards
Arun

On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley pe...@hurleysoftware.com wrote:
 On 08/03/2015 10:47 PM, arun k wrote:
 Thank you for the reply

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

 I tried this method but in my case I found data loss. By changing any buffer 
 size modification in driver side , can we fix this issue ?

 The data loss is probably occurring because you have all flow control disabled
 and the line speed is too fast for no flow control.

 Regards,
 Peter Hurley

 Please don't use the generic driver, it's slow and not the best to
 use

 Could you tell me is generic driver is suitable for my application ( My usb 
 device sending data at a rate of 409600 bytes/sec) , ?
 or do you have any other suggestion for me ?

 My Linux kernel  version is 3.4.35

 Regards,
 Arun

 On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org 
 mailto:gre...@linuxfoundation.org wrote:

 On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
  Hi ,
 
  I have a trouble with using usb serial generic device.
   I am using USB - Generic Serial driver for communicating with my usb
  device and my embedded device.

 Please don't use the generic driver, it's slow and not the best to
 use.

  My usb device sending data at a rate of 409600 bytes/sec, and in host
  side application I tried to read 16384 bytes in one read. But the read
  size returning is always  4095

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

 thanks,

 greg k-h



--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-04 Thread Peter Hurley
On 08/03/2015 10:47 PM, arun k wrote:
 Thank you for the reply
 
 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.
 
 I tried this method but in my case I found data loss. By changing any buffer 
 size modification in driver side , can we fix this issue ?

The data loss is probably occurring because you have all flow control disabled
and the line speed is too fast for no flow control.

Regards,
Peter Hurley

 Please don't use the generic driver, it's slow and not the best to
 use
 
 Could you tell me is generic driver is suitable for my application ( My usb 
 device sending data at a rate of 409600 bytes/sec) , ? 
 or do you have any other suggestion for me ?
 
 My Linux kernel  version is 3.4.35
 
 Regards,
 Arun
 
 On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org 
 mailto:gre...@linuxfoundation.org wrote:
 
 On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
  Hi ,
 
  I have a trouble with using usb serial generic device.
   I am using USB - Generic Serial driver for communicating with my usb
  device and my embedded device.
 
 Please don't use the generic driver, it's slow and not the best to
 use.
 
  My usb device sending data at a rate of 409600 bytes/sec, and in host
  side application I tried to read 16384 bytes in one read. But the read
  size returning is always  4095
 
 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.
 
 thanks,
 
 greg k-h
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-04 Thread Peter Hurley
On 08/04/2015 10:00 PM, arun k wrote:
 I enabled software flow control like below
 
 tty.c_iflag |= (IXON | IXOFF | IXANY);

Ok, but does the sending device know how to process in-band software flow 
control
and is it set up to respond properly?

Also, I doubt software flow control is going to work @ 4Mbaud line rate.
If you're stuck using software flow control, start with a 115kbaud line rate
and see if that fixes your data loss problem.

Regards,
Peter Hurley


 On Wed, Aug 5, 2015 at 12:59 AM, Peter Hurley pe...@hurleysoftware.com 
 wrote:
 On 08/03/2015 10:47 PM, arun k wrote:
 Thank you for the reply

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

 I tried this method but in my case I found data loss. By changing any 
 buffer size modification in driver side , can we fix this issue ?

 The data loss is probably occurring because you have all flow control 
 disabled
 and the line speed is too fast for no flow control.

 Regards,
 Peter Hurley

 Please don't use the generic driver, it's slow and not the best to
 use

 Could you tell me is generic driver is suitable for my application ( My usb 
 device sending data at a rate of 409600 bytes/sec) , ?
 or do you have any other suggestion for me ?

 My Linux kernel  version is 3.4.35

 Regards,
 Arun

 On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org 
 mailto:gre...@linuxfoundation.org wrote:

 On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
  Hi ,
 
  I have a trouble with using usb serial generic device.
   I am using USB - Generic Serial driver for communicating with my usb
  device and my embedded device.

 Please don't use the generic driver, it's slow and not the best to
 use.

  My usb device sending data at a rate of 409600 bytes/sec, and in host
  side application I tried to read 16384 bytes in one read. But the read
  size returning is always  4095

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

 thanks,

 greg k-h




--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-03 Thread Greg KH
On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
 Hi ,
 
 I have a trouble with using usb serial generic device.
  I am using USB - Generic Serial driver for communicating with my usb
 device and my embedded device.

Please don't use the generic driver, it's slow and not the best to
use.

 My usb device sending data at a rate of 409600 bytes/sec, and in host
 side application I tried to read 16384 bytes in one read. But the read
 size returning is always  4095

The tty layer is limiting you, just keep reading in a loop until you
run out of data, you should not ever expect to read a specific number of
bytes from a tty device at a time, the read call will tell you the
number that was read properly.

thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fwd: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-03 Thread arun k
Thank you for the reply

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

I tried this method but in my case I found data loss. By changing any
buffer size modification in driver side , can we fix this issue ?

 Please don't use the generic driver, it's slow and not the best to
 use

Could you tell me is generic driver is suitable for my application (
My usb device sending data at a rate of 409600 bytes/sec) , ?
or do you have any other suggestion for me ?

My Linux kernel  version is 3.4.35

Regards,
Arun

On Tue, Aug 4, 2015 at 1:13 AM, Greg KH gre...@linuxfoundation.org wrote:

 On Mon, Aug 03, 2015 at 04:44:07PM +0900, arun k wrote:
  Hi ,
 
  I have a trouble with using usb serial generic device.
   I am using USB - Generic Serial driver for communicating with my usb
  device and my embedded device.

 Please don't use the generic driver, it's slow and not the best to
 use.

  My usb device sending data at a rate of 409600 bytes/sec, and in host
  side application I tried to read 16384 bytes in one read. But the read
  size returning is always  4095

 The tty layer is limiting you, just keep reading in a loop until you
 run out of data, you should not ever expect to read a specific number of
 bytes from a tty device at a time, the read call will tell you the
 number that was read properly.

 thanks,

 greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-03 Thread arun k
Hi ,

I have a trouble with using usb serial generic device.
 I am using USB - Generic Serial driver for communicating with my usb
device and my embedded device.
My usb device sending data at a rate of 409600 bytes/sec, and in host
side application I tried to read 16384 bytes in one read. But the read
size returning is always  4095
I don't know whether I  missed any settings or this is limited in driver.
Could you please tell me is it possible to read large size(16384
bytes) using usb serial generic driver.

I pasted my sample code for reading from usb device

###

/*
 * usb_logger_test.c
 *
 *  Created on: Aug 3, 2015
 *  Author:
 */
#include stdio.h
#include stdlib.h
#include string.h
#include sys/types.h
#include sys/stat.h
#include fcntl.h
#include termios.h
#include unistd.h
#include errno.h
#include poll.h

#define USB_DEVICE /dev/ttyUSB0
#define DATA_SIZE (16384)
//#define DATA_SIZE (1000)

struct pollfd  fds[1];
nfds_t  nfds = 1;
int dev_fd;

void set_blocking (int should_block)
{
struct termios tty;
memset (tty, 0, sizeof tty);
if (tcgetattr (dev_fd, tty) != 0) {
printf(error %d from tggetattr, errno);
return;
}
tty.c_cc[VMIN]  = should_block ? 1 : 0;
//tty.c_cc[VTIME] = 5;// 0.5 seconds read timeout

if (tcsetattr (dev_fd, TCSANOW, tty) != 0) {
printf(error %d setting term attributes, errno);
}
}

int hal_uart_init()
{

int parity =0;
int speed = B115200;
struct termios tty;

memset ((void *)tty, 0, sizeof tty);
if (tcgetattr (dev_fd, tty) != 0) {
printf(error %d from tcgetattr, errno);
return -1;
}
cfsetospeed (tty, speed);
cfsetispeed (tty, speed);
tty.c_cflag = (tty.c_cflag  ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break
// as \000 chars
tty.c_iflag = ~IGNBRK; // disable break processing
tty.c_lflag = 0;// no signaling chars, no echo,
// no canonical processing
tty.c_oflag = 0;// no remapping, no delays
tty.c_cc[VMIN]  = 0;// read doesn't block
tty.c_cc[VTIME] = 5;// 0.5 seconds read timeout

tty.c_iflag = ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl

tty.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
tty.c_cflag = ~(PARENB | PARODD);  // shut off parity
tty.c_cflag |= parity;
tty.c_cflag = ~CSTOPB;
tty.c_cflag = ~CRTSCTS;
tty.c_iflag = ~(ICRNL | IGNCR );
if (tcsetattr (dev_fd, TCSANOW, tty) != 0) {
printf(error %d from tcsetattr, errno);
return -1;
}
set_blocking (1);

return 0;
}

int hal_uart_open()
{
dev_fd = open (USB_DEVICE,O_RDWR | O_NOCTTY | O_SYNC);
if (dev_fd  0)  {
printf (error %d opening %s: %s, errno, USB_DEVICE, strerror (errno));
return -1;
}
fds[0].fd = dev_fd; /* open fd for each filter,increment nfds */
fds[0].events = POLLIN;
fds[0].revents = 0;
nfds = 1;

return 0;
}

int hal_uart_read(unsigned char *buf, unsigned int size, unsigned int *rcv_len)
{
int ret;
unsigned int timeout = 1000;
int read_size;

ret = poll(fds[0], nfds, timeout);
if(ret = 0) {
if(ret  0) {
printf( poll err !!!   errno %d : %s !!! \n, errno, strerror(errno));
return -1;
}else {
printf( poll timeout !!! ,  timeout %d \n,  timeout);
return -1;
}
}
if(fds[0].revents  POLLIN) {
read_size = read(fds[0].fd, buf, DATA_SIZE);
if(read_size = 0) {
printf( read err !!!   read_size %d fd %d   errno %d : %s !!! \n,
read_size, fds[0].fd, timeout, errno, strerror(errno));
return -1;
}
printf(read succc read_size %d \n, read_size);
{
FILE *fp = fopen(usb_dump, ab );
if(fp != NULL) {
fwrite(buf, 1, read_size, fp);
fflush(fp);
fclose(fp);
}
}
}else {
printf(  No data read  \n);
}

return read_size;
}

void main()
{

unsigned char buf[DATA_SIZE];
unsigned int size;
unsigned int rcv_len;
int ret = 0;

ret = hal_uart_open();
if(ret  0) {
printf(hal_uart_open fail  \n);
return;
}
ret = hal_uart_init();
if(ret  0) {
printf(hal_uart_init fail  \n);
return;
}

while(1) {
hal_uart_read(buf[0], size, rcv_len);
//usleep(40);
usleep(4);
//sleep(10);
//sleep(11);
}
}

Regards,
Arun
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB - Generic Serial device : Unable to read more than 4095 bytes

2015-08-03 Thread Peter Hurley
On 08/03/2015 03:44 AM, arun k wrote:
 Hi ,
 
 I have a trouble with using usb serial generic device.
  I am using USB - Generic Serial driver for communicating with my usb
 device and my embedded device.
 My usb device sending data at a rate of 409600 bytes/sec, and in host
 side application I tried to read 16384 bytes in one read. But the read
 size returning is always  4095
 I don't know whether I  missed any settings or this is limited in driver.
 Could you please tell me is it possible to read large size(16384
 bytes) using usb serial generic driver.

read() is limited to 4096 bytes by the driver.

What linux version are you using?

Regards,
Peter Hurley
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html