利用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”?
请问我应该怎么样写才能把秒、分、时、天、月、星期、年写到硬件中?
举个例子
var
sBuf:array[0..1] of byte;
begin
sBuf[0]:=byte($FF); //可以换算出来255
sBuf[1]:=byte($FE);// ............244
//原来的形式可能发送字节数组,现在就是以字符形式发送如下
Mscomm1.output:=chr(255)+chr(254);
end;