usb

Using RegisterDeviceNotification in a .NET app

徘徊边缘 提交于 2019-12-05 16:23:23
I have seen some examples on how to use RegisterDeviceNotification from the Windows API, but I have not seen any .NET examples. I want to write a C# app that is notified when a new drive appears (specifically through USB, firewire, etc). This app needs to be a Windows service, so I can't use WM_DEVICECHANGE messages without some bad-practice hacking. I'd like to avoid that. Can anyone give me a sample of how to use RegisterDeviceNotification in C#, or at least give me a good alternative to it? EDIT: Again, this is a Windows service that has no graphical user interface. So the possible

Serial ports - how do I set characters?

空扰寡人 提交于 2019-12-05 16:02:42
Consider: Baud rate 19200 RTS on DTR on Data bits=8, Stop bits=1, Parity=None Set chars: Eof=0x00, Error=0x2A, Break=0x2A, Event=0x00, Xon=0x11, Xoff=0x13 Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=0, XoffLimit=4096 OK, so using a port scanner I've found that a USB device needs these settings to facilitate an import. I can recreate most of these as follows: port = new SerialPort("COM4"); port.DtrEnable = true; port.RtsEnable = true; port.Handshake = Handshake.None; port.BaudRate = 19200; port.StopBits = StopBits.One; port.Parity = Parity.None

Safely remove USB from batch file?

北慕城南 提交于 2019-12-05 15:57:49
Can a batch file be made in windows that could safely eject the USB?So far on various sites there exist different utilities like devcon. Eject Media and Remove Drive Freeware by Uwe Sieber - http://www.uwe-sieber.de Remove drive is what you need for USB safe removal. Download RemoveDrive.exe from http://www.uwe-sieber.de/drivetools_e.html and then use the code below. removedrive\x64\RemoveDrive.exe F: -L Note that F: is the drive you want to eject -L means Loop Please try this script to safely remove disk, maybe useful to you :) @echo off cls set tempfile="%TEMP%\tmp_disk.dsk" cd %SystemRoot%

Android Studio wont recognize Nexus 7 as device

↘锁芯ラ 提交于 2019-12-05 15:54:25
I am having trouble running an app I am developing in Android Studio on my Nexus 7. I have successfully gotten this to work before using the same tablet and computer (running Windows 8), but since having my laptop repaired and everything wiped I'm convinced something with my dev environment is messed up. When I go to run the project, there are no available devices, so it is not recognizing my Nexus 7 anymore. Things I have tried making sure my computer recognizes the device and that I have the Nexus 7 driver installed from ASUS going to the SDK manager and ensuring I have the Google USB driver

What's going on after DTR/RTS is sent to an FTDI-based Arduino board?

为君一笑 提交于 2019-12-05 15:10:20
I'm working over a sketch to enable uploading from an Android device to an Arduino board, and it works for Duemilanove ( FTDI -based) and Arduino Uno ( ATmega -based) when testing for PC/Arduino using rxtx (pure Java). But it does not work when using the USB-Android library as the setDTR/setRTS methods are not yet implemented. FTDI Android drivers allow the sending of setDTR/setRTS signals, but it fails to send/read data after it. So the problem is in the Android USB API and I can't figure out what's wrong.. What happens for FTDI-based Arduino boards after DTR/RTS are toggled? I believe that

How to get C++ to perform I/O from a USB Port like a Serial Port

纵饮孤独 提交于 2019-12-05 14:59:12
Is it possible to read/write from/to a specific USB port, avoiding all that USB handshaking stuff? What I want to do is communicate with a microcontroller, for example, that doesn't have a USB driver on board via USB. I want my C++ application to be able to send data via a specific USB port and then to receive data from that same USB port. Basically what I want to be able to do is treat that USB port like a serial port. Is this possible? Is there a workaround I can use? Thanks in advance. PS: I know this isn't the best way to go about communication with a uC, but let's assume, for some reason,

android usb UsbDeviceConnection.bulkTransfer returns -1

廉价感情. 提交于 2019-12-05 14:04:55
I am trying to send commands to a POS printer from my android tablet. I have been able to get the basic connections wroking but now when I try to send data to the printer, the bulkTransfer returns -1. Please help me understand what is going on. The following is a modified broadcast receiver taken from the android site where I do all the data transfer. private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (ACTION_USB_PERMISSION.equals(action)) { synchronized (this) { UsbDevice

Turn off power to a USB port

和自甴很熟 提交于 2019-12-05 13:53:02
I'm looking for a way to turn power off (and back on) for a USB port. Solution can be in C, bash, etc. I'm using a BeagleBone running 32-bit Ubuntu 16.04 for armhf. > uname -srvm Linux 4.4.6-ti-r15 #1 SMP Tue Apr 5 12:32:22 UTC 2016 armv7l I've tried many things discussed on StackOverflow and AskUbuntu, including: #include <linux/usbdevice_fs.h> int main(void) { int fd = open( "/dev/bus/usb/001/002", O_WRONLY ); if (fd < 0) return 1; int rc = ioctl( fd, USBDEVFS_RESET, 0 ); if (rc < 0) return 2; close( fd ); return 0; } The USB device I need to turn off (and eventually back on) is a Champtek

How to simulate a webcam device [closed]

允我心安 提交于 2019-12-05 13:39:15
I am working on a project which I need to synthesize a video from existing frames and then format it exactly like a webcam device and make it available to external computers. In other words, this USB output should look exactly as if it was generated by a webcam. Can someone provide some hints about any existing library or any methodology to do this? The target system to create "webcam" output via USB is UBUNTU. Thanks Web cams are usually accessed through a library or the operating system rather than as low level USB devices. In python, one option to read webcam frame is https://github.com

AS3 USB game controller support

做~自己de王妃 提交于 2019-12-05 13:03:56
How can I make a USB controller control my AS3 game. I'm using the keyboard right now and I have thought about mapping the keys but I have to use a plugin for that and I just want users to be able to buy a simple controller that doesn't need any driver downloads/configuration. They should be able to plugin the USB controller and play the game through Flash Player in a browser. One possibility... you can tell your users to download joy2key. http://electracode.com/4/joy2key/JoyToKey%20English%20Version.htm I admit that this is not a "real answer" to your question. But it is a stop-gap solution