tags:

views:

186

answers:

5

How would I go about writing to a COM port, trying to convert the following example to .Net (C#), specifically the PHP part? If possible is there an easier way to write out to a USB?

+5  A: 

Use the SerialPort class, e.g.:

SerialPort port = new SerialPort("COM1");
port.Open();
if (port.IsOpen)
{
}
port.Close();
Pete OHanlon
+3  A: 

see SerialPort class.

elder_george
+1  A: 

The easiest way to write to USB is through serial port (COMx - on windows). Here are some examples in C#:

http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.open.aspx

bua
A: 

See the System.IO.Ports namespace docs:

The System.IO.Ports namespace contains classes for controlling serial ports. The most important class, SerialPort, provides a framework for synchronous and event-driven I/O, access to pin and break states, and access to serial driver properties. It can be used to wrap a Stream objects, allowing the serial port to be accessed by classes that use streams.

The namespace includes enumerations that simplify the control of serial ports, such as Handshake, Parity, SerialPinChange, and StopBits.

The SerialPort class documentation contains a detailed usage exmaple.

gimel
A: 

Here you can find a good tutorial

Tror