当前位置:首页 > 单片机 > 单片机
[导读]  趁热打铁,在上一PIC32MZ UDP ethernet bootloader的基础上我又完成了采用TCP协议的PIC32MZ ethernet bootloader。两款ethernet bootloader基本架构都一样,数据包格式也一样。TCP ethernet bootloader 也分两部

  趁热打铁,在上一PIC32MZ UDP ethernet bootloader的基础上我又完成了采用TCP协议的PIC32MZ ethernet bootloader。两款ethernet bootloader基本架构都一样,数据包格式也一样。TCP ethernet bootloader 也分两部分,我将他们命名为PhnLoader_v4.0和PhnBoot_v4.0。

PhnLoader_v4.0

  PhnLoader_v4.0 是PC端host 程序。

运行环境:Window + .NET Framework 4.5

开发语言:C#

通信类型:TCP Server

IP 地址: 192.168.1.105

端口号: 8720

  UI 如下:

  主要代码如下:


try{while(loaderReader.Peek()>=0){pBarLoading.PerformStep();recordLine=loaderReader.ReadLine();if(recordLine.Contains(EXTEND_TOKEN)==true){if(recordLine.Contains(USER_ID_TOKEN)==true){isNextLineUserID=true;continue;}//elseif(recordLine.Contains(CONFIG_BITS_TOKEN)==true)//{//constintADDR_U_START_INDEX=9;//constintADDR_U_LENGTH=4;//stringaddrU=recordLine.Substring(ADDR_U_START_INDEX,ADDR_U_LENGTH);//loaderUpperAddr=Convert.ToInt32(addrU,16)<<16;//isNextLineConfigBits=true;//continue;//}elseif(recordLine.Contains(PIC32_CONFIG_BITS_TOKEN)==true){constintADDR_U_START_INDEX=9;constintADDR_U_LENGTH=4;stringaddrU=recordLine.Substring(ADDR_U_START_INDEX,ADDR_U_LENGTH);loaderUpperAddr=Convert.ToInt32(addrU,16)<<16;isNextLineConfigBits=true;continue;}else{constintADDR_U_START_INDEX=9;constintADDR_U_LENGTH=4;stringaddrU=recordLine.Substring(ADDR_U_START_INDEX,ADDR_U_LENGTH);loaderUpperAddr=Convert.ToInt32(addrU,16)<<16;continue;}}elseif(recordLine.Contains(END_OF_HEX_FILE_TOKEN)==true){break;}if(isNextLineUserID){isNextLineUserID=false;//donothing;}elseif(isNextLineConfigBits){if(!DownloadConfigLine(recordLine)){Debug.WriteLine("Errorfoundduringconfigurationbitsprogramming");loaderReader.Close();loaderServer.Close();btnDownload.Enabled=true;return;}isNextLineConfigBits=false;}else{if(!DownloadDataLine(recordLine)){Debug.WriteLine("Errorfoundduringdataprogramming");loaderReader.Close();loaderServer.Close();btnDownload.Enabled=true;return;}}}}catch(Exceptionex){Debug.WriteLine("Error:"+ex.Message);textBoxStatus.ForeColor=Color.Red;textBoxStatus.AppendText("Downloadingfailedrn");textBoxStatus.ForeColor=Color.Black;loaderServer.Close();loaderReader.Close();btnDownload.Enabled=true;return;}textBoxStatus.AppendText("Downloadingcompletedrn");

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

总线-Ethernet与EtherCAT的比较

关键字: ethercat ethernet

Microchip公司的PIC32MZ EF系列是高达250MHz的集成浮点单元(FPU),具有广泛的外设和包括局域网(CAN)的极好的连接选择,工作电压2.1V到 3.6V,DSP增强核具有四

关键字: Microchip pic32mz 处理器

  随着半导体技术的不断进步(按照摩尔定律),MCU内部集成的逻辑功能外设越来越多,存储器也越来越大。消费者对于汽车节能(经济和法规对排放的要求)型、舒适性、互联性、安全性(功能安全和信息安全)

关键字: bootloader 汽车电子

1.之所以要实现一个专用的bootloader,一是为了更好的移植和自身的升级,二是为了方便操作系统的调试,当然,你完全可以将这部分所要实现的与操作系统相关的功能集成到操作

关键字: bootloader 如何实现 嵌入式开发

  An interrupt is an internal or external event that requires quick attention from the controller. The PIC32MZ...

关键字: interrupt pic32mz timer tutorial

一、Android网络简介Android与服务器的通信方式主要有两种,一种是Http通信,另一种是Socket通信。HTTP通信:Android中内置HttpClient,这样可以发方便的发送Http

关键字: Android tcp协议 网络通信

  In my last post I implement "Key Debounce" with port polling, port polling is not very efficient....

关键字: pic32mz tutorial change notification
关闭
关闭