| Thread Closed |
stick parity & vb.net 2005 |
Share Thread | Thread Tools |
| Jan24-07, 01:29 PM | #1 |
|
|
stick parity & vb.net 2005
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 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 |
| Jan24-07, 02:31 PM | #2 |
|
|
Take a look at this code sample. It uses api functions and probably has what you need.
|
| Jan24-07, 03:13 PM | #3 |
|
|
hmm, I dont see anything I dont already have, but what exactly is an API function?
I dont have a problem setting up rs232 communication, its just using this strange parity scheme. if the parity was any of the standard values it would be npnp |
| Jan24-07, 05:10 PM | #4 |
|
|
stick parity & vb.net 2005
I mean Windows API (formerly Win32 API) functions. Perhaps you already use them. I thought perhaps you could simply disable parity.
|
| Jan26-07, 11:10 PM | #5 |
|
Recognitions:
|
I assume you're using the class SerialPort which has an enumerated property "Parity":
Code:
SerialPort sp = new SerialPort(); sp.Parity = Parity.Even sp.Parity = Parity.Mark sp.Parity = Parity.None sp.Parity = Parity.Odd sp.Parity = Parity.Space So if i understand what's happening, you're communicating with an RS232 device which implements stick parity. Since the SerialPort class doesn't support the stick parity your device uses, the data you send using any of the available parities generates a parity error on the device. Is this what's happening? I think that, using the SerialPort class, and assuming the Stick Parity your device uses is neither High nor Low stick parity, but some other format, then what you might have to do is set Parity to Parity.None. Then, you create your own StickParity function. This function receives a packet and processes the bytes according to your stick parity, which you then send to the device. Since Parity is set to Parity.None, the SerialPort class won't mess up your data and it should reach your device properly formatted. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: stick parity & vb.net 2005
|
||||
| Thread | Forum | Replies | ||
| Parity and CP-violation | Quantum Physics | 2 | ||
| 2 dimensional quantum mechanical situation | Quantum Physics | 1 | ||
| parity? | High Energy, Nuclear, Particle Physics | 2 | ||
| Will Solar Eclipses Occur on 8 April 2005 and 3 November 2005? | General Physics | 8 | ||
| What is the difference between Visual Studio .Net 2005 and Visual Studio 2005? | Computing & Technology | 4 | ||