I'm investigating options available for creating a virtual USB device (say, a keyboard or a mass storage device), so to emulate its function as needed and to allow a userspace app to emulate its insertion/removal at will.
What I am not clear about is how to go about the emulation of insertion/removal. It seems that one option is to emulate a (virtual) USB hub and have it fake the device arrival/departure events (and I would also supply the device driver for my virtual USB device and that's where my device logic will reside).
Device Emulation is a first-order approximation of the look and feel of your page on a mobile device. Device Emulation doesn't actually run your code on a mobile device. Instead, you simulate the mobile user experience from your laptop or desktop.
Some aspects of mobile devices aren't emulated in DevTools. For example, the architecture of mobile CPUs is different than the architecture of laptop or desktop CPUs. For the most robust testing, run your page on a mobile device.
Use Remote Debugging to interact with the code of a page from your machine while your page actually runs on a mobile device. You can view, change, debug, profile, or all four while you interact with the code. Your machine can be a notebook or desktop computer.
To quickly test the look and feel of your page across multiple screen sizes, drag the handles to resize the viewport to your required dimensions. You can enter any numeric values in the width and height boxes. If you select a size larger than available in the browser window, the viewport will be automatically scaled to accommodate for the larger viewport.
If you have defined media queries on your page, jump to the viewport dimensions where those media queries take effect by showing media query breakpoints above your viewport. Select More options () > Show media queries.
Media queries can be used to change the layout of a page when the viewport of the device that the webpage is viewed on is over or under a certain width. Media queries allow you to write code to use for page layout either when the screen width is under a certain size, or over a certain size, or within a mininum and maximum size.
To change the width of the viewport so that the media query for that breakpoint is used, click a breakpoint rectangle in the breakpoints bar. The viewport's width changes so that the breakpoint gets triggered, and the webpage layout is updated.
To go to the corresponding @media declaration in the code for the webpage, right-click between breakpoint vertical bars, and then select Reveal in source code. DevTools opens the Sources tool and displays the corresponding @media line in the Editor.
Device pixel ratio (DPR) is the ratio between physical pixels on the hardware screen and logical (CSS) pixels. In other words, DPR tells the browser how many screen pixels to use to draw a CSS pixel. Microsoft Edge uses the DPR value when drawing on HiDPI (High Dots Per Inch) displays.
To simulate the dimensions of a specific mobile device, click More options (), and then select Show device frame to show the physical device frame around the viewport:
Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 4.0 International License.The original page is found here and is authored by Kayce Basques (Technical Writer, Chrome DevTools & Lighthouse).
I have a Singer XL420 automatic embroidery machine that I use with Windows 10. The software will only open when the embroidery machine is plugged in. This is a nightmare as I have to set up the embroidery machine, when all I want to do is design something on the PC.
What I would love to know is ... is it possible to use an Arduino to emulate a device being plugged into Windows .... it doesn't have to do anything whatsoever other than simulate that the device is plugged in.
I've used Arduinos LOTS before so not a complete newbie and I've done a virtual mouse using a Leonardo before - guessing it would have to be a similar device to facilitate the USB function in this instance?
I'm not an expert on Windows but I wonder that shows up in Device Manager when you connect to the sewing machine without the design program. My guess is that any alternative to the sewing machine will have to emulate that device and if the purpose of the restriction is to prevent pirate copies of the software then I suspect the emulation won't be simple.
What is quite absurd, is when some software requires both the dongle and the separate device to which it connects - I have that situation with my present ECG system. Common sense would be at least to incorporate the dongle into the device itself - as appears to be the case with your embroidery machine, alternatively the dongle may allow the other function of the software to proceed in its absence.
In any case, it is likely that the device/ dongle performs some non-trivial task such as encryption. As zwieblum suggest, you could use wireshark to monitor the connection transaction between the program and the machine; it might be simple and the same on every connection; something you can emulate with an Arduino as it may just be that the designers thought it would be a "good idea" to have the machine connected, or sadly, they may be bloody-minded.
It's possible it's as simple as recognizing the VID/PID of the device attached to the computer. If so, that is a fairly simple thing to do with an Arduino that has a programmable USB chip. Any manufacturer who was serious about locking down their software would not use this approach and would instead have the validation via encrypted communication with the device, but there is a possibility they took the easy way out. Since it's fairly fast and easy to test this, I think it's worth a try.
I'd say the easiest way to quickly create a USB device with a custom VID/PID would probably be to use an FTDI FT232. FTDI provides a tool named FT_prog that allows you to program the FT232 to a custom VID/PID via a GUI.
If you don't have an FT232 board, the second easiest is to use any Arduino with native USB (Leonardo, Micro, Pro Micro, MKR). You can set the VID/PID of the board by editing its build.vid and build.pid properties in boards.txt, then uploading any sketch to the board. In the case of the Leonardo, Micro, Pro Micro, you might have multiple boards.txt files on your computer, but only one will be active, so you need to make sure you're editing the right file. If you need assistance finding and editing boards.txt, let me know and I'll provide detailed instructions.
It's also possible to do this with any Arduino board that uses the ATmega16U2 USB chip (e.g., official and faithful clone Uno and Mega), but this is a significantly more complex process so probably not worth the effort.
You wrote: "I have a Singer XL420 automatic embroidery machine that I use with Windows 10. The software will only open when the embroidery machine is plugged in. This is a nightmare as I have to set up the embroidery machine, when all I want to do is design something on the PC.".
That makes me wonder why you don't keep the machine plugged in to the USB all the time? You can use powered multiport extenders to connect several things to the USB of your PC and just leave them connected.
Paul_KD7HB:
That makes me wonder why you don't keep the machine plugged in to the USB all the time? You can use powered multiport extenders to connect several things to the USB of your PC and just leave them connected.
There are free embroidery softwares that support various file formats (extensions); not all of them support all possible formats and your current Singer software might only allow you to save files in its native format which might not be supported by 3rd party programs. One search revealed
Comparison of embroidery software - Wikipedia which lists some free options that support the (Singer) .XXX extension/format; others outside that link might support FHE and CHE format.
Are Singer being deliberately awkward (entirely possible) or is it simply that the software needs to know the capabilities of the target embroidery machine so it can avoid designing in something (stitch types?) that your hardware can't actually do?
Why not try the simplest possible solution of emulating the VID/PID before jumping into the complexity of trying to sniff and interpret the USB communication via WireShark and then attempting to reproduce that via an Arduino?
After that, if you decide to go for it and have questions about how to proceed (e.g., how to determine the VID/PID of your embroidery machine, how to find boards.txt), then let me know and I'll provide instructions.
I've searched for a while, finding similar questions with partial answers (with this being the closest: Is there software to fully emulate a USB hard drive?)However, none of them clearly answered my question.
Set the location to wherever you want to place the virtual hard disk on your local file system. You have to specify the filename, not just the location. This means C:/MyContainingFolder would be wrong, and C:/MyContainingFolder/virtualusb.vhd would be correct.
Specify the "Virtual hard disk size" to be however big you want your USB drive to be.NOTE: I have only tested this with the VHD format for a 64GB fixed size drive. This should work for different sized drives, but my instincts tell me that a variable size hard disk might confuse the system when mounted as removeable storage.
Once this VHD (virtual hard drive) has been created, you should see it in the disk management screen. Right click and click "Intialize disk" and select the MBR (Master Boot Record) partition style.Note: GPT may work, but again I've only tested with MBR.
I'm writing these steps mostly from memory, as I don't like to faff around with disk partitions just for the sake of a tutorial. For the first 6 steps, I used the following resource to both create my virtual hard drive, and as a reference for this guide: -en/how-to-create-a-virtual-usb-flash-drive-in-windows-10/
c80f0f1006