I tried out the following simple Netduino program which is supposed to read the byte and send back the same value via serial connection:
public class Program { static SerialPort serialPort; public static void Main() { serialPort = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One); serialPort.Open(); serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); Thread.Sleep(Timeout.Infinite); } static void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { byte[] bytes = new byte[1]; serialPort.Read(bytes, 0, bytes.Length); serialPort.Write(bytes, 0, bytes.Length); } }
The received values on Netduino are not equal to those sent from PC hyperterminal (I used X-CTU) and then the received values on PC ae not equal to those, sent back from Netduino. Below is the list of bytes (characters) I tried to send from PC to Netduino and then from Netduino back to PC using the above program:
PC byte (character) -> Netduino byte -PC byte (character)
61 (a) -> 79 -> 58 (X) 62 (B) -> 39 -> 6C (1) 63 (c) -> 78 -> 2C (,) 64 (d) -> 19 -> 76 (v) 65 (e) -> 77 -> 59 (Y) 66 (f) -> 38 -> 36 (6) 67 (g) -> 76 -> 16 (.) 68 (h) -> 9 -> 7B ({) 69 (i) -> 75 -> 5A (z) 6A (j) -> 37 -> 6D (m) 6B (k) -> 74 -> 2D (-) 6C (l) -> 18 -> 3B (j) 6D (m) -> 73 -> 5B ([) 6E (n) -> 36 -> 1B () 6F (o) -> 72 -> 0B () 70 (p) -> 4 -> 1F () 71 (q) -> 71 -> 5C (\) 72 (r) -> 35 -> 6E (n) 73 (s) -> 70 -> 2E ()
Does anyone know what could possibly cause the change of byte values on serial communication and how to solve the problem?
Thank you for your help!
Niko