c# - Serialport writeline textbox error -


i use virtual com ports testing program. want serial write com8 , serial read com9. when want write values textbox1, error:

ioexception unhandled (the parameter incorrect)  

how rid of this?

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.io.ports;  namespace flowerpod_user_interface {     public partial class form1 : form     {         public form1()         {              initializecomponent();             // show list of valid com ports             foreach (string s in system.io.ports.serialport.getportnames())             {                 combobox1.items.add(s);             }         }          private void textbox1_textchanged(object sender, eventargs e)         {          }          private void form1_load(object sender, eventargs e)         {          }          private void button1_click(object sender, eventargs e)         {             if (serialport1.isopen)             {                 serialport1.writeline(textbox1.text);               }             else             {                 messagebox.show("serialport1 not open");             }         }          private void combobox1_selectedindexchanged(object sender, eventargs e)         {          }          private void connect_click(object sender, eventargs e)         {             if (!serialport1.isopen)             {                 serialport1.portname = combobox1.selecteditem.tostring();                  serialport1.open();                  textbox3.text = "open";              }          }          private void textbox3_textchanged(object sender, eventargs e)         {          }          private void textbox2_textchanged(object sender, eventargs e)         {          }          private void button3_click(object sender, eventargs e)         {             random slumpgenerator = new random();             // or whatever limits want... next() returns double             int tal = slumpgenerator.next(1000, 10000);             textbox1.text = tal.tostring();         }          private void textbox4_textchanged(object sender, eventargs e)         {          }          private void serialport1_datareceived(object sender,serialdatareceivedeventargs e)         {          }          private void button4_click(object sender, eventargs e)         {             if (!serialportread.isopen)             {                 serialport1.portname = "com9";                  serialportread.open();                  textbox4.text = serialportread.readline();                              }         }     } } 

there wasn't bridge between 2 ports caused problem. virtual com port software tricked me !.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -