CnPack Forum


 
Subject: CnRS232接收大量中文字符问题
ken0137
新警察
Rank: 1



UID 68059
Digest Posts 0
Credits 10
Posts 3
点点分 10
Reading Access 10
Registered 2014-5-15
Status Offline
Post at 2014-5-15 12:07  Profile | Blog | P.M. 
CnRS232接收大量中文字符问题

各位好:
    我使用CnRS232控件连接一个主板,当主板接通电源后将会向串口发送大量含中文的字符,我需要读取这个,但是读到的是大量的夹杂乱码的字符,而且每次还都不一样,我想问一下,是否是我的接收函数写的有问题?还是一些参数没有设置正确?(使用超级终端,得到的是正常的中文字符)
串口初始化:
  RS1.CommName := 'COM'+Form1.ComPortTxt.text;
  RS1.CommConfig.BaudRate :=StrToInt(Form1.BaudRateTxt.Text);
  RS1.CommConfig.Parity :=TParity(paNone);
  RS1.CommConfig.ByteSize :=TByteSize(_8);
  RS1.CommConfig.StopBits :=TStopBits(_1);
  RS1.StopComm;
  RS1.StartComm;
串口接收
var Str :string;
begin
  SetLength(Str,BufferLength);
  Move(buffer^,PChar(@Str[1])^,bufferlength);
  ReturnTxt.Lines.Add(Str);

波特率为9600,这个是定死的,没法改,我试过了要是使用虚拟串口,将波特率变高,那接收中文字符是没有问题的

[ 本帖最后由 ken0137 于 2014-5-15 13:14 编辑 ]
Top
ken0137
新警察
Rank: 1



UID 68059
Digest Posts 0
Credits 10
Posts 3
点点分 10
Reading Access 10
Registered 2014-5-15
Status Offline
Post at 2014-5-15 15:54  Profile | Blog | P.M. 
这个论坛是不是挂了?
Top
 




All times are GMT++8, the time now is 2024-4-20 17:00

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.006280 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP