RS-485通讯 [英] RS-485 Communication
问题描述
我使用的是vortex86 icop board&它的4个com端口我已经用过了。所以我想用RS485端口进行通信。我怎么读&将数据写入此端口。我必须打开相同的端口号。如果可能,请使用vc ++使用wince6.0智能设备应用程序向我发送示例代码。我是
。
i am using vortex86 icop board & its 4 com port i already used.so i want to use RS485 port for communication. How can i read & write data to this port.Which port number i have to open for the same.If possible send me sample code.i am
using wince6.0 smart device application using vc++.
推荐答案
这真的取决于您的BSP。阅读提供的文档或联系您的提供商。
This is really down to your BSP. Read the documentation provided or contact your provider.
COM端口号不会是1-4。您必须使用WIN32 API调用来实现通信。请看: -
The COM port number no dought will be from 1-4. You would have to use the WIN32 API calls to achieve communications. Look at :-
HANDLE WINAPI CreateFile(
__in LPCTSTR lpFileName,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwCreationDisposition,
__in DWORD dwFlagsAndAttributes,
__in_opt HANDLE hTemplateFile
);
HANDLE WINAPI CreateFile(
__in LPCTSTR lpFileName,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwCreationDisposition,
__in DWORD dwFlagsAndAttributes,
__in_opt HANDLE hTemplateFile
);
这将使您可以访问该端口,然后使用Read& WriteFile等有很多组件和例子可供查看。谷歌吧。
This will give you access to the port, then use Read & WriteFile etc. There are many components and examples out there to look at. Google it.
这篇关于RS-485通讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!