pb11.5 串口通讯(16进制) 返回全是0,pb9.0没有任何问题!

nbxkele 2011-11-11 12:33:48
用的是网上下载的例子:纯PB代码 pbcomm



请帮我看下 想转成pb11.5版本的。
...全文
1736 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhoulei100 2013-08-12
  • 打赏
  • 举报
回复
请问这个程序我只能被动接收十六制的信息,发送十六进制06没用仪器没有接收到,串口调试助手就可以接收到十六进制06,请问有朋友知道怎么回事吗?希望可以将程序发送至我邮箱:283462875@qq.com
xuam 2011-11-15
  • 打赏
  • 举报
回复
丁页.
[Quote=引用 7 楼 yyoinge 的回复:]
C/C++ code
Function Boolean CloseHandle(ulong hObject ) Library "kernel32.dll"
FUNCTION boolean ReadFile(ulong fhand, ref string lpbuffer, ulong numbyte, ref ulong bytesread, ulong lpover) LIBRAR……
[/Quote]
yyoinge 2011-11-14
  • 打赏
  • 举报
回复
Function Boolean CloseHandle(ulong  hObject )  Library "kernel32.dll" 
FUNCTION boolean ReadFile(ulong fhand, ref string lpbuffer, ulong numbyte, ref ulong bytesread, ulong lpover) LIBRARY "kernel32.dll" alias for "ReadFile;Ansi"
FUNCTION ulong CreateFileA(ref string fname, ulong f_access, ulong f_share, ulong f_sec, ulong f_create, ulong f_flag, ulong f_attrib) LIBRARY "kernel32.dll" alias for "CreateFileA;Ansi"
Function Boolean WriteFile(uLong handle,ref string lpbuffer,ulong numbytes, ref ulong bytesread, ulong lpOverLaped) Library "Kernel32.dll" alias for "WriteFile;Ansi"
Function Boolean GetCommProperties(ulong hFile,ref COMMPROP lpCommProp ) Library "Kernel32.dll" alias for "GetCommProperties;Ansi"
Function Boolean BuildCommDCBA(ref string lpDef,ref DCB lpDCB ) Library "Kernel32.dll" alias for "BuildCommDCBA;Ansi"
Function Boolean SetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll" alias for "SetCommState;Ansi"
Function Boolean GetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll" alias for "GetCommState;Ansi"
Function ulong GetLastError() Library "Kernel32.dll"
Function Boolean SetCommTimeouts(ulong hCommDev, ref COMMTIMEOUTS lpctmo ) Library "Kernel32.dll" alias for "SetCommTimeouts;Ansi"
Function Boolean PurgeComm(ulong hCommDev, ulong fdwAction ) Library "Kernel32.dll"
SKY_4K_PPM 2011-11-12
  • 打赏
  • 举报
回复
//从PLC中读取30003-30018的数据,02 04 00 02 00 10 50 35。
ole_1.object.inbuffercount=0
int length,ii=2
blob output,outputtemp,tempzero,input
outputtemp= blob("~h02"+"~h04",encodingUTF16BE!)
tempzero=blobmid(outputtemp,1,1) //取值00
outputtemp=outputtemp+tempzero+tempzero //+00
outputtemp=outputtemp+blob("~h02",encodingUTF16BE!)
outputtemp=outputtemp+tempzero+tempzero //+00
outputtemp=outputtemp+blob("~h10"+"~h50"+"~h35",encodingUTF16BE!)
length=len(outputtemp)
do while ii<=length
output+=blobmid(outputtemp,ii,1)
ii+=2
loop
ole_1.object.output=output
我是用ole控件做的,传下去的是2进制数据,encodingUTF16BE!编码格式是关键吧
nbxkele 2011-11-12
  • 打赏
  • 举报
回复
有谁做过11.5版本的 串口16 通讯,帮帮忙啊
WorldMobile 2011-11-11
  • 打赏
  • 举报
回复
例如

Function ulong GetModuleFileNameA ( Long hModule, ref String lpFileName, Long nSize ) Library "Kernel32.dll"

改为

Function ulong GetModuleFileNameA ( Long hModule, ref String lpFileName, Long nSize ) Library "Kernel32.dll" alias for "GetModuleFileNameA;Ansi"
WorldMobile 2011-11-11
  • 打赏
  • 举报
回复
看一下api函数,把用到的api函数声明里都加;ansi
nbxkele 2011-11-11
  • 打赏
  • 举报
回复
改过了 还是不行啊 能发个11.5版本的成功实例吗?
yyoinge 2011-11-11
  • 打赏
  • 举报
回复
FUNCTION boolean ReadFile //在该句定义的最后加上 ALIAS FOR "ReadFile;ansi"
FUNCTION ulong CreateFileA //在该句定义的最后加上 ALIAS FOR "CreateFileA;ansi"
FUNCTION boolean BuildCommDCBA //在该句定义的最后加上 ALIAS FOR "BuildCommDCBA;ansi"

794

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 项目管理
社区管理员
  • 项目管理
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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