I am implementing the SAS protocol where its documented that SAS will poll with data-packet which size is 11 bit, where one start bit, eight data bit , ninth wakeup bit and one stop bit. Also documented that When SAS sned the message then it set wakeup bit for first byte of message after that for other byte message wakeup bit is clear. and also we have to use parity bit as wakeup bit.
i am facing issue with receiving the data from comport. what i suppose to get the data is:
01 73 1D 00 09 03 00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 B3 74 A4 02 0E 76
but i am getting
73 1D 00 09 03 00 00 01 02 03 04 05 06
here first byte is 01
is not coming into the received data as well as data after 06
bellow are the code for creating the serial port object.
SerialPort _serialPort = new SerialPort("COM1", 19200, Parity.None, 8, StopBits.One);
and when i am writing to Comport i set the Parity to MARK. like:
byte[] f = Response.ToArray();
_serialPort.Parity = Parity.Mark;
_serialPort.Write(f, 0, f.Length);
and when i am reading from comport
private void port_DataReceived_1(object sender, SerialDataReceivedEventArgs e)
{
SASobj._serialPort.ParityReplace = 0;
SASobj._serialPort.Parity = Parity.Space;
byte[] data = new byte[SASobj._serialPort.BytesToRead];
SASobj._serialPort.Read(data, 0, data.Length);
InputData = ByteToHex(data);
this.BeginInvoke(new SetTextCallback(SetText), new object[] { InputData });
}
private void SetText(string text)
{
this.txtMessage.Text += text;
}