Hello,
I have been searching for an answer without much luck. I have a Fez Panda II, and a XL-MaxSonar-AE4.
Here is the datasheet for the maxsonar: http://www.maxbotix.com/documents/MB1240-MB1340_Datasheet.pdf
As the documentation describes, I connected the pin 4 (RX) to the COM2 Output, Pin 5 (TX) to the COM2 Input, the V+ to 5V output, and the GND to ground.
I have the code in the main:
UART = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler( ReceiveSerial );
And the interrupt for reading:
public static void ReceiveSerial(Object sender, SerialDataReceivedEventArgs e){
int size = UART.BytesToRead;
byte[] bytes = new byte[size + 4]; //4 extra to be safe
int read = UART.Read(bytes, 0, bytes.Length);
for (int i = 0; i < read; i++ )
{
Debug.Print(bytes[i].ToString());
}
}
The Maxbotix documentation says: “The output is an ASCII capital R, followed by three ASCII character digits representing the range in centimeters up to a maximum of 765, followed by a carriage return (ASCII 13).”
The ASCII value of “R” is “82”. But the console outputs:
...
76
0
76
0
76
0
76
0
76
...
And the “82”, nor the “13” is nowhere to be seen.
Am I doing something wrong? Thanks.