USB Scanner using SANE

Has anyone been able to get a USB Scanner to work with either an Ultra 5/10 or the SunBlades, or other Sun hardware under Solaris 8 or 9? I'm trying to get the SANE backends to work with my Ultra 10 which has a generic USB card installed. The main problem is that there appears to be no device driver for a USB scanner, so no device such as /dev/usb/scanner0 is being created. I have other working USB devices such as a USB hub, a HP printer, and a memory key storage device that are recognized as /dev/usb/hub0, /dev/usb/printer0, & /dev/usb/storage0, respectively. The system does see this USB scanner at boot time as it complains there is no device driver for it.
Thanks for any help given,
Matt Evans

Hi,
I want to use sane on solaris 9 with a fujitsu ScanPartner 620C.
I've already installed sane and changed /kernel/drv/sgen.conf. When I run sane-find-scanner, the following appears:
found SCSI scanner "FCPA ScanPartner 620C 2.02" at /dev/scsi/scanner/c1t4d0
# Your SCSI scanner was detected. It may or may not be supported by SANE. Try
# scanimage -L and read the backend's manpage.
# No USB scanners found. If you expected something different, make sure that
# you have loaded a driver for your USB host controller and have installed a
# kernel scanner module.
# Not checking for parallel port scanners.
# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.
but when I run scanimage -L, the following error occurs:
No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).
May you help-me with this problem?
tks,
Luis Falcao
([email protected])

