Hi all,
Did anyone ever figure this out? I've got a RS-485 Shield from LinkSprite and I can't get it work. Here are some details from my project:
1. Linksprite RS-485 Shield V2.1 - http://linksprite.co...2.1_for_Arduino
2. Using SerialPort for communication: http://msdn.microsof...y/ee432679.aspx
3. Communicating over CAT6 twisted pair to a device at other end expecting 9600 baud, Even parity, 7 character bits, and one stop bit.
4. Twisted pair inserted into H2 485-A and 485-B ports.
5. Netduino Plus 2 (bought a month ago with no firmware updates)
6. Set to 5V using jumper.
7. Set to D0 and D1 using jumper.
8. Set to TX_CTRL using jumper.
9. Plugged into computer to deploy code. Headers are not soldered but they fairly snug and not loose.
10: Code:
static SerialPort serial; static OutputPort led; const int bufferMax = 10000; static byte[] buffer = new byte[bufferMax]; static int bufferLength = 0; public static void Main() { led = new OutputPort(Pins.ONBOARD_LED, false); serial = new SerialPort(SerialPorts.COM1, 9600, Parity.Even, 7, StopBits.One); serial.ReadTimeout = 1000; serial.DataReceived += serial_DataReceived; serial.ErrorReceived += serial_ErrorReceived; serial.Open(); while (true) { { led.Write(true); Debug.Print("Request sent"); string hexrequest = "2F3F3030303330303030313039363030210D0A"; // Create request byte[] seq = StringToByteArray(hexrequest); if (serial.CanWrite) serial.Write(seq, 0, seq.Length); led.Write(false); } string line = "> "; for (int i = 0; i < bufferLength; i++) { line += buffer[i] + ","; } Debug.Print(line); if(serial.IsOpen) Debug.Print("Port is open."); Thread.Sleep(10000); } } static void serial_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { if (e.EventType == SerialError.TXFull) { Debug.Print("Error: TXFull"); } else if (e.EventType == SerialError.RXParity) { Debug.Print("Error: RXParity"); } else { Debug.Print("Error: Some other error"); } } static void serial_DataReceived(object sender, SerialDataReceivedEventArgs e) { Debug.Print(dataRecLineNumber + ": Data received ******* - " + t ); int bytesReceived = serial.Read(buffer, bufferLength, bufferMax - bufferLength); if (bytesReceived > 0) { bufferLength += bytesReceived; if (bufferLength >= bufferMax) throw new ApplicationException("Buffer Overflow. Send shorter lines or increase lineBufferMax."); } }