Richard | 6 Aug 2008 13:21
Picon
Favicon

remove usb drive too early

Hi,

I do a file copy to a usb drive from a c++ program. After the file
copy call I do a crc check of the file which is ok.
After this the led of the usb drive is still flashing for a few
seconds.
When I remove the usb drive too early after the file copy some data is
lost.

When I do a crc check I expect all the data is on the usb drive. Can
anybody tell me what happens?

Thanks,
Richard

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
David Novak | 6 Aug 2008 15:07
Favicon

remove usb drive too early

It takes some time to program the flash, so I expect that the data is
buffered. When you perform the CRC check, you are actually checking the
buffered data and not the data that has been written to the flash. The flash
write is in process while the led flashes. Therefore, if you unplug while
the led is flashing, it won't be able to finish the write.

Be careful, if the write can't finish, the file you are writing may be
corrupt, but it is also possible that the file system on the usb drive will
become corrupt.

David

> -----Original Message-----
> From: Richard [mailto:richi_8 <at> hotmail.com] 
> Sent: Wednesday, August 06, 2008 7:22 AM
> To: libusb-win32-devel <at> lists.sourceforge.net
> Subject: [Libusb-win32-devel] remove usb drive too early
> 
> Hi,
> 
> I do a file copy to a usb drive from a c++ program. After the file
> copy call I do a crc check of the file which is ok.
> After this the led of the usb drive is still flashing for a few
> seconds.
> When I remove the usb drive too early after the file copy some data is
> lost.
> 
> When I do a crc check I expect all the data is on the usb drive. Can
> anybody tell me what happens?
> 
(Continue reading)

neil scales | 6 Aug 2008 17:12

Re: remove usb drive too early

On Windows it is possible to tell the OS not to cache file writes.

If you are using CreateFile then setting the dwFlagsAndAttributes parameter to FILE_FLAG_WRITE_THROUGH|FILE_FLAG_NO_BUFFERING can disable caching.

See: http://msdn.microsoft.com/en-us/library/aa363858.aspx#caching_behavior

If you are using fopen to create the file then just add "c" to the attribute

i.e. fopen(fname, "wbc");

Enable the commit flag for the associated filename so that the contents of the file buffer are written directly to disk if either fflush or _flushall is called.

Neil


2008/8/6 David Novak <novakd <at> dajac.com>
It takes some time to program the flash, so I expect that the data is
buffered. When you perform the CRC check, you are actually checking the
buffered data and not the data that has been written to the flash. The flash
write is in process while the led flashes. Therefore, if you unplug while
the led is flashing, it won't be able to finish the write.

Be careful, if the write can't finish, the file you are writing may be
corrupt, but it is also possible that the file system on the usb drive will
become corrupt.

David


> -----Original Message-----
> From: Richard [mailto:richi_8 <at> hotmail.com]
> Sent: Wednesday, August 06, 2008 7:22 AM
> To: libusb-win32-devel <at> lists.sourceforge.net
> Subject: [Libusb-win32-devel] remove usb drive too early
>
> Hi,
>
> I do a file copy to a usb drive from a c++ program. After the file
> copy call I do a crc check of the file which is ok.
> After this the led of the usb drive is still flashing for a few
> seconds.
> When I remove the usb drive too early after the file copy some data is
> lost.
>
> When I do a crc check I expect all the data is on the usb drive. Can
> anybody tell me what happens?
>
>
> Thanks,
> Richard
>
>
>
>
> --------------------------------------------------------------
> -----------
> This SF.Net email is sponsored by the Moblin Your Move
> Developer's challenge
> Build the coolest Linux based applications with Moblin SDK &
> win great prizes
> Grand prize is a trip for two to an Open Source event
> anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Libusb-win32-devel mailing list
> Libusb-win32-devel <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Taimoor Mirza | 7 Aug 2008 10:20
Picon
Favicon

winusb Vs Libusb

Hi all,
 
Can you people Tell me relaTion b/w WinUSB and LibUSB-Win32?
 

If WinUSB also provides a user mode API for applications to communicate with USB devices then what’s the difference between them?

 

Why should I use LibUSB-Win32 and not WinUSB?

 
 
-Taimoor

Connect to the next generation of MSN Messenger  Get it now!
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Xiaofan Chen | 7 Aug 2008 10:41
Picon

Re: winusb Vs Libusb

On Thu, Aug 7, 2008 at 4:20 PM, Taimoor Mirza <mooni_mirza <at> hotmail.com> wrote:

> Can you people Tell me relaTion b/w WinUSB and LibUSB-Win32?
>
> If WinUSB also provides a user mode API for applications to communicate with
> USB devices then what's the difference between them?
>
> Why should I use LibUSB-Win32 and not WinUSB?

WinUSB does not support isochronous transfer, only works under
Windows XP and Vista 32/64, not Windows 2000.

libusb-win32 supports isochronous transfer, works under
Windows 2000, XP and Vista 32. It is also compatible in the
API level with libusb under Linux/Mac OS X/BSDs so you
can write cross-platform applications.

The upcoming libusb-win32 1.0 (not so sure how soon it will
come) will have WinUSB as one possible backend, along
with libusb-win32 device driver and HID.

Xiaofan
http://mcuee.blogspot.com

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Javier Fileiv | 19 Aug 2008 03:42
Picon
Favicon

Help with HID

I need to do an application that use only an HID device. I'm looking for a
kind of tutorial to install and use the libusb in windows Xp and I can't
find it. How can i use it?  Can we help me with some web address or
something  like that??Any idea??
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Taimoor Mirza | 19 Aug 2008 08:24
Picon
Favicon

USB packet sender utility

Hi all,
 
Is there any software utility that I can use to send USB packets (Data/Control) to any USB device plugged in my EHCI controller?
 
-Taimoor

Connect to the next generation of MSN Messenger  Get it now!
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Chaitanya Joshi | 20 Aug 2008 09:28
Picon

FW: Bulk read write in libusb-win 0.1.12.1

 

Hello,

 

            I am testing libusb-win with intention to use it with USB Mass Storage Flash Drives. I had downloaded the source and compiled it with DDK. I also succeeded in installing driver for my flash drive. The next thing I wanted to do is to test its data transfer features and capacity. While looking for some example, I got your bulk read/write transfer program. So I took it and run it with VS 2005 environment. I have also turned on debug output for program. But somehow it is failing.

 

            The typical output is

 

>LIBUSB_DLL: info: usb_os_init: dll version: 0.1.12.1

>LIBUSB_DLL: info: usb_os_init: driver version: 0.1.12.1

>LIBUSB_DLL: info: usb_os_find_busses: found bus-0

>LIBUSB_DLL: info: usb_os_find_devices: found \\.\libusb0-0001--0x058f-0x6387 on

>bus-0

>Found and opened the device

>LIBUSB_DLL: error: usb_reap: reaping request failed, win error: A device attached to the system is not functioning.

>

 

>error: bulk read failed

 

When I checked through device manager, it shows the device under libusb-win32 devices as USB Drive which I had installed the driver for. The test utility that comes with the source also works with the same setup. So what can be problem??

 

Thanks for your time, in advance.

 

Regards,

 

Chaitanya Joshi

 

P.S.: I have attached my code file as well.

// TestReadWrite.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "usb.h"

/* the device's vendor and product id */
#define MY_VID 0x058F
#define MY_PID 0x6387

/* the device's endpoints */
#define EP_IN 0x82
#define EP_OUT 0x01

#define BUF_SIZE 64

usb_dev_handle *open_dev(void);

usb_dev_handle *open_dev(void)
{
  struct usb_bus *bus;
  struct usb_device *dev;

  for(bus = usb_get_busses(); bus; bus = bus->next) 
    {
      for(dev = bus->devices; dev; dev = dev->next) 
        {
          if(dev->descriptor.idVendor == MY_VID
             && dev->descriptor.idProduct == MY_PID)
            {
				printf("Found and opened the device\n");
              return usb_open(dev);
            }
        }
    }
  return NULL;
}

int _tmain(int argc, _TCHAR* argv[])
{
	usb_set_debug(255);
	usb_dev_handle *dev = NULL; /* the device handle */
	char tmp[BUF_SIZE];

	usb_init(); /* initialize the library */
	usb_find_busses(); /* find all busses */
	usb_find_devices(); /* find all connected devices */

	if(!(dev = open_dev()))
	{
	  printf("error: device not found!\n");
	  return 0;
	}

	if(usb_set_configuration(dev, 1) < 0)
	{
	  printf("error: setting config 1 failed\n");
	  usb_close(dev);
	  return 0;
	}

	if(usb_claim_interface(dev, 0) < 0)
	{
	  printf("error: claiming interface 0 failed\n");
	  usb_close(dev);
	  return 0;
	}

	if(usb_bulk_write(dev, EP_OUT, tmp, sizeof(tmp), 5000) 
	 != sizeof(tmp))
	{
	  printf("error: bulk write failed\n");
	}

	if(usb_bulk_read(dev, EP_IN, tmp, sizeof(tmp), 5000) 
	 != sizeof(tmp))
	{
	  printf("error: bulk read failed\n");
	}

	usb_release_interface(dev, 0);
	usb_close(dev);

	return 0;
}

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel

Gmane