A
anndy1999
Unregistered / Unconfirmed
GUEST, unregistred user!
这个UNIX下c传送的data_format结构体数据包:
struct stimeval
{
int Tv_Sec
int Tv_Usec
}timeval;
struct data_format
{
byte Data_Type;
short Code;
int Height;
int Velocity;
float Heading;
int X_axis;
int Y_axis;
float Longitude;
float Latitude;
int Sys_Track_No;
int Track_No;
byte Target_Id;
int Obj_Type;
int Weight;
int Ca_Twins[5];
timeval Time_Stamp;
char Info[256];
byte S_Flag;
byte Other_Flag;
char Call_Sign[10];
}
这是在delphi下接收的结构体
type
RdpTimeVal = Record
Tv_Sec:Integer;
Tv_Usec:Integer;
end;
DBCAR =Record
Data_Type : Byte;
Code : SmallInt;
Height : Integer;
Velocity : Integer;
Heading : Single;
X_axis : Integer;
Y_axis : Integer;
Longitude : Single;
Latitude : Single;
Sys_Track_No : Integer;
Track_No : Integer;
Target_Id : Byte;
Obj_Type : Integer;
Weight : Integer;
Ca_Twins : array [0..4] of Integer;
Time_Stamp : RdpTimeVal;
Info :array [0..255] of byte;
S_Flag : Byte;
Other_Flag : Byte;
Call_Sign : array [0..9] of byte;
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
car : DBCAR;
str:TMemoryStream;
begin
str:=TMemoryStream.Create;
str.LoadFromStream(AData);
str.Read(plan,str.Size);
Memo2.Lines.Add('类型:'+InttoStr(plan.Data_Type)+','
+'高:'+IntToStr(ntohl(plan.Height))+','
+'序号:'+IntToStr(plan.Call_Sign[0])+','
);
str.Free;
end;
plan.Call_Sign[0]为0,plan.Call_Sign[1]、plan.Call_Sign[3]这些也为0,什么原因呢??
其他除的char型的都能正常接收,发送方是64位机,接收方是32位机,所以在接收int这些我用了ntohl来转。但char型的我怎么也接收不到数据。
没分了,大家肯帮我偶吗?
struct stimeval
{
int Tv_Sec
int Tv_Usec
}timeval;
struct data_format
{
byte Data_Type;
short Code;
int Height;
int Velocity;
float Heading;
int X_axis;
int Y_axis;
float Longitude;
float Latitude;
int Sys_Track_No;
int Track_No;
byte Target_Id;
int Obj_Type;
int Weight;
int Ca_Twins[5];
timeval Time_Stamp;
char Info[256];
byte S_Flag;
byte Other_Flag;
char Call_Sign[10];
}
这是在delphi下接收的结构体
type
RdpTimeVal = Record
Tv_Sec:Integer;
Tv_Usec:Integer;
end;
DBCAR =Record
Data_Type : Byte;
Code : SmallInt;
Height : Integer;
Velocity : Integer;
Heading : Single;
X_axis : Integer;
Y_axis : Integer;
Longitude : Single;
Latitude : Single;
Sys_Track_No : Integer;
Track_No : Integer;
Target_Id : Byte;
Obj_Type : Integer;
Weight : Integer;
Ca_Twins : array [0..4] of Integer;
Time_Stamp : RdpTimeVal;
Info :array [0..255] of byte;
S_Flag : Byte;
Other_Flag : Byte;
Call_Sign : array [0..9] of byte;
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
car : DBCAR;
str:TMemoryStream;
begin
str:=TMemoryStream.Create;
str.LoadFromStream(AData);
str.Read(plan,str.Size);
Memo2.Lines.Add('类型:'+InttoStr(plan.Data_Type)+','
+'高:'+IntToStr(ntohl(plan.Height))+','
+'序号:'+IntToStr(plan.Call_Sign[0])+','
);
str.Free;
end;
plan.Call_Sign[0]为0,plan.Call_Sign[1]、plan.Call_Sign[3]这些也为0,什么原因呢??
其他除的char型的都能正常接收,发送方是64位机,接收方是32位机,所以在接收int这些我用了ntohl来转。但char型的我怎么也接收不到数据。
没分了,大家肯帮我偶吗?