Similar Messages

  • My Aztec 1236 USB scanner stumped Tiger.

    Hi. I bought an Aztec 1236 USB scanner used for five bucks. It came with nothing. I was lucky enough to find the model number. It's vintage but the price fit my post-buying-a-mac budget.
    I managed to dig up a Win XP driver for it w/ the accompanying photoshop bits (not a plugin, actually had an installer). The scanner works slow, but fine. But I want my PC free to do other things.
    But Tiger can't see it when I plug it in, let alone know what to do with it. I tried the Image Capture device browser TWAIN trick--and it ain't showing. I can't find a Mac OS X driver for it anywhere, not even w/ Google.
    Anybody know how I can save the hundred bucks and avoid buying a new scanner? Anybody found a Tiger driver for my classy, antique flatbed?

    I don't know where you get your information but Apple doesn't claim "it just works with everything." No computer can truly make that claim. Apple does, however, provide a list of known compatible devices. Consulting this available information would help you avoid making a mistake by purchasing incompatible hardware.
    It's up to the peripheral manufacturer to make compatible drivers. If your scanner doesn't work on a Mac then the problem is with its manufacturer not with Apple.
    You purchased a cheap used scanner without knowing in advance whether a driver would be available for the Mac. This is your oversight. Ranting at Apple (which, btw, is not appropriate here) is simply trying to shift the blame from where it really lies.

  • How to use SANE / USB scanners on Solaris 10?

    I would like to use a SANE-enabled USB scanner (Mustek BearPaw 1200F) on Solaris 10, but haven't yet managed to make it work.
    I gather that on Solaris 10, there's a "libusb" library in "/opt/sfw/lib" and a "sane-find-scanner" program in "/opt/sfw/bin", that seems to look for USB scanners. It finds the "libusb", but doesn't find my scanner.
    My scanner is on a USB hub connected to a USB port on the mainboard. The "usba" driver is running, and other USB devices seem to work.
    I looked on the Internet and found some descriptions using the "ugen" kernel driver. I added a driver descriptor for the interface node that I suspected to be the scanner, and indeed, dmesg and prtconf report a valid "ugen0" device, and ugen creates various driver nodes for the USB interface node.
    But how do I go from there? I have not the slightest clue.

    This is a real old post, however I got a very similar scanner (Mustek 1200 UB) which I got working on Solaris 10, so I thought I'd list what I did in order to get it to work (I also managed to get an Epson Perfection 1250 to work using the same method). I used the sane packages available on the Solaris companion cd, and installed them prior to getting started. So, first off we need to see if Solaris is recognizing the scanner so in a terminal as root (su -) :
    prtconf -D -v
    you'll be looking for some reference to usb,device and note the value (I had to modify the profile of the terminal for scrolling from 500 lines to 2000 in order to see it). The value of the Mustek 1200 UB was usb55f,6.100
    next we need to remove the old usb driver:
    rem_drv ugen
    now we'll add the driver with the Mustek values:
    add_drv -i 'usb55f,6.100' ugen
    now we want to ensure that there was an new entry created in /etc/driver_aliases for ugen with the Musktek info (note you need to ensure that " 's are used, for example, so you will need to edit the file. Example: ugen "usb55f,6.100"
    Now we need to make a link from the Mustek to /dev/usbscanner (since sane uses either /dev/usbscanner or dev/usb/scanner), So:
    ln -s /dev/usb/55f.6/0 /dev/usbscanner
    then reboot the machine
    Once rebooted in a terminal as root as root (su -):
    /opt/sfw/bin/sane-find-scanner
    you should see a reference to found usb scanner (vendor=0x055f, product=0x0006, chip=MA-1017) at libusb:/dev/usb:55f.6/0
    you can then confirm it by :
    /opt/sfw/bin/scanimage -L
    you'll see a reference device 'mustek_usb:libusb:/dev/usb:55f.6/0' is a Mustek 1200 UB flatbed scanner
    Finally it's time to do a test scan, so:
    /opt/sfw/bin/xscanimage
    I really suggest using xscanimage on the Mustek, as just using scanimage will give you a high pitch squealing noise. xscanimage does not. Also be advised that if you close xscanimage and then try to scan again, you get an i/o error. The solution to that is to simply hotplug the Mustek, by unplugging it from the usb port and plugging it back in.
    Hope this helps some folks out.
    Message was edited by:
    mrmdls
    corrected line concerning ad_drv ugen, as I had written the value for an epson 1250 scanner

  • Using usb scanner DSmobile 620

    I would like to utilize a Brother DSmobile 620 document scanner in Xfce 4.10. To that end, I downloaded the manufacturer's drivers as rpm, extracted via rpmextract.sh and copied the driver files to the respective root directories (etc, lib, usr). Thereafter, I installed sane 1.0.24. Upon plugging in the scanner, it is not recognized by sane.
    lsusb | grep Brother
    Bus 001 Device 004: ID 04f9:60e0 Brother Industries, Ltd
    sudo sane-find-scanner\
    # No USB scanners found. If you expected something different, make sure that
    # you have loaded a kernel driver for your USB host controller and have setup
    # the USB system correctly. See man sane-usb for details.
    scanimage -L
    # Only the webcam is identified
    Any suggestions on getting this usb scanner to work?

    Hi,
    I want to use sane on solaris 9 with a fujitsu ScanPartner 620C.
    I've already installed sane and changed /kernel/drv/sgen.conf. When I run sane-find-scanner, the following appears:
    found SCSI scanner "FCPA ScanPartner 620C 2.02" at /dev/scsi/scanner/c1t4d0
    # Your SCSI scanner was detected. It may or may not be supported by SANE. Try
    # scanimage -L and read the backend's manpage.
    # No USB scanners found. If you expected something different, make sure that
    # you have loaded a driver for your USB host controller and have installed a
    # kernel scanner module.
    # Not checking for parallel port scanners.
    # Most Scanners connected to the parallel port or other proprietary ports
    # can't be detected by this program.
    but when I run scanimage -L, the following error occurs:
    No scanners were identified. If you were expecting something different,
    check that the scanner is plugged in, turned on and detected by the
    sane-find-scanner tool (if appropriate). Please read the documentation
    which came with this software (README, FAQ, manpages).
    May you help-me with this problem?
    tks,
    Luis Falcao
    ([email protected])

  • Setting permissions for scanner use

    Hello,
    My USB scanner is a Canon Lide 35 and it had been working perfectly in arch. After  a recent update (don't know exactly which because do not use scanner so often), the device is detected and device is set in /dev/bus/usb/005/00x. The problem is that the permissions are not set correctly, I assume by udev?, and my normal user cannot use the scanner because the device remains as owned by root.root and not 0664, group=scanner, as specified in the sane udev rules (/etc/udev/rules.d/53-sane.rules). The rules file is with the new syntax, i.e., ATTRS instead of SYSFS and so forth. My user belongs to the "scanner" group. I have the feeling it is something related with the udev rules but Im not sure what. Here is the relevant line:
    # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50
    ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2213", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
    The latest update where kernel stuff and udev stuff were updated resulted in:
    kernel-headers-2.6.24.3-1  udev-119-1...
    Any help greatly appreciated,
    Regards,
    Felipe.

    It appears that udev has problems with rules matching by idVendor when system is up and running but everything is ok if device was online during boot. Please check out this bug http://bugs.archlinux.org/task/9935 and comments. If You have the same problem then please vote for this bug and/or post a comment.
    Thank You.

  • USB scanner permissions

    Okay, I'm totally confused.
    I have a Canon Lide-30 USB scanner which I have used under Arch Linux many times--but not for 2 or 3 months. However, I was never able to configure hotplug to set the permissions automatically; I always had to become root and manually set the permissions in order to access the scanner as a regular user. Now, of course, the devices are all different (I mostly keep up with the latest release, don't really use testing packages, so I now have kernel 2.6.14).
    Here's what's happening:
    I plugged in the scanner's USB cable after booting (my machine's been up continuously for a few days, so I would have to shut down to do otherwise).
    Loaded the uhci-hcd module ... now /proc/bus/usb is mounted, and it contains a node for my scanner.
    Run sane-find-scanner as root:
    found USB scanner (vendor=0x04a9 [Canon], product=0x220e [CanoScan], chip=LM9832/3) at libusb:001:002
    Run sane-find-scanner as myself: same as above
    Run xsane as root: OK.
    Run xsane as myself: No devices found.
    # chmod 777 /dev/usbdev1.2 (which I think represents the scanner)
    # chmod 777 /dev/usbdev1.1
    # chmod 777 /proc/bus/usb/001/002
    # chmod 777 /proc/bus/usb/001/001
    No change. I still can't access the scanner as myself.
    By the way, it appears that the hotplug daemon won't start, though I'm not quite sure why. There are no files in /var/log/hotplug. In /var/log/errors, I see
        DEVPATH is not set (subsystem pci)
    But according to a brief Google search, this is not a serious problem.
    So what's the magic formula?

    Have you read this?

  • Visioneer 7100 USB Scanner --- Need driver

    As the subject states, I need a driver for the Visioneer 7100 USB scanner. I just bought my first Mac this month, the 20" imac, and now I'm trying to hook everything together. The system profile scans the USB ports and find the Visioneer scanner. But when I use Vuescan or other software applications to use the scanner, the application comes back with scanner not found. Visioneer does not have a Mac driver. SANE shows the scanner as unsupported. I've done some searching on the internet but still am not having any luck. The kind people at Apple Help tried, but could not help and directed me to this forum. Any help would be greatly appreciated.
    THX

    1. The Visioneer 7100 is NOT supported by VueScan.
    http://www.hamrick.com/vuescan/vuescan.htm#visioneer
    2. Visioneer says: "This product is classified as END OF LIFE."
    3. The last update to the "OneTouch 7100 Scanner Installation and Configuration Guide" was over 7 years ago on April 16, 2002.
    http://support.visioneer.com/products/7100/downloads.asp
    4. I think you need to buy a new scanner. The Visioneer 9520 is $90 USD. But, it is not supported by VueScan.
    5. I would spend some time reading the posts in http://discussions.apple.com/forum.jspa?forumID=1344 to get an idea of what would be a good scanner to buy.
    6. I really like our MicroTek scanner, but certainly could not recommend it: http://www.microtekusa.com/
    7. You might want to consider a used scanner that is supported by VueScan.

  • Usb scanner with root permissions only

    Hello
    When I open xsane with regular a user, the scanner does not get detected by it. Only when I open xsane as root.
    That's probably a permission issue. My user is added to the scanner group.
    How would I correct this?
    Thanks

    brebs wrote:
    Write a udev rule to identify the scanner and give it the right user group & permissions. Google search is your friend
    Just to confuse the hell out of us, different distros use different group names. Some have "scanner", some use "usb", some don't even have "usb".
    Example:  In /etc/udev/rules.d/91-local.rules
    # Scanner.
    # sane-find-scanner ; scanimage -L
    # From http://forums.gentoo.org/viewtopic-p-33 … ml#3311185
    # udevadm info -a --name /dev/usbdev5.3_ep00
    # "libusb:003:015" probably means /dev/bus/usb/003/015
    SUBSYSTEM=="usb", ATTRS{product}=="CanoScan", GROUP="usb", MODE="0660", SYMLINK+="lide25"
    I googled it quite a bit to find out this process is rather difficult for newbies. I even read udev wiki but I can't come up with a rule myself. The gentoo forum post you referenced has udevinfo command while it has been replaced with udevadm and the script wouldn't work.
    Would you give me more directions?
    Here's the output of sane-find-scanner as root.
    [root@myhost ~]# sane-find-scanner
    found USB scanner (vendor=0x03f0 [HP], product=0x2504 [Deskjet F4200 series]) at libusb:001:004
    found USB scanner (vendor=0x050d [Belkin], product=0x705c [USB2.0 WLAN]) at libusb:001:003
    [root@myhost ~]# scanimage -L
    device `hpaio:/usb/Deskjet_F4200_series?serial=CN83I3Y197052D' is a Hewlett-Packard Deskjet_F4200_series all-in-one
    device `v4l:/dev/video0' is a Noname Kworld ATSC110/115 virtual device
    [root@myhost ~]#
    I understand the device would be 001:004, but how would I write a rule for it?
    Thanks

  • USB Scanner Permissions without hotplug

    After getting rid of hotplug, the permissions for my usb scanner aren't set to scanner:root anymore. Udev is supposed to take care of everything hotplug used to do, but it doesn't seem to do this automatically. Could anyone explain how I can make udev set the permissions correctly for my usb scanner?

    Oh, I'm sorry, I forgot I had made my own sane-package, since a former version broke the support for my scanner (Epson CX3200), but that's fixed now. I updated Sane, and everything works. (Still, I have to replug the scanner after booting, for the permissions to get set, though)

  • Remote Desktop and remote USB scanner

    Hello, We currently use NeatWorks to scan our company receipts and docs. Several of our employees access the NeatWorks database remotely, via a locally installed NeatWorks application, the connection we use to the file is the simple Finder 'Connect to Server'. Because NeatWorks is not networkable, we access it one at a time.
    The problem is the Neatworks database is huge, it can take 20 minutes to load remotely.
    Our solution to this would be to use Remote Desktop to access our server that has the application and database for a quick load. The problem is scanning.
    Can Remote Desktop connect to the users local USB scanner so that the scans go directly to the remote database? If not, is there any other elegant solution to this remote scan problem?
    We were hoping to find a networkable program to replace NeatWorks that wouldn't load the entire database, just an index perhaps.
    Thanks a million for any input!
    John

    Can the NeatWorks application on the server, see, connect to the USB scanner device on the user end.
    That would not be a function of Apple Remote Desktop. The NeatWorks software would need to have code to access a remote scanner, either natively or using the Scanner Sharing feature of Mac OS X 10.6 (if that will support the USB scanner you're using).

  • USB scanner problems - it's there, then it's gone

    Ok, I've seen this problem on other distros too, so Arch must have something in common with them, but I'm on Arch right now, so I'll try my luck here.
    I have a Fujitsu USB scanner, sane installed, udev scanner rules file installed.  My user is in the scanner and wheel groups.
    lsusb finds it fine: Bus 004 Device 010: ID 04c5:10cf Fujitsu, Ltd
    USB device looks right: crw-rw-r--+ 1 root scanner 189, 392 Oct  9 15:33 ./bus/usb/004/010
    sane-find-scanner finds it fine: found USB scanner (vendor=0x04c5, product=0x10cf) at libusb:004:010
    "scanimage -L" works just fine the first time: device `fujitsu:libusb:004:010' is a FUJITSU fi-4340Cd scanner
    But only that time, then it fails to find one.  If I strace the scanimage binary, it shows me where it's failing: ioctl(12, USBDEVFS_SETCONFIGURATION, 0x7fff94199eac) = -1 ETIMEDOUT (Connection timed out)
    When it works the first time, that line of the strace output looks like this: ioctl(12, USBDEVFS_SETCONFIGURATION, 0x7fffc564cb3c) = 0
    I even tried compiling libusb 1.0 into /opt/libusb and pointed sane at it, but same problem.  I'm starting to think it's a kernel problem.
    Ideas?

    BTW, this is on a fresh install of Arch done yesterday: Linux groovy9 3.11.4-1-ARCH #1 SMP PREEMPT Sat Oct 5 21:22:51 CEST 2013 x86_64 GNU/Linux
    For a plan B, if there's a straightforward way to custom compile my own kernel, I'd like to try a slightly older one to see if I have better luck.  This same model of scanner is working fine on a 3.5 kernel, for example.
    Last edited by groovy9 (2013-10-09 21:34:22)

  • Canon USB scanner

    I thought macs were supposed to just work with stuff like scanners.
    I have a Canon CanoScan N670U USB scanner and I plugged it into the Mac and nothing. It is supposed to get its power from the mac as well so its not lighting up or anything.
    I've tried the USB ports on the rear and the one on the keyboard and no difference.
    I also checked the Canon site for drivers for OS X but nothing stands out.
    Any ideas?

    That's right. the USB port on the keyboard is a secondary port that gets less power than the one directly on the computer. I've experienced this when using some types of USB flash memory pens. Some of them don't work when plugged into the keyboard but work fine plugged into the computer.
    Your scanner won't work at all unless you have downloaded and installed the latest drivers for your particular model, from the Canon website. I have to say Canon (unlike Epson) have been very good at updating all their drivers for the latest version of OSX including Intel.
    The one problem is that the Canon website is a bit of a labyrinth. You have to find your way through it until you've found EXACTLY the drivers you need for your particular model of scanner, in the correct language.
    You may then find that there are actually TWO components you need to download: one to drive the scanner itself, and another to use it (this is called Canoscan Toolbox, or something like that). You'll need to install both.
    Once you've done that you should be fine. Rather than low-powered USB sockets it's likely that you need these updated drivers.

  • USB Scanner eject operation?

    Hello
    Sorry I'm newbie and don't know if We need to make any operation on Mac OSX before unplug a USB SCANNER...
    Could we simply disconnect the USB plug ? Is ther any mounting/unmounting process like pendrives?
    Thank you.

    Hi Kappy and eww, thanks for your replies!
    I need to hot-swap USB devices, without turn-off my MBP everytime and I don't know if this procedure will damage both sides if I repeat every time.
    For example, mouses aren't powered devices then I imagine it's ok to hot-swap.
    I made the same question to HP (I use HP 3570c scanner) and I'm waiting their answer.
    I like Apple Discussions because seems so friendly geek lounge! Congratulations for all members!

  • Not able to create More than 1 Partition in USB Drive using kernel32 and DeviceIoControl

    I have successfully created 2 or more partitions in USB drive using DeviceIoControl in C++. Now I am trying to convert this code into C# using kernel32 and DeviceIoControl. But I am not getting more than 1 partition. Can anybody tell me what is wrong
    with this code?
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    namespace PartitionWrapper
    public class IOWrapper
    public static bool CreatePartitions(string selectedDrive)
    bool RetCode = false;
    try
    bool bSuccess = false;
    uint dwBytesReturned = 0;
    IntPtr hDisk = OpenVolume(selectedDrive);
    if (hDisk == null || hDisk == FSConstants.INVALID_HANDLE_VALUE)
    RetCode = false;
    goto FINAL;
    bSuccess = FSStructures.DeviceIoControl(hDisk, FSConstants.IOCTL_DISK_DELETE_DRIVE_LAYOUT, IntPtr.Zero, 0, default(IntPtr), default(uint), ref dwBytesReturned);
    // Get the partition information
    uint PartitionInfomations = (uint)(Marshal.SizeOf(typeof(FSStructures.DRIVE_LAYOUT_INFORMATION_EX)) + 3 * Marshal.SizeOf(typeof(FSStructures.PARTITION_INFORMATION_EX)));
    byte[] DBuffer = new byte[PartitionInfomations];
    GCHandle handle = GCHandle.Alloc(DBuffer, GCHandleType.Pinned);
    FSStructures.DRIVE_LAYOUT_INFORMATION_EX pDriveLayout = (FSStructures.DRIVE_LAYOUT_INFORMATION_EX)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(FSStructures.DRIVE_LAYOUT_INFORMATION_EX));
    IntPtr pDriveLayoutPtr = Marshal.AllocHGlobal(Marshal.SizeOf(pDriveLayout));
    Marshal.StructureToPtr(pDriveLayout, pDriveLayoutPtr, false);
    // bSuccess = FSStructures.DeviceIoControl(hDisk, FSConstants.IOCTL_DISK_GET_DRIVE_LAYOUT_EX, default(IntPtr), default(uint), pDriveLayoutPtr, PartitionInfomations, ref dwBytesReturned);
    pDriveLayout = (FSStructures.DRIVE_LAYOUT_INFORMATION_EX)Marshal.PtrToStructure(pDriveLayoutPtr, typeof(FSStructures.DRIVE_LAYOUT_INFORMATION_EX));
    if (bSuccess || dwBytesReturned != PartitionInfomations)
    RetCode = true;
    else { RetCode = false; goto FINAL; }
    pDriveLayout.PartitionEntry = new FSStructures.PARTITION_INFORMATION_EX[0x16];
    pDriveLayout.PartitionStyle = FSStructures.PARTITION_STYLE.MasterBootRecord;
    pDriveLayout.PartitionCount = 4;
    pDriveLayout.DriveLayoutInformatiton.Mbr.Signature = 0xA4B57300;
    pDriveLayout.PartitionEntry[0] = new FSStructures.PARTITION_INFORMATION_EX();
    pDriveLayout.PartitionEntry[0].PartitionStyle = FSStructures.PARTITION_STYLE.MasterBootRecord;
    pDriveLayout.PartitionEntry[0].Mbr.BootIndicator = true;
    pDriveLayout.PartitionEntry[0].Mbr.RecognizedPartition = true;
    pDriveLayout.PartitionEntry[0].Mbr.PartitionType = 0x0B;
    pDriveLayout.PartitionEntry[0].PartitionNumber = 1;
    pDriveLayout.PartitionEntry[0].StartingOffset = 32256;
    pDriveLayout.PartitionEntry[0].PartitionLength = 3221225472;
    pDriveLayout.PartitionEntry[0].RewritePartition = true;
    pDriveLayout.PartitionEntry[0].Mbr.HiddenSectors = 32256 / 512;
    pDriveLayout.PartitionEntry[1] = new FSStructures.PARTITION_INFORMATION_EX();
    pDriveLayout.PartitionEntry[1].PartitionStyle = FSStructures.PARTITION_STYLE.MasterBootRecord;
    pDriveLayout.PartitionEntry[1].Mbr.BootIndicator = false;
    pDriveLayout.PartitionEntry[1].Mbr.RecognizedPartition = true;
    pDriveLayout.PartitionEntry[1].Mbr.PartitionType = 0x0B;
    pDriveLayout.PartitionEntry[1].PartitionNumber = 2;
    pDriveLayout.PartitionEntry[1].StartingOffset = 32256 + 3221225472;
    pDriveLayout.PartitionEntry[1].PartitionLength = 2147483648; //2147483648;//3221225472;
    pDriveLayout.PartitionEntry[1].RewritePartition = true;
    pDriveLayout.PartitionEntry[1].Mbr.HiddenSectors = 32256 / 512;
    for (int i = 0; i < pDriveLayout.PartitionEntry.Length; i++)
    pDriveLayout.PartitionEntry[i].RewritePartition = true;
    try
    bSuccess = FSStructures.DeviceIoControl(hDisk, FSConstants.IOCTL_DISK_SET_DRIVE_LAYOUT_EX, ref pDriveLayout, PartitionInfomations, default(IntPtr), default(uint), ref dwBytesReturned);
    catch (Exception ex)
    if (bSuccess)
    RetCode = true;
    else { RetCode = false; }
    bSuccess = FSStructures.DeviceIoControl(hDisk, FSConstants.IOCTL_DISK_UPDATE_PROPERTIES, IntPtr.Zero, 0, default(IntPtr), default(uint), ref dwBytesReturned);
    if (bSuccess)
    RetCode = true;
    else { RetCode = false; }
    FINAL:
    // Close the disk handle.
    if (hDisk != null && hDisk != FSConstants.INVALID_HANDLE_VALUE)
    FSStructures.CloseHandle(hDisk);
    catch { return false; }
    return RetCode;
    private static IntPtr OpenVolume(string DeviceName)
    try
    IntPtr hDevice;
    hDevice = FSStructures.CreateFile(
    @"\\.\" + DeviceName,
    FSConstants.GENERIC_EXECUTE | FSConstants.GENERIC_READ | FSConstants.GENERIC_WRITE | FSConstants.FILE_SHARE_READ | FSConstants.FILE_SHARE_WRITE,
    FSConstants.FILE_SHARE_WRITE,
    IntPtr.Zero,
    FSConstants.OPEN_EXISTING,
    0,
    IntPtr.Zero);
    if ((int)hDevice == -1)
    throw new Exception(Marshal.GetLastWin32Error().ToString());
    return hDevice;
    catch { return FSConstants.INVALID_HANDLE_VALUE; }
    internal static class FSConstants
    public const uint FILE_SHARE_READ = 0x00000001;
    public const uint FILE_SHARE_WRITE = 0x00000002;
    public const uint OPEN_EXISTING = 3;
    public const int GENERIC_EXECUTE = 0x10000000;
    public const uint GENERIC_READ = (0x80000000);
    public const uint GENERIC_WRITE = (0x40000000);
    public static IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
    public const uint IOCTL_DISK_GET_DRIVE_LAYOUT_EX = 0x00070050;
    public const uint IOCTL_DISK_SET_DRIVE_LAYOUT_EX = 0x7C054;
    public const int IOCTL_DISK_UPDATE_PROPERTIES = 0x70140;
    public const int IOCTL_DISK_DELETE_DRIVE_LAYOUT = 0x0007c010;
    public const int IOCTL_DISK_CREATE_DISK = 0x7C058;
    internal static class FSStructures
    [DllImport("kernel32.dll", EntryPoint = "CreateFile", SetLastError = true)]
    public static extern IntPtr CreateFile(
    string lpFileName,
    uint dwDesiredAccess,
    uint dwShareMode,
    IntPtr lpSecurityAttributes,
    uint dwCreationDisposition,
    uint dwFlagsAndAttributes,
    IntPtr hTemplateFile);
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern int CloseHandle(IntPtr hObject);
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool DeviceIoControl(
    IntPtr hDevice,
    uint dwIoControlCode,
    [Optional]ref DRIVE_LAYOUT_INFORMATION_EX lpInBuffer,
    uint nInBufferSize,
    [Optional] [Out] IntPtr lpOutBuffer,
    uint nOutBufferSize,
    [Optional] ref uint lpBytesReturned,
    [Optional] IntPtr lpOverlapped);
    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool DeviceIoControl(
    IntPtr hDevice,
    uint dwIoControlCode,
    IntPtr lpInBuffer,
    uint nInBufferSize,
    [Optional] [Out] IntPtr lpOutBuffer,
    uint nOutBufferSize,
    [Optional] ref uint lpBytesReturned,
    [Optional] IntPtr lpOverlapped);
    [StructLayout(LayoutKind.Sequential)]
    public struct DRIVE_LAYOUT_INFORMATION_EX
    public PARTITION_STYLE PartitionStyle;
    public int PartitionCount;
    public DRIVE_LAYOUT_INFORMATION_UNION DriveLayoutInformatiton;
    [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = 0x16)]
    public PARTITION_INFORMATION_EX[] PartitionEntry;
    [StructLayout(LayoutKind.Sequential)]
    public struct PARTITION_INFORMATION_EX
    [MarshalAs(UnmanagedType.U4)]
    public PARTITION_STYLE PartitionStyle;
    public long StartingOffset;
    public long PartitionLength;
    public int PartitionNumber;
    public bool RewritePartition;
    public PARTITION_INFORMATION_MBR Mbr;
    public PARTITION_INFORMATION_GPT Gpt;
    [StructLayout(LayoutKind.Sequential)]
    public struct PARTITION_INFORMATION_MBR
    public byte PartitionType;
    [MarshalAs(UnmanagedType.U1)]
    public bool BootIndicator;
    [MarshalAs(UnmanagedType.U1)]
    public bool RecognizedPartition;
    public uint HiddenSectors;
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct PARTITION_INFORMATION_GPT
    public Guid PartitionType;
    public Guid PartitionId;
    [MarshalAs(UnmanagedType.U8)]
    public EFIPartitionAttributes Attributes;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 36)]
    public string Name;
    [Flags]
    public enum EFIPartitionAttributes : ulong
    GPT_ATTRIBUTE_PLATFORM_REQUIRED = 0x0000000000000001,
    LegacyBIOSBootable = 0x0000000000000004,
    GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER = 0x8000000000000000,
    GPT_BASIC_DATA_ATTRIBUTE_HIDDEN = 0x4000000000000000,
    GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY = 0x2000000000000000,
    GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY = 0x1000000000000000
    [StructLayout(LayoutKind.Explicit)]
    public struct DRIVE_LAYOUT_INFORMATION_UNION
    [FieldOffset(0)]
    public DRIVE_LAYOUT_INFORMATION_MBR Mbr;
    [FieldOffset(0)]
    public DRIVE_LAYOUT_INFORMATION_GPT Gpt;
    [StructLayout(LayoutKind.Sequential)]
    public struct DRIVE_LAYOUT_INFORMATION_GPT
    public Guid DiskId;
    public long StartingUsableOffset;
    public long UsableLength;
    public int MaxPartitionCount;
    [StructLayout(LayoutKind.Sequential)]
    public struct DRIVE_LAYOUT_INFORMATION_MBR
    public uint Signature;
    public enum PARTITION_STYLE : int
    MasterBootRecord = 0,
    GuidPartitionTable = 1,
    Raw = 2

    Hello,
    in the links below you can found many informations to help you:
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa365730(v=vs.85).aspx
    http://www.codeproject.com/Articles/696388/Recover-Data-From-Corrupted-Drives-File-Systems-FA
    http://www.functionx.com/vcsharp/fileprocessing/drives.htm
    http://forums.codeguru.com/showthread.php?548305-partitioning-USB-Falsh-drive
    http://forums.codeguru.com/showthread.php?548169-USB-Flash-drive-Partitioning

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

Maybe you are looking for