Using Usb2ser DLL in C#
Using Usb2ser DLL in C#
Rev. 1, 07/2011
Application Note
1 Introduction Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
This application note explains how to use the USB2SER 2 Using DLLs in a C# Project . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Creating a new DLL folder. . . . . . . . . . . . . . . . . . . . 2
DLL in any C# (C sharp) project. This DLL is used to 2.2 Application programming interface . . . . . . . . . . . . . 5
communicate with the USB2SER, which allows the 3 Serial Production GUI User Guide. . . . . . . . . . . . . . . . . . 8
reading and modification of USB descriptors allocated in 3.1 Valid formats and values for USB descriptors’ fields 9
3.2 Discover USB devices . . . . . . . . . . . . . . . . . . . . . . . 9
nonvolatile memory. 3.3 Read USB descriptors . . . . . . . . . . . . . . . . . . . . . . 10
3.4 Customize USB descriptors. . . . . . . . . . . . . . . . . . 10
First, the application note explains how to include and 4 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
use the USB2SER DLL in a C# project. Second, it
explains in detail the application programming interface
(API) of the USB2SER DLL. Third, this document
explains how the serial production GUI is implemented
and how it uses the USB2SER DLL.
5. On the solution explorer, right click on References, then choose Add Reference.
6. Select the Browse tab and look for the USB2SER_DLL.dll file. Select it and click OK.
7. Repeat steps 6 and 7 for any other desired DLL files.
8. Open the Form1 code and add the class USB2SER_DLL with the “using” word.
9. Now, by declaring a new USB2SER_API object the Form1 can use the methods provided by the
referenced class.
Download and open the SerialProduction1v3 project from www.freescale.com for more information about
the mentioned class.
The variables listed below are read/write variables and are used by the application. The BusPowered
variable configures whether the device is self- or bus-powered. The SerialAutoIncrement variable
configures whether the serial number string is incremented each time the nonvolatile memory is written or
whether it remains unchanged.
public bool BusPowered
public bool SerialAutoIncrement
public bool HexFormat
2.2.3 Methods
Table 1. USB2SER C# Methods
The serial production GUI is intended to communicate with one USB2SER device at the time. Ensure that
no more than one device with the same vendor ID and product ID is connected.
4 Conclusion
The DLLs described in this document provide a secure way to use previously-validated methods and
objects. They also allow code reuse and speed up the development of new designs. DLLs also protect
intellectual property since the DLL does not provide source code.
5 Revision History
Table 2. Revision History
Version Changes
Web Support:
http://www.freescale.com/support Freescale Semiconductor reserves the right to make changes without further notice to
any products herein. Freescale Semiconductor makes no warranty, representation or
USA/Europe or Locations Not Listed: guarantee regarding the suitability of its products for any particular purpose, nor does
Freescale Semiconductor, Inc. Freescale Semiconductor assume any liability arising out of the application or use of any
Technical Information Center, EL516 product or circuit, and specifically disclaims any and all liability, including without
2100 East Elliot Road
Tempe, Arizona 85284 limitation consequential or incidental damages. “Typical” parameters that may be
+1-800-521-6274 or +1-480-768-2130 provided in Freescale Semiconductor data sheets and/or specifications can and do vary
www.freescale.com/support in different applications and actual performance may vary over time. All operating
parameters, including “Typicals”, must be validated for each customer application by
Europe, Middle East, and Africa: customer’s technical experts. Freescale Semiconductor does not convey any license
Freescale Halbleiter Deutschland GmbH under its patent rights nor the rights of others. Freescale Semiconductor products are
Technical Information Center not designed, intended, or authorized for use as components in systems intended for
Schatzbogen 7 surgical implant into the body, or other applications intended to support or sustain life,
81829 Muenchen, Germany
+44 1296 380 456 (English) or for any other application in which the failure of the Freescale Semiconductor product
+46 8 52200080 (English) could create a situation where personal injury or death may occur. Should Buyer
+49 89 92103 559 (German) purchase or use Freescale Semiconductor products for any such unintended or
+33 1 69 35 48 48 (French) unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and
www.freescale.com/support its officers, employees, subsidiaries, affiliates, and distributors harmless against all
claims, costs, damages, and expenses, and reasonable attorney fees arising out of,
Japan: directly or indirectly, any claim of personal injury or death associated with such
Freescale Semiconductor Japan Ltd. unintended or unauthorized use, even if such claim alleges that Freescale
Headquarters
ARCO Tower 15F Semiconductor was negligent regarding the design or manufacture of the part.
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064 For information on Freescale’s Environmental Products program, go to
Japan http://www.freescale.com/epp.
0120 191014 or +81 3 5437 9125
[email protected]
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
Asia/Pacific: All other product or service names are the property of their respective owners.
Freescale Semiconductor China Ltd. © Freescale Semiconductor, Inc. 2011. All rights reserved.
Exchange Building 23F
No. 118 Jianguo Road
Chaoyang District
Beijing 100022
China
+86 10 5879 8000
[email protected]