Question

So I'm stuck and i need to turn to you experts once more to get me out of my jam.

I have a c# forms project that is going to move a camera via serial port (rs232). (VISUAL STUDIO 2010)

When I use hyperterminal the camera responds as it should.

The device uses ASCII for communiation. I think that the serialPort class converts strings to ASCII when it sends the bytes. If I am wrong about this, Please correct me. When I load my forms project the device does not react. I have tried building the form two ways,

I have used

 SerialPort com = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);  
com.Open();

private void button1_Click(object sender, EventArgs e)
{
com.Write("move left" + "/r/n")
}

I have also used the serialport tool by dropping it into my form and calling the function with

serialPort1.Write("move left" + "/r/n");

I have tried different handshaking and different baud rates. I have made sure that the settings match the settings on the camera too.

I need your help. Can someone explain to me why the device does not respond? It acts as if its not connected.

Does the serial link require some sort of negotiation before it begins (like though a telnet connection)? id so can you point me to that?

I have also tried

serialPort1.write("move left"+serialPort1.newline)

//and

serialPort1. write("move left"+"/n")
Was it helpful?

Solution 2

OK, so I guess i was just too burned out on it. After walking away from the project for a couple of days i found the problem. The DiscardNull property was set to false. It needed to be set to true. Thank you all for your help.

OTHER TIPS

In hyper terminal do you press enter after a command? If so you will need to send the \r\n which is effectively the same as a hitting enter in hyper terminal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top