c# - SerialPort.Write() take a relatively long time to execute -
the function myserialport.write("hello")
takes full millisecond execute. have added stopwatch code helps me understand execution time. there way program execute faster? can issue related serial port driver? using usb serial converter cable. baud rate = 115200 parity = none data bits = 8 stop bits = 1 if replace myserialport.write("hello")
line empty loop runs 10000 times, executes instantly. therefore if me achieve similar speed execution of myserialport.write("hello")
of immense help. in advance.
private void button2_click(object sender, eventargs e) { stopwatch stopwatch = new stopwatch(); stopwatch.start(); myserialport.write("hello"); stopwatch.stop(); timespan ts = stopwatch.elapsed; textbox2.text = string.format("{0:00}:{1:00}:{2:00}.{3:00}", ts.hours, ts.minutes, ts.seconds, ts.milliseconds); }
Comments
Post a Comment