我想通过串口传输mp3文件 但是不知道串口传输文件的原理  最好以zmedom协议 串口传输mp3文件为例 讲解下具体过程 
   
  zmedom协议格式代码我也没有 只知道使用这个协议 我负责的是上位机编程  谢谢帮助

解决方案 »

  1.   

    两个问题困扰:
    1  串口如何读取文件 (mp3文件)2  文件发送协议zmedom协议是怎样定义的
      

  2.   

    串口读文件还不是,先把文件读到内存,再通过串口发出去zmodem协议是ymodem的升级,协议定义可以google啊。
    一般没特殊安全考虑,自定义个简单协议就行了
      

  3.   

    得看串口连的设备支持什么协议。要想省开发时间的话就在设备上开FTP。
      

  4.   

    一般来说友元函数能够访问类的私有成员变量吧? 为什么我的程序有一个问题,我解决不了,请各位高人指点一下,谢谢//Header file mystring.h
    #ifndef H_mystring
    #define H_mystring
    #include<iostream>
    using namespace std;
    class newstring
    {
    friend ostream& operator<<(ostream&,const newstring&);//
    friend istream& operator>>(istream&, newstring&);
    public:
    const newstring& operator=( const newstring&);
        newstring(const char*);
     newstring( );
      newstring(const newstring&);
      ~newstring( );
      char &operator[] (int);//为非常量数组声明运算符函数operator[]为类成员
      const char &operator[](int) const;//为常量数组声明运算符函数operator[]为类成员
         
      //overload the relatonal operators;
      bool operator!=( const newstring&) const;
       bool operator==( const newstring&) const;
        bool operator>=( const newstring&) const;
     bool operator<=( const newstring&) const;
             bool operator>( const newstring&) const; 
    private:
    char *strptr;//pointer to the char array that holds the string
    int strlength;//data me,ber to store the length of the string
    };
    #endif#include<iostream>
     #include<iomanip>
     #include<cstring>
     #include<cassert>
     #include"mystring.h"
    using namespace std;newstring::newstring(const char *str)//转换构造函数,它把参数转换为类的对象,在当前情况下把一个
    //字符创转换为newtring类型的对象
    {strlength=strlen(str);
    strptr=new char[strlength+1];
    assert(strptr!=NULL);
    strcpy(strptr,str);}newstring::newstring()
    {strlength=1;
    strptr=new char[1];
    assert(strptr !=NULL);
    strcpy(strptr," ");
    }newstring::newstring(const newstring& rightstr)//复制构造函数
    {strlength= rightstr.strlength;
    strptr=new char[strlength+1];
    assert(strptr !=NULL);
    strcpy(strptr,rightstr.strptr);
    }newstring::~newstring()
    {delete[] strptr;}const newstring& newstring::operator=(const newstring& rightstr)
    {
    if(this!=&rightstr)//avoid self-copy
    {
    delete [] strptr;
    strlength= rightstr.strlength;
    strptr=new char[strlength+1];
    assert(strptr !=NULL);
    strcpy(strptr,rightstr.strptr);
    }
    return *this;
    }char& newstring::operator[](int index)
    {assert(0<=index && index<strlength);
    return strptr[index];}const char& newstring::operator[](int index)const
    {
    assert(0<=index && index<strlength);
    return strptr[index];
    }bool newstring::operator==(const newstring& rightstr)const
    {
    return (strcmp(strptr,rightstr.strptr)==0);
    }
    bool newstring::operator>=(const newstring& rightstr)const
    {
    return (strcmp(strptr,rightstr.strptr)>=0);
    }
    bool newstring::operator<=(const newstring& rightstr)const
    {
    return (strcmp(strptr,rightstr.strptr)<=0);
    }
    bool newstring::operator!=(const newstring& rightstr)const
    {
    return (strcmp(strptr,rightstr.strptr)!=0);
    }
    bool newstring::operator>(const newstring& rightstr)const
    {
    return (strcmp(strptr,rightstr.strptr)>0);
    }ostream& operator<<(ostream& osobject, const newstring& str)//
    {
    osobject<<str.strptr;
    return osobject;
    }istream& operator>>(istream& isobject, newstring& str)
    {char temp[81];
    isobject>>setw(81)>>temp;
    str=temp;
    return isobject;
    }
    #include<iostream>
    #include"mystring.h"
    using namespace std;void main()
    { newstring str1="sunny";const newstring str2("warm");
    newstring str3;
    newstring str4;
    cout<<"line1:  "<<str1<<" "<<str2<<"***"<<str3<<"###."<<endl;
    if(str1<=str2)
    cout<<"line3:"<<str1<<" is less than"<<str2<<endl;
    else
    cout<<"line5:"<<str2<<" is less than"<<str1<<endl;}