Note that there are some explanatory texts on larger screens.

plurals
  1. POUSB communications - Windows CE host terminal to usb device (printer)
    primarykey
    data
    text
    <p>I am developing some code to run from a Windows CE5 terminal that will send data to a usb device (a printer in this case). I am having issues obtaining the value of the port used to open communications. I have tried to use the device path written in the registry by the driver (USBport + GUID) and many other variations to no prevail. I understand that communicating to the device should just "open a file" to communicate w/ the device at a given memory address. I understand there are modern usb libraries, but those will be of no use on such an old OS (i assume). My overall goal is to write the code is VC++ and use JNI to wrap the code for use in a Java application (SE6). Can anybody give an example on what a sample "device path" might be? Or if there is anything else I am missing feel free to shed light. I have noticed most of the modern USB libraries have a search function, but if I have the device path I don't believe the search function would be necessary....</p> <p>Currently I am trying to get the code to work on any OS, and have been using Windows 7 just to get things working. Below are some code snippets: </p> <p>const LPCTSTR portvalue = L"441ee000-4342-11d5-a184-00c04f60524d"; // defines the portname, ie, location of device to read/write</p> <p>int usbHandle = OpenUsb(portvalue); //opens the file/device for communication</p> <p>/<strong><em>*</em>**<em>*</em>**<em>*</em>*</strong><em>Here is the OpenUsb function <strong></em>**<em>*</em>**<em>*</em>**<em>*</em>****</strong>/ __declspec(dllexport) int _cdecl OpenUsb(const LPCTSTR portName) { </p> <pre><code>HANDLE activeUsbFileHandle = CreateFile(portName, //portname built in registry? need to get a WinCE5 vm going..? i belive so GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, // comm devices must be opened w/exclusive-access NULL, // no security attributes OPEN_EXISTING, // comm devices must use OPEN_EXISTING FILE_ATTRIBUTE_NORMAL, NULL); cout &lt;&lt; "Portname Mem Location: " &lt;&lt; &amp;portName; cout &lt;&lt; "\nThe portname passed in as: " &lt;&lt; portName &lt;&lt; endl; commTimeouts.ReadIntervalTimeout = 0; commTimeouts.ReadTotalTimeoutConstant = 500; commTimeouts.ReadTotalTimeoutMultiplier = 0; commTimeouts.WriteTotalTimeoutConstant = 5000; commTimeouts.WriteTotalTimeoutMultiplier = 0; SetCommTimeouts(activeUsbFileHandle, &amp;commTimeouts); return (int)activeUsbFileHandle; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload