A
Andrew Poelstra
Hey all,
I have my serial port configured with the follow perl script
to pulse the DTR line when you open the port. This resets my
device, which is important during programming. (If the device
is not reset, it can only be programmed by fluke if its state
is correct.)
use Device::SerialPort;
Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(100);
HOWEVER, on the C# side of things, when I open the port for
communication, it also sends the DTR pulse and resets the
serial device, which I do not want. My test C# code is:
port = new SerialPort("/dev/ttyUSB0", 115200, Parity.None, 8, StopBits.One);
try {
port.Open();
for(int i = 0; i < 3; ++i)
System.Console.WriteLine(port.ReadLine());
}
catch(System.IO.IOException) {
System.Console.WriteLine("Failed to open port.");
}
Whenever I run this code, I can see the device reset (it
has a LED indicator of its program progress), and I see
its three-line boot message appear in the console.
So my question is, can I turn off the DTR pulse from C#? I'm
using System.IO.Ports.SerialPort and portability is a pretty
big concern for this project. (Also, I'm running Mono rather
than .NET so I can't pInvoke or use COM.) (That I know of.)
Andrew
I have my serial port configured with the follow perl script
to pulse the DTR line when you open the port. This resets my
device, which is important during programming. (If the device
is not reset, it can only be programmed by fluke if its state
is correct.)
use Device::SerialPort;
Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(100);
HOWEVER, on the C# side of things, when I open the port for
communication, it also sends the DTR pulse and resets the
serial device, which I do not want. My test C# code is:
port = new SerialPort("/dev/ttyUSB0", 115200, Parity.None, 8, StopBits.One);
try {
port.Open();
for(int i = 0; i < 3; ++i)
System.Console.WriteLine(port.ReadLine());
}
catch(System.IO.IOException) {
System.Console.WriteLine("Failed to open port.");
}
Whenever I run this code, I can see the device reset (it
has a LED indicator of its program progress), and I see
its three-line boot message appear in the console.
So my question is, can I turn off the DTR pulse from C#? I'm
using System.IO.Ports.SerialPort and portability is a pretty
big concern for this project. (Also, I'm running Mono rather
than .NET so I can't pInvoke or use COM.) (That I know of.)
Andrew