c# - Can't open serialport on Windows CE application -
i working on windows ce application involves using serial ports of machine. when try open port gives ioexception. below example code:
serialport newserialport = new serialport("com7", 115200, parity.none, 8, stopbits.one); newserialport.handshake = handshake.none; //opening serial port newserialport.open();
i have tried close connection before open statement , checked isopen status before opening (which false before opening). serialport.getportnames function gives back: com1 / com2 / com5 / com7. tried including in diffrend way this: com1: / com2: / com5: / com7:. can't seem work.
my first thought forgot add in windows ce image. can't seem find in catalog seem important serial communication.
does have thought on this?
at system.io.ports.serialstream.winioerror() @ system.io.ports.serialstream.winioerror() @ system.io.ports.serialstream.checkresult() @ system.io.ports.serialstream.setbuffersizes() @ system.io.ports.serialport.open() @ commtest.form1.button2_click() @ system.windows.forms.control.onclick() @ system.windows.forms.button.onclick() @ system.windows.forms.buttonbase.wnproc() @ system.windows.forms.control._internalwnproc() @ microsoft.agl.forms.evl.entermainloop() @ system.windows.forms.application.run() @ commtest.program.main()
try exact port name getportnames() - including colon
serialport newserialport = new serialport("com7:", 115200, parity.none, 8, stopbits.one); // or string[] portnames = serialport.getportnames() serialport newserialport = new serialport(portnames[3], , 115200, parity.none, 8, stopbits.one);
if doesn't work, try "\\.\com7"
serialport newserialport = new serialport("\\.\com7", 115200, parity.none, 8, stopbits.one);
Comments
Post a Comment