解决方案 »
- ◆难道就没有人能回答这个问题吗◆
- ... 关于ADOQuery的Update异常问题,大家给看看,谢谢了。在线等...
- 我的可用分快没了,要专家分有个屁用?专家分不能花!大家讨论讨论!
- 问题一有答案,马上结贴!
- 怎样把SpinEdit里的数据存到数据库里面?
- 如何设置打印机的字间距?谢谢
- 添加记录的问题?在线等待!!!!!!!!!!
- 怎样判断 query1.FieldByName('bjts').value 是否为空(nil)
- 各位老大!小弟已经失业半月了!请问在上海哪有招收大专+delphi +sql server的!郁闷!散分
- 怎样输入日文?各位帮帮我!
- 求用delphi在Dll封装多个窗体的方法或源码
- Ehlib的TDBEditEh ReadOnly Bug如何修改?.txt
ED 1C 24 代表图片的位置(x,y)0,0的rgb数据,为红绿蓝,上面的FF 00 00 是正确的
//通信协议: 始码2 + sin + 列数 + 数据24 + 校验1 + 尾码 = 31字节 (累加和校验)
//通信协议: $ @ + 0~11 0~127 数据24 校验1 * #
您分析的有这个可能,我有空测试一下。主要对delphi7情有独钟,瘦小的身材、强大的功能...以后的版本太臃肿了。难道D7真的不行吗?只要有可能,还是希望用D7做这个项目
你可以找个第三方串口软件试下,看看有没delphi7上面一样的数据返回。
而且数据都有校验,就算是你觉得是错误的数据,它的校验又没错,说明是真真实实你接收到的反馈数据,不是delphi的BUG数据啊。
var
c: TColor;
s1 : string;
w_count : Integer;
//pt: TPoint;
newstr1,he,oldstr:string; //校验和
tj:boolean;
i:integer;
begin
Timer1.Enabled := False;
//GetCursorPos(pt); //获取光标
//Label1.Caption := inttostr(pt.X - Fl);
//Label2.Caption := inttostr(pt.Y - Ft);
uart_rx_sign := True;
if uart_rx_sign = True then
begin
uart_err_columns := 0;
w_count := 0;
rgb_str := '';
while (w_count < 8) do //每次取8个点
begin
//c := GetPixel(GetDC(0), Fl+14+tu_x, Ft+70+tu_y); //xp +4 +40
c := GetPixel(GetDC(0), Fl+18+tu_x, Ft+132+tu_y); //win7 +8 +32
s1 := Format('%.6x', [c]); // B G R MidStr
rgb_str := rgb_str + MidStr(s1,5,2);
rgb_str := rgb_str + MidStr(s1,3,2);
rgb_str := rgb_str + MidStr(s1,1,2);
//rgb_str := rgb_str + inttohex(c,6);
//int r = (c & 0xFF);//转换R
//int g = (c & 0xFF00) / 256;//转换G
//int b = (c & 0xFF0000) / 65536;//转换B
//FrmMain.Canvas.Pixels[138+10+tu_x, 30+tu_y] := c;//同步画图
if tu_y < 95 then inc(tu_y)
else
begin
tu_y := 0;
if tu_x < 127 then inc(tu_x)
else tu_x := 0;
end; inc(w_count);
end;
//Label1.Caption := 'S1: ' + s1;
//Label2.Caption := 'RGB: ' + rgb_str;
i:=1; //校验和-------------------------------
he:='';
tj:=true;
oldstr:=copy(rgb_str,1,length(rgb_str));
while tj=true do
begin
newstr1:=copy(oldstr,i,2);
oldstr:=copy(oldstr,i+2,length(oldstr)-2);
//开始计算校验和并给he变量
if he='' then
begin
he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+'00',16),2);
he:=rightstr(he,2);
end
else
begin
he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+he,16),2);
he:=rightstr(he,2);
end;
if length(oldstr) =0 then tj:=false;
end;
rgb_str := rgb_str + he;
uart_str := '$@' + HexStrToStr(IntToHex(led_sin,2)) + HexStrToStr(IntToHex(led_columns,2)) + HexStrToStr(rgb_str) + '*#';
//SendString(uart_str);
//Edit2.Text := StrToHexStr(uart_str);
mmoSend.Lines.Add(StrToHexStr(uart_str));
uart_rx_sign := False;
if led_sin < 11 then Inc(led_sin)
else
begin
led_sin := 0;
if led_columns < 127 then inc(led_columns)
else
begin
led_columns := 0;
Timer1.Enabled := False;
Button1.Caption := '更新';
end;
end;
Edit1.Text := IntToStr(led_sin);
Edit2.Text := IntToStr(led_columns);
Edit3.Text := IntToStr(tu_x);
Edit4.Text := IntToStr(tu_y);
// FlatProgressBar1.Position := trunc((led_sin + led_columns*12)/15); //进度条
end
else //出错处理----------------------
begin
Inc(uart_err_columns);
//Label1.Caption := '状态: ' + IntTostr(uart_err_columns) + ' 错误计数';
if uart_err_columns > 100 then
begin
uart_err_columns := 0;
//Label1.Caption := '状态: ' + HexStrToStr(IntToHex(led_sin,2)) + ' ' + HexStrToStr(IntToHex(led_columns,2)) + ' 故障';
Label1.Caption := '状态: ' + IntToHex(led_sin,2) + ' ' + IntToHex(led_columns,2) + ' 故障';
Timer1.Enabled := False;
Button1.Caption := '更新';
end
else if uart_err_columns = 20 then
begin
//SendString(uart_str);
//Edit2.Text := StrToHexStr(uart_str);
end
else if uart_err_columns = 40 then
begin
//SendString(uart_str);
//Edit2.Text := StrToHexStr(uart_str);
end
else if uart_err_columns = 60 then
begin
//SendString(uart_str);
//Edit2.Text := StrToHexStr(uart_str);
end;
end;
if Button1.Caption = '更新中...' then Timer1.Enabled := True;
end;
无奈地放弃 可爱的“Delphi ”,转c#了。谢谢朋友们的支持!