求助:用Mscomm控件怎样发送和接收16进制数据?

cgj820307 2006-08-31 03:23:51
用MScomm进行串口通信编程,要发送和接收的都是16进制的数据,不知道该怎样实现,请高手帮忙,最好能给出代码。谢谢!
...全文
632 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sbkopoky 2007-02-17
  • 打赏
  • 举报
回复
有一个香港和悦网络电话的源文件 ,有兴趣妨进入我的BLOG看看
cppowner 2006-12-19
  • 打赏
  • 举报
回复
汗啊 BCB 人真少啊 半年 都没结帖 汗下
shenyouzhe 2006-10-30
  • 打赏
  • 举报
回复
cppowner() 接收16进制数据?举个例子吧。
土著巫师 2006-10-25
  • 打赏
  • 举报
回复
下面是WINDOWS SDK里对串口DCB(设备控制块)里的说明,事实上只能用二进制方式在WINDOWS 32串口通讯了。其中是否用二进制是是对字段fBinary设置 TRUE或FALSE:

Specifies whether binary mode is enabled. The Win32 API does not support nonbinary mode transfers, so this member should be TRUE. Trying to use FALSE will not work.

Under Windows 3.1, if this member is FALSE, nonbinary mode is enabled, and the character specified by the EofChar member is recognized on input and remembered as the end of data.
cppowner 2006-09-25
  • 打赏
  • 举报
回复
老大你解决了给点分把
没分发问题了
i_love_pc 2006-09-15
  • 打赏
  • 举报
回复
16进制的数据应该是属于字符串类型
cppowner 2006-09-14
  • 打赏
  • 举报
回复
int k;
BYTE buff[3000];
char pp;
AnsiString str="",temp,tt;
str=Edit1->Text;
k=str.Length();
int c;
buff[0]=0x9A;
buff[1]=0x00;
buff[2]=0x00;
buff[3]=0x3F;
buff[4]=0x00;
c=8+k;
buff[5]=(8+k)%256;
buff[6]=(8+k)/256;
buff[7]=0x03;
buff[8]=atoi(ComboBox1->Text.c_str());
buff[9]=atoi(ComboBox2->Text.c_str());
buff[10]=atoi(ComboBox3->Text.c_str());
buff[11]=atoi(ComboBox4->Text.c_str());
buff[12]=atoi(ComboBox5->Text.c_str());
buff[13]=atoi(ComboBox6->Text.c_str());




int i; char *ch;
ch=str.c_str();
for(i=0;i<k;i++)
buff[i+14]=*(ch+i);
buff[k+14]=0x00;


for(i=7;i<k+15;i++)
pp+=buff[i];
buff[15+k]=pp;
Txbuff=VarArrayCreate(OPENARRAY(int,(0,k+15)),varByte);
for(i=0;i<k+16;i++)
Txbuff.PutElement(buff[i],i);
Form1->MSComm1->Output=Txbuff;
jackie718 2006-09-12
  • 打赏
  • 举报
回复
用Pcomm动态连接库
LuoGD 2006-09-12
  • 打赏
  • 举报
回复
发送和接收的应该都是Byte字节类型,不存在什么16、10、8等进制的问题
zurong 2006-08-31
  • 打赏
  • 举报
回复
MSComm1->CommPort=1;
MSComm1->InputLen=0;
MSComm1->RThreshold=1;
MSComm1->SThreshold=0;
MSComm1->InputMode=comInputModeBinary;
MSComm1->Settings ="57600,N,8,1";


注意设置就行了

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