Click here to Skip to main content
15,882,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to everyone
i want to connect via serial port and send/receive data. I've not done it before. I need to press on button(like as OK), then send data by port to a hardware. if it has an answer, send it to PC.
how can i do this? please help me
Posted

1 solution

Well, it depends a bit on the programming language (and the libraries) you are using. In any case you may find many examples just using Google. For instance (assuming you are developing for the Windows OS):

(.NET Framework) - SerialPort Class[^].

(WINAPI) - Serial Communications[^].
 
Share this answer
 
Comments
mohsenvasefi 7-Oct-13 9:27am    
thanks, but in my project (C#), it can't open port! I've written as following lines:

serialport1.BaudRate=38400;
serialport1.PortName="com1";
serialport1.DtrEnable=true;
serialport1.RtsEnable=true;
serialport1.Handshake=System.IO.Ports.Handshake.None;
serialport1.Parity=System.IO.Ports.Parity.None;
serialport1.Open;
serialport1.DiscardInBuffer();
serialport1.DiscardOutBuffer();

could you explain what shall i do to open port of my PC?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900