I am writing my first C# program and its purpose is to communicate with a device through RS-232 using a serial port. The device is setup to transmit and receive some data.
When using HyperTerminal, I can succesfully send data to the device and succesfully receive data from the device, so I know wiring, communication settings, and the device are all correct.
I started writing a simple C# program using Windows Forms to test sending and receiving data. Using this small program, I can succesfully send data to my device. I cannot, however, receive any data from the device.
There is something odd going on which I cannot figure out due to my lack of C# and .NET experience. When I run my program and tell my device to send data, I get nothing. When I close the program and run it again, I get the previously sent line of data from the device. In other words, when my application is running, the device is not able to send data through the port. I don’t know if there is some handshaking element that is preventing the device from sending data or what…
Turn the hardware handshake signals on with DtrEnable and RtsEnable. You’ll then have to fix the NullReference exception you’ll get in SerialReceive().
Hi. I’m trying to run the code from:http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx Still (after enabling DtrEnable and RtsEnable after “_serialPort.Handshake = SetPortHandshake(_serialPort.Handshake);”) -I get timeout when trying to read from port… What am I doing wrong?? Thanks.