利用mscomm向硬件传送数据。
type
Tbyterec=record
Lo,Hi:Byte;
end;
tempbyte[0]:=Tbyterec(systemtime.wSecond).Lo ;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wMinute ).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wHour).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wDay).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wMonth).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wDayOfWeek).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wYear).Lo;
我用上面的方法,传送数据。告诉我错误“Access violation at address 004E1BA0 in module "***.exe". write of address 00000000”?
请问我应该怎么样写才能把秒、分、时、天、月、星期、年写到硬件中?
type
Tbyterec=record
Lo,Hi:Byte;
end;
tempbyte[0]:=Tbyterec(systemtime.wSecond).Lo ;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wMinute ).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wHour).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wDay).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wMonth).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wDayOfWeek).Lo;
mscomm1.Output:=tempbyte;
tempbyte[0]:=Tbyterec(systemtime.wYear).Lo;
我用上面的方法,传送数据。告诉我错误“Access violation at address 004E1BA0 in module "***.exe". write of address 00000000”?
请问我应该怎么样写才能把秒、分、时、天、月、星期、年写到硬件中?
MSComm1.Output = Sendtemp
Sendtemp(0) = Minute(Time)
MSComm1.Output = Sendtemp
Sendtemp(0) = Hour(Time)
MSComm1.Output = Sendtemp
Sendtemp(0) = Day(Date)
MSComm1.Output = Sendtemp
Sendtemp(0) = Month(Date)
MSComm1.Output = Sendtemp
Sendtemp(0) = 4
MSComm1.Output = Sendtemp
Sendtemp(0) = Year(Date) - 2000
MSComm1.Output = Sendtemp
这是在vb下的向硬件中写时间的程序。难道delphi就不行吗?
temp:array[0..6] of byte
outt:variant;
begin
temp[i]:=.....// 或是copymemory(@temp,@systemp,sizeof(byte)*6)
outt:=temp;
mscomm1.Output:=outt;