Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my VC++ code,

A serial sending data to another computer.

It send a structured data like as follows

struct data_format{

char stx; // 0x02
int type;
int seq;
int lenth;
char data[N];
char etx; // 0x03

Once, it send a data to another part;

stx+ type(=0) + seq(=100) + lenth (=220) + data ....

but in the side of receiving data

stx+ stype(=0) + seq(=100) + lenth (=92) + data....

I confirmed every time that the value of lenths are different between sending and receiving part.(220 -> 92)

Is it possible?

What I have tried:

3 more days wasted for this problem
Posted
Updated 25-Jun-17 19:20pm
Comments
[no name] 26-Jun-17 4:33am    
Sounds like you are trying to send binary data in TEXT mode... which can be 7 bits with 1 used as the odd parity bit.
Rick York 27-Jun-17 13:36pm    
I recommend using a serial communications analyzer so you can see what is actually going over the line. There are lots of variations of them but they can be very helpful and save a lot of time. You would have known within seconds what your problem was if you had one. If you deal with serial comm very often you really should get one.

1 solution

Yes. Look at the values: 92 + 128 == 220. This implies it's a seven bit problem.
The most likely reasons for this are:
1) The communications link between the two devices is set to 7 bits per char (7 bpc), which means that the eighth bit is discarded when it's transmitted.
2) Your software is using a character based value which only holds 7 bits of significant data - it may be that you are using char when you need unsigned char
3) Somewhere in your software you are "masking out" the top bit to prevent negative values.

But without your software, we can't even begin to help you fix.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900