C coolyjc Unregistered / Unconfirmed GUEST, unregistred user! 2002-04-09 #1 求教,如何用ComPort控件发送十六进制代码?请给出例程,谢谢!
W windwy Unregistered / Unconfirmed GUEST, unregistred user! 2002-04-09 #2 procedure TFmexpertload.Beep(ID: Char); var C: Char; Buf: array[0..1] of Char; begin if not ComPort1.Connected then Exit; ComPort1.Write(ID, 1); Sleep(20); ComPort1.Read(Buf, 2); Sleep(20); C := #$A3; ComPort1.Write(C, 1); end;
procedure TFmexpertload.Beep(ID: Char); var C: Char; Buf: array[0..1] of Char; begin if not ComPort1.Connected then Exit; ComPort1.Write(ID, 1); Sleep(20); ComPort1.Read(Buf, 2); Sleep(20); C := #$A3; ComPort1.Write(C, 1); end;
C coollidan Unregistered / Unconfirmed GUEST, unregistred user! 2002-04-10 #3 procedure TForm1.ShowMeClick(Sender: TObject); Var Str:String; begin ComPort1.Open; //打开COM口 //下面是用ComPort控件发送十六进制代码的三种方法,实际上是发送十进制数99给单片机,化成二进制数为‘0110 0011’ Str:=Chr(99); //方法1:Chr() 是将数字转化成ASCII码的函数 //Str:='c'; //方法2:'c'的ASCII码为99,将'c'发送出去,实为发送99 //Str:=#$99; //方法3: #:表示字符,$表示十六进制 ,发送#99 ComPort1.WriteStr(Str); end;
procedure TForm1.ShowMeClick(Sender: TObject); Var Str:String; begin ComPort1.Open; //打开COM口 //下面是用ComPort控件发送十六进制代码的三种方法,实际上是发送十进制数99给单片机,化成二进制数为‘0110 0011’ Str:=Chr(99); //方法1:Chr() 是将数字转化成ASCII码的函数 //Str:='c'; //方法2:'c'的ASCII码为99,将'c'发送出去,实为发送99 //Str:=#$99; //方法3: #:表示字符,$表示十六进制 ,发送#99 ComPort1.WriteStr(Str); end;
W wcwcw Unregistered / Unconfirmed GUEST, unregistred user! 2002-04-10 #4 用ComPort连接打印机 ComPort.WriteStr(#$1c'.'#1); //切纸 ComPort.WriteStr(#27'm'); //具体看打印机的说明书
东 东方龙 Unregistered / Unconfirmed GUEST, unregistred user! 2003-03-25 #7 coollidan兄,能告诉我CPORT如何接收十六进制数据吗?