background preloader

USB & Serial communication

Facebook Twitter

SerialPort IOException Workaround in C# Working with USB devices in .NET and C# - .NET tutorial. This article was originally published in VSJ, which is now part of Developer Fusion.

Working with USB devices in .NET and C# - .NET tutorial

This article was originally published in VSJ, which is now part of Developer Fusion. USB devices are now ubiquitous across the hardware space, but there are still no native support within the .NET library in order to interact with them. In this article, we look at creating the .NET software to run on a PC connected to a USB device. We will also use the techniques presented here to control a device that was probably never intended to be used with a PC, but opens up lots of possibilities for fun PC game projects as well as illustrating the portability and simplicity of USB HID devices. USB overview A USB device provides information about itself in the form of descriptors. The operating system provides logical connections or pipes from the client to endpoints on the host device.

There are many classifications of USB devices, each with a protocol specification of how to use it. Introducing HID Device operations. Working with USB devices in .NET. HELP....serial port data reading C# HI Rohit, Yes, sure.

HELP....serial port data reading C#

I'm trying to read data from digital multimeter via RS232 to usb. this is my code: // Hyperterminal adapter program publicclassHyperTerminalAdapter SerialPort oSerialPort = newSerialPort(); publicint BaudRate = 9600; publicint DataBits = 8; publicint ReadTimeOut = 2000; publicint WriteTimeOut = 2000; publicstring PortName = "COM3"; publicstring Handshake = ""; publicstring Name = "user"; publicstring DataReceived = ""; publicstring sParity = "none"; publicint iStopBits = 2; public HyperTerminalAdapter() this.Configure(); publicvoid Configure()

SerialPort Class (System.IO.Ports) Represents a serial port resource.

SerialPort Class (System.IO.Ports)

To browse the .NET Framework source code for this type, see the Reference Source. public class SerialPort : Component The SerialPort type exposes the following members. If a SerialPort object becomes blocked during a read operation, do not abort the thread. Instead, either close the base stream or dispose of the SerialPort object. The following code example demonstrates the use of the SerialPort class to allow two users to chat from two separate computers connected by a null modem cable. .NET Framework Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0 .NET Framework Client Profile Supported in: 4, 3.5 SP1 Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported) Any public static (Shared in Visual Basic) members of this type are thread safe.