dimanche 26 avril 2015

Setting pins of RS232 using SerialPort .NET without overhead


I want to set DTS and RTS pins to true/false in .NET using SerialPort-Class.

When setting pins to true/false and sniffing COM-Port there are alot of other things send to the COM-Port that I don't want.

Sniff-Log: http://ift.tt/1JtqQsF

Code:

SerialPort serialPort = portSelector.SelectedPort;
serialPort.Parity = Parity.None;
serialPort.StopBits = StopBits.One;
serialPort.DataBits = 8;
serialPort.ReadTimeout = 10;
serialPort.WriteTimeout = 10;
serialPort.BaudRate = 5;
serialPort.Handshake = Handshake.None;

serialPort.Open();
serialPort.DiscardInBuffer();
serialPort.DiscardOutBuffer();
serialPort.DtrEnable = false;

If I do the same thing in C it works and is not sending any garbage I don't want. Can you tell me what I'm doing wrong?

Thank you


Aucun commentaire:

Enregistrer un commentaire