我想通过串口传输mp3文件 但是不知道串口传输文件的原理 最好以zmedom协议 串口传输mp3文件为例 讲解下具体过程
zmedom协议格式代码我也没有 只知道使用这个协议 我负责的是上位机编程 谢谢帮助
zmedom协议格式代码我也没有 只知道使用这个协议 我负责的是上位机编程 谢谢帮助
解决方案 »
- installshield怎么样获取programData的路径
- windows服务获取显卡温度
- 实在搞不定了,请教,主线程,子线程之间传递值
- CSocket文件传输接收不到完整文件
- 有过USB开发经验的请进!!!(30分相送)
- Hook的两个问题~~~~~~~~~初学者
- 比较弱的问题,如何在别的类中调用定义在一个类中的TAB变量?
- 急求BMP图象库
- 关于模态对话框中调用函数的问题
- 怎样把word文件转化为pdf格式的文件!!急~~~
- 以太网建立VC和PLC得通信
- VS2005/VC++中,编译时出现“error C2228: left of '.WritePort' must have class/struct/union”
1 串口如何读取文件 (mp3文件)2 文件发送协议zmedom协议是怎样定义的
一般没特殊安全考虑,自定义个简单协议就行了
#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;}