Toggle parity bit for sending and receiving data via Serial Port

All:
I am writing a window program to communicate with a embedded frimware
device via PC RS232 serial port.  My program requires sending and
receiving data.  In each frame, first and last bytes need parity bit
set (MARK), the rest of bytes need parity bit reset (SPACE).  The
window program is the master.

My question is when I set parity bit on PC is different than the one I
receive, do I really receive this type (I am using ReadFile)?

I used HyperTerminal to try out this test.  I start HyperTerminal in
two different PCs.  Two PCs are connected via serial port.  I set up
one PC with MARK parity, the other one with SPACE parity.  The rest of
settings are the same.  When I send only one byte, I did receive this
type on the other PC, but if I send more bytes, I didn't receive
anything on the other PC.  Can someone explain the parity bit problem
on PC in general?  Should my program be ready to receive any data even
in different parity bit?


Thank you for the help
awu10

0
awu10 (17)
8/31/2006 4:19:23 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
405 Views

Similar Articles

[PageSpeed] 40

awu wrote:
> All:
> I am writing a window program to communicate with a embedded frimware
> device via PC RS232 serial port.  My program requires sending and
> receiving data.  In each frame, first and last bytes need parity bit
> set (MARK), the rest of bytes need parity bit reset (SPACE).  The
> window program is the master.
> 
> My question is when I set parity bit on PC is different than the one I
> receive, do I really receive this type (I am using ReadFile)?
> 
> I used HyperTerminal to try out this test.  I start HyperTerminal in
> two different PCs.  Two PCs are connected via serial port.  I set up
> one PC with MARK parity, the other one with SPACE parity.  The rest of
> settings are the same.  When I send only one byte, I did receive this
> type on the other PC, but if I send more bytes, I didn't receive
> anything on the other PC.  Can someone explain the parity bit problem
> on PC in general?  Should my program be ready to receive any data even
> in different parity bit?

Windows does not give you the received parity bit.  The hardware checks 
it and reports an error if it does not match what you have set.  So you 
might not be able to do this at all using the standard Windows serial 
driver.

A possible work-around: If your device data format is 7 bits plus parity 
try setting 8 bits with no parity in your program.  I think the received 
parity bit will then appear in the high bit of each received byte, with 
no hardware checking.  And if that works it would probably also let you 
set the high bit when you send, letting you directly control the send 
parity in each character.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
8/31/2006 9:47:32 PM
Reply:

Similar Artilces: