- #1
ionlylooklazy
- 30
- 0
Hello all,
Im trying to communicate with a RS232 device utilizing stick parity. This is defined as the first byte of a packet having its parity bit set to one, while all proceeding bytes have their parity bit set to 0. This was meant to be used to determine the start of a new packet.
However, there is no built in function to handle stick parity and I am generating all sorts of parity errors, which makes processing the data dificult.
AFAIK, when a parity error is detected, it inserts a specified value into the input stream, but when I read the stream the byte that was supposed to have generated the parity error still appears. is there anyway to disable this insertion?
I tried setting up an error event that would read the inserted byte out of the stream , but sometimes two or more bytes are inserted, and it seems to only remove one. here is my error event
I also tried setting the parity to space (parity bit always = 0). This way, I thought that when a parity error is generated, that would signal the start of a new packet, but strangely the error does not always occur.
Does any have any experience with stick parity, or have any suggestions?
Thanks,
IOLL
Im trying to communicate with a RS232 device utilizing stick parity. This is defined as the first byte of a packet having its parity bit set to one, while all proceeding bytes have their parity bit set to 0. This was meant to be used to determine the start of a new packet.
However, there is no built in function to handle stick parity and I am generating all sorts of parity errors, which makes processing the data dificult.
AFAIK, when a parity error is detected, it inserts a specified value into the input stream, but when I read the stream the byte that was supposed to have generated the parity error still appears. is there anyway to disable this insertion?
I tried setting up an error event that would read the inserted byte out of the stream , but sometimes two or more bytes are inserted, and it seems to only remove one. here is my error event
Code:
Private Sub Data_Error(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialErrorReceivedEventArgs) Handles SerialPort.ErrorReceived
Dim x As Integer
x = SerialPort.ReadByte
End Sub
I also tried setting the parity to space (parity bit always = 0). This way, I thought that when a parity error is generated, that would signal the start of a new packet, but strangely the error does not always occur.
Does any have any experience with stick parity, or have any suggestions?
Thanks,
IOLL