笔记:
小结:
1.通过Matlab建立的上位机非常稳定,可以轻松实现图片的发送;
clc; clear all; close all; warning off; % ConfigPacket Frame Packet ConfigPacket_Length = 14;% 配置包单帧长 ConfigPacket_Content = zeros(1,ConfigPacket_Length,"uint8");% 配置包单帧内容初始化 image_w = 640; image_h = 512; Set_ConfigPacket_Content = [8,image_w,image_h,0];% 配置包内容数组 Set_ConfigPacket_Length = length(Set_ConfigPacket_Content);% 配置包总帧长 Readback_ConfigPacket = zeros(Set_ConfigPacket_Length, ConfigPacket_Length, "uint8"); % Data Frame Packet framehead = uint8([170,170,170,170,170,170,170,170]);% 配置包单帧内容初始化 Data_Line_Buf = zeros(1, image_w * 2,"uint8"); % Set Connection Client_1 = tcpclient("192.168.1.10",10000,"Timeout",20,"ConnectTimeout",30); for j = 1:Set_ConfigPacket_Length for i = 1:ConfigPacket_Length if i <= 8 ConfigPacket_Content (i) = 85;% Frame Header elseif i == 9 ConfigPacket_Content (i) = j - 1;% addr elseif i == 10 ConfigPacket_Content (i) = 0;% R/W elseif i == 11 ConfigPacket_Content (i) = uint8(bitand((bitshift(Set_ConfigPacket_Content(j),-24)),255)); elseif i == 12 ConfigPacket_Content (i) = uint8(bitand((bitshift(Set_ConfigPacket_Content(j),-16)),255)); elseif i == 13 ConfigPacket_Content (i) = uint8(bitand((bitshift(Set_ConfigPacket_Content(j),-8)),255)); elseif i == 14 ConfigPacket_Content (i) = uint8(bitand((bitshift(Set_ConfigPacket_Content(j),0)),255)); end end % s is a tcp/ip object write(Client_1,ConfigPacket_Content) pause(0.0001) Readback_ConfigPacket(j, 1:end) = read(Client_1, ConfigPacket_Length, "uint8"); end pause(0.0001); write(Client_1,framehead); pause(0.0001); for n = 1:image_h for m = 1:image_w Data_Line_Buf(2 * m -1) = 0; if n < image_h/4 Data_Line_Buf(2 * m) = 64; elseif n < image_h/2 Data_Line_Buf(2 * m) = 128; elseif n < image_h/2 + image_h/4 Data_Line_Buf(2 * m) = 192; else Data_Line_Buf(2 * m) = 255; end end write(Client_1,Data_Line_Buf) pause(0.000001); end readreq = read(Client_1, 8, "uint8"); clear Client_1;View Code
2.通过C建立的上位机并不是我自己写的,这导致了对我完全黑盒的同时也产生了很多问题,例如粘包;
3.粘包问题我暂时是无法解决的,我打算采取的手段是:更换UDP作为发送媒介并且重新编写自己的上位机(当然也要参考大佬们);
项目展示:
通过上位机配置图像尺寸并发送指定图像完成指定图像传输到FPGA中再输出到HDMI显示;
那条线是因为屏幕自身的问题,不是我代码的问题,啥也不干也有线的。
标签:Set,FPGA,上位,image,ConfigPacket,PC,Length,TCP,170 From: https://www.cnblogs.com/VerweileDoch/p/18026278