Main Site Documentation

Using CTS/RTS pins as GPIO on G80


#1

Hello,

I am trying to use the CTS/RTS pins of COM3 (PD11 and PD12) on G80 device, but when the open port command is executed, the port take control of the pins, even when the handshake is disable.

Here is the code:

SerialPort comPort = new SerialPort(GHI.Pins.G80.SerialPort.Com3, 115200, Parity.None, 8, StopBits.One);
comPort.Handshake = Handshake.None;
OutputPort EnablePin = new OutputPort(GHI.Pins.G80.Gpio.PD12, true);
OutputPort ResetPin = new OutputPort(GHI.Pins.G80.Gpio.PD11, false);
comPort.ErrorReceived += comPort_ErrorReceived;
comPort.Open();

When the comPort.Open() is executed, the EnablePin becomes false, and the ResetPin become true, What can I do to recover the control over those pins?

Thanks


#2

I already solved my issue.
The key is to declare the ports after open de “COM” port.

SerialPort comPort = new SerialPort(GHI.Pins.G80.SerialPort.Com3, 115200, Parity.None, 8, StopBits.One);
comPort.Handshake = Handshake.None;
comPort.ErrorReceived += comPort_ErrorReceived;
comPort.Open();
OutputPort EnablePin = new OutputPort(GHI.Pins.G80.Gpio.PD12, true);
OutputPort ResetPin = new OutputPort(GHI.Pins.G80.Gpio.PD11, false);

With this change in the declaration order, I retook the control of the pins.
But I am still open to better approaches.

Thanks