Sure i've done.
Here is the code i've init my serialPort
private bool intiCom()
{
if (serialPort == null)
serialPort = new SerialPort();
serialPort.Handshake = Handshake.None;
serialPort.PortName = comport;
serialPort.BaudRate = baudrate;
serialPort.DataBits = databits;
if (stopbits == 1)
serialPort.StopBits = StopBits.One;
else if (stopbits == 1.5)
serialPort.StopBits = StopBits.OnePointFive;
else if (stopbits == 2)
serialPort.StopBits = StopBits.Two;
else
return false;
if (parity == 1)
serialPort.Parity = Parity.Even;
else if (parity == 2)
serialPort.Parity = Parity.Mark;
else if (parity == 3)
serialPort.Parity = Parity.None;
else if (parity == 4)
serialPort.Parity = Parity.Odd;
else if (parity == 5)
serialPort.Parity = Parity.Space;
else
return false;
serialPort.RtsEnable = true;
serialPort.Encoding = Encoding.ASCII;
try
{
serialPort.Open();
}
catch (Exception)
{
return false;
}
return true;
}
And the settings came from my ini file :)
portname=4
baudrate=9600
databits=8
stopbits=1
parity=3
showsettings=0
showdisplay=1
tray=1
topmost=0
excelinstalled=1
excellang=german
saveinginterval=3600
scalebars=1