PB7.0做COM口的UO中的问题?

dxx2002 2004-09-01 03:08:26
本人想做个UO来操作COM口,其中碰到了点问题。希望大家能来给小生点提示啊!
1。引用的时候出了问题。以下几个说要结构,但是我有找不到怎么弄了。
FUNCTION Boolean GetCommProperties(ulong hFile,ref COMMPROP lpCommProp) LIBRARY "kernel32.dll"
Function Boolean BuildCommDCBA(ref string lpDef,ref DCB lpDCB ) Library "Kernel32.dll"
Function Boolean SetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll"
Function Boolean GetCommState(ulong hCommDev,ref DCB lpdcb ) Library "Kernel32.dll"
2。COM口怎样来等着接数据呢?
...全文
198 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhushizu 2004-09-01
  • 打赏
  • 举报
回复
这个问题对我这个菜鸟级的人来说还是难了一点点,不过还是要帮楼主顶一下...因为菜鸟也想知道答案....关注中!
dxx2002 2004-09-01
  • 打赏
  • 举报
回复
兄弟,真要我做结构吗?很麻烦的啊!那么多!我倒呢?
dxx2002 2004-09-01
  • 打赏
  • 举报
回复
你说的是FUNCTION boolean ReadFile(ulong fhand, ref string lpbuffer, ulong numbyte, ref ulong bytesread, ulong lpover) LIBRARY "kernel32.dll"吧,我用了,我出的问题是我觉得我等着接收数据的时机好象不是很好。同过串口发了东西出去后就要有一定的BUFFER来等着接收数据,但是COM口不象TCP/IP那样就是一个数据包过来就可以了,它是一点一点的吐出来的,我不知道怎样等着接数据。
还有以前引用 FUNCTION Boolean GetCommProperties(ulong hFile,ref COMMPROP lpCommProp) LIBRARY "kernel32.dll"等等都没问题,也不要我做结构。现在突然报结构错误。我就不明白了。
不过PB7还是可以做多线程,只是没C那么好而已,而且不是很好调试,我都是写文件的方式来调试的。呵呵~~笑话了!现在程序和功能基本做好了,也实现了多线程。我现在就是想把串口通信整理下,现在就是出现了上面的情况!
myclife 2004-09-01
  • 打赏
  • 举报
回复
用readfile读取,pb中没有多线程,多数是用timer
dxx2002 2004-09-01
  • 打赏
  • 举报
回复
对了,我以前引用好象不用什么结构啊。
你的这些type.......end type要做结构还是写到什么地方呢?
dxx2002 2004-09-01
  • 打赏
  • 举报
回复
你写过串口通信的没?SEND后怎么REC呢?它是怎么监听端口的。
myclife 2004-09-01
  • 打赏
  • 举报
回复
type dcb from structure
unsignedlong DCBlength
unsignedlong BaudRate
unsignedlong fBinary
unsignedlong fParity
unsignedlong fOutxCtsFlow
unsignedlong fOutxDsrFlow
unsignedlong fDtrControl
unsignedlong fDsrSensitivity
unsignedlong fTXContinueOnXoff
unsignedlong fOutX
unsignedlong fInX
unsignedlong fErrorChar
unsignedlong fNull
unsignedlong fRtsControl
unsignedlong fAbortOnError
unsignedlong fDummy2
unsignedinteger wReserved
unsignedinteger XonLim
unsignedinteger XoffLim
long ByteSize
long Parity
long StopBits
string XonChar
string XoffChar
string ErrorChar
string EofChar
string EvtChar
end type

type commtimeouts from structure
unsignedlong readintervaltimeout
unsignedlong readtotaltimeoutmultiplier
unsignedlong readtotaltimeoutconstant
unsignedlong writetotaltimeoutmultiplier
unsignedlong writetotaltimeoutconstant
end type

type commprop from structure
character wpacketlength
character wpacketversion
unsignedlong dwservicemask
unsignedlong dwreserved1
unsignedlong dwmaxtxqueue
unsignedlong dwmaxrxqueue
unsignedlong dwmaxbaud
unsignedlong dwprovsubtype
unsignedlong dwprovcapabilities
unsignedlong dwsettableparams
unsignedlong dwsettablebaud
unsignedinteger wsettabledata
unsignedinteger wsettablestopparity
unsignedlong dwcurrenttxqueue
unsignedlong dwcurrentrxqueue
unsignedlong dwprovspec1
unsignedlong dwprovspec2
string wcprovchar[1]
end type

680

社区成员

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

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