Thursday 15 September 2011

c# - serial port split data -



c# - serial port split data -

in code send resume , left reason text split this:

[com6] pause [com6] re [com6] sume [com6] [com6] le [com6] ft

here code

var myserialport = new serialport { baudrate = int.parse(nscombobox1.items[nscombobox1.selectedindex].tostring()), portname = nscombobox2.items[nscombobox2.selectedindex].tostring(), readtimeout = 500, readbuffersize = 1024, parity = parity.space, stopbits = stopbits.one }; myserialport.open(); myserialport.datareceived += (o, args) => { string s = myserialport.readexisting(); textbox1.invoke( new methodinvoker(() => textbox1.text += string.format("[{0}] {1}", myserialport.portname, s) + environment.newline)); //removed rest beingness irrelevant };

i think because of alternative how can avoid splitting text?

try using myserialport.readline(); read until new line value

c# serial-port

No comments:

Post a Comment