Click here to Skip to main content
15,846,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi people.
I'm working on some device automation application and need to connect to it via a serial pport and a RS232 interface and send and recieve ASCII data to the port. I've used some codes like this:
SerialPort srp = new SerialPort("COM2", 19200, Parity.None, 8, StopBits.One);

srp.Open();
srp.WriteLine("some commands");
srp.Close();


My device takes no action with this code but I'm sure about the command syntax. Is the problem in my used code? Could anyone help me please?
Posted

Hi,

When you use writeLine Method that writes the specified string and the NewLine value to the output buffer. The New line is maybe the problem. You can verify this.

Jerem
 
Share this answer
 
Comments
Baji Jabbar 8-Nov-10 5:22am    
seems so
Hi
Your code seems right?
You can download any virtual Serial port emulator . Pair any two virtual port and let your application connect with any port ,just paired. Send the message to the same port , you will can listen to other port using the Microsoft hyper terminal ( or you can create your own app to listen and send message to a port). If you are getting the message properly ,then there is no issues in your code . May be the delimiter is the issue.

hope this will help you.
I am usingvirtual serial port emulator from http://www.eterlogic.com/[^]
 
Share this answer
 
I am not an expert but have you tried this?

SerialPort srp = new SerialPort("COM2", 19200, Parity.None, 8, StopBits.One);
srp.Open();
srp.WriteLine("some commands"+Environment.NewLine);
srp.Close();
 
Share this answer
 
Cross Post

sending text file via serial port C#[^]


Why are you posting new Question.., this is already posted.., Stick with one.., don't snap the board..

----------

Are You tried the same commands from Hypertrm/ Dock light Scriptings.,
If Possible can you post the modem commands here...
 
Share this answer
 

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