I need to build communication between Multidrop bus nodes and main process running on Windows IoT over Raspberry Pi 3.
I know how to exchange data with 8 bit byte. It example of working code:
_serial_port = await SerialDevice.FromIdAsync(di.Id);
if (_serial_port == null) return false;
_serial_port.WriteTimeout = TimeSpan.FromMilliseconds(1000);
_serial_port.ReadTimeout = TimeSpan.FromMilliseconds(1000);
_serial_port.BaudRate = 9600;
_serial_port.Parity = SerialParity.None;
_serial_port.StopBits = SerialStopBitCount.One;
_serial_port.DataBits = 8;
dataWriteObject = new DataWriter(_serial_port.OutputStream);
dataReaderObject = new DataReader(_serial_port.InputStream);
dataWriteObject.WriteBytes(0xAA);
await dataWriteObject.StoreAsync();
await dataReaderObject.LoadAsync(1);
byte resp = dataReaderObject.ReadByte();
Here I transmit 1010 1010
and receive xxxx xxxx
from the remote node.
The question.
1010 1010 1
1010 1010 1
What the code need to looks like?
UPDATE
I think about workaround solutions:
SerialDevice.Parity is used for error-checking instead of data transmitting. And application can't access this bit.
Use two bytes for 9 bits transmitting.
Send part:
dataWriteObject.WriteBytes(new byte[] { 0b10101010, 0b10000000});
Receive part:
byte[] data = new byte[2] { 0, 0 };
dataReaderObject.ReadBytes(data);
int data1 = data[0];
int data2 = data[1];
data1 = data1 << 1;
data2 = data2 >> 7;
int data3 = data1 | data2;