communicating with serial port in C#
-
I want to work with serial port, I found a good example in this site. And I learnt a little about serial work in c#. But now I want to now how could I update serial port communication protocol in C##? Like; how could I change the value of serial port parameters: Parity, BaudRate, StopBits, DataBits ect. Thanks in advance
Mansureh Shahraki Moghaddam
-
I want to work with serial port, I found a good example in this site. And I learnt a little about serial work in c#. But now I want to now how could I update serial port communication protocol in C##? Like; how could I change the value of serial port parameters: Parity, BaudRate, StopBits, DataBits ect. Thanks in advance
Mansureh Shahraki Moghaddam
you set serial port parameters thru the SerialPort class, use one of the constructors and/or one of several properties (such as SerialPort.BaudRate). :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
-
you set serial port parameters thru the SerialPort class, use one of the constructors and/or one of several properties (such as SerialPort.BaudRate). :)
Luc Pattyn [Forum Guidelines] [My Articles]
Happy 2008!
-
Thank you so much for helping me. You mean like these codes: _serialPort.Open(); _serialPort.ReadTimeout = 5000; _serialPort.WriteLine("*cls"); But what about wiring? Is that enough to estanbish a "Null Modem" connection?
Sourie
Hi again, I found this link. I think it could be helpful for me: http://www.codeproect.com/KB/cs/serialcommunication.asp
Sourie
-
Thank you so much for helping me. You mean like these codes: _serialPort.Open(); _serialPort.ReadTimeout = 5000; _serialPort.WriteLine("*cls"); But what about wiring? Is that enough to estanbish a "Null Modem" connection?
Sourie
Hi again. When you connect a peripheral to a PC, you typically need a straight cable with one male and one female connector. When you connect two PCs, you would need a null modem cable, which has two female connectors. There is nothing you can do about that in software, your cable must match the situation. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi again. When you connect a peripheral to a PC, you typically need a straight cable with one male and one female connector. When you connect two PCs, you would need a null modem cable, which has two female connectors. There is nothing you can do about that in software, your cable must match the situation. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
Thanks for your reply. Actually I want to connect an AVR MCU to PC. As I studied these days, I think I should make a NULL MODEM connection between AVR and Serial Port of PC (but by inserting a MAX232 chip). It means that RXD and TXD from PC should be connected to TXD and RXD of MCU and DTR of PC should be connected to its DSR and CD, also its RTS should be connected to CTS. I think this wiring is enough and after that I should write a C# code for Pc and an assembly code for MCU to communicate to eachother.
Sourie
-
Thanks for your reply. Actually I want to connect an AVR MCU to PC. As I studied these days, I think I should make a NULL MODEM connection between AVR and Serial Port of PC (but by inserting a MAX232 chip). It means that RXD and TXD from PC should be connected to TXD and RXD of MCU and DTR of PC should be connected to its DSR and CD, also its RTS should be connected to CTS. I think this wiring is enough and after that I should write a C# code for Pc and an assembly code for MCU to communicate to eachother.
Sourie
Hi, yes, you need at least three wires: GND to GND RXD to TXD TXD to RXD you may want or need some of the control lines, depending on your application and port settings. If so, they need to be cross-wired too. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, yes, you need at least three wires: GND to GND RXD to TXD TXD to RXD you may want or need some of the control lines, depending on your application and port settings. If so, they need to be cross-wired too. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|