找回密码
 注册
LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 1240|回复: 6

[labview求助] 关于DLL调用-USB转485中的串口参数如何设置-有偿!

[复制链接]
发表于 2011-2-12 09:16:57 | 显示全部楼层 |阅读模式
本帖最后由 sddnothing 于 2011-2-12 11:26 编辑

原程序中参数设置格式为:ret=sio_ioctl(2,B38400,P_NONE|BIT_8|STOP_1);
在进行DLL调用时,怎么进行参数设置?

目的:使用hexin USB转485或DT5011 USB转485 进行数据通信,能提供详细源程序或指导的可邮件联系商谈报酬。两种转接线我都有驱动光盘。chongzhoud@Hotmail.com

 楼主| 发表于 2011-2-12 09:53:09 | 显示全部楼层
有这个介绍
Language    Syntax
C/C++    int WINAPI sio_ioctl(int port, int baud, int mode)
Visual Basic    Function sio_ioctl(ByVal port As Long, ByVal baud As Long, ByVal mode As Long) As Long
Delphi    function sio_ioctl(port, baud, mode: Longint): Longin
Argument:
port = COM port number
baud = (bits/sec)
0 = 50    6 = 600    12 = 9600    18 = 460800
1 = 75    7 = 1200    13 = 19200    19 = 921600
2 = 110    8 = 1800    14 = 38400
3 = 134.5    9 = 2400    15 = 57600
4 = 150    10 = 4800    16 = 115200
5 = 300    11 = 7200    17 = 230400
Note: Some COM ports may not support higher speed. Please refer to the COM port's manual for more information.
mode = bit_cnt OR stop_bit OR parity
bit_cnt (bit 0, 1) =    0x00 = bit_5
0x01 = bit_6
0x02 = bit_7
0x03 = bit_8
stop_bit (bit 2) =    0x00 = stop_1
0x04 = stop_2
parity (bit 3,4 5) =    0x00 = none
0x08 = odd
0x18 = even
0x28 = mark
0x38 = space
Return:
SIO_OK    OK
SIO_BADPORT    Port is not opened in advance
SIO_BADPARM    Bad parameter
SIO_WIN32FAIL    Calling Win32 function failed
Call GetLastError to get the error code

Example:

Configure COM2 communication parameter:
Baud rate = 38400, Parity = NONE, Data bits = 8, Stop bits = 1

C/C++

ret = sio_ioctl ( 2, B38400, P_NONE | BIT_8 | STOP_1 );
if (ret != SIO_OK) {
    /* Setting fail  */
}
回复 顶

使用道具 举报

 楼主| 发表于 2011-2-12 10:39:09 | 显示全部楼层
/* PComm_c.h          
* PComm define file for Win32 on C/C++
* History:
* Date            Author        Comment
* 10/22/1996  Victor        wrote it.
* 03/28/1997  Victor        modified. add sio_term_irq function.
*                                add sio_linput function.
* 04/29/1997  Victor        modified. add sio_putb_x function.
* 05/21/1997  Victor        modified. add sio_view function.
* 06/13/1997  Victor        modified. add file transfer function.
* 06/30/1997  Victor        modified. add sio_TxLowWater function.
* 11/17/1997  Victor        add sio_AbortWrite, sio_SetWriteTimeouts
* 11/21/1997  Victor        add sio_SetReadTimeouts, sio_AbortRead
*                                sio_GetReadTimeouts, sio_GetWriteTimeouts
* 03/08/1998  Casper   support VB 5.0
*
* 04/27/1999  Casper   add sio_ActXon, sio_ActXoff, sio_break_ex
*/

/*        BAUD rate setting        */
#define B50                        0x00
#define B75                        0x01
#define B110                0x02
#define B134                0x03
#define B150                0x04
#define B300                0x05
#define B600                0x06
#define B1200                0x07
#define B1800                0x08
#define B2400                0x09
#define B4800                0x0A
#define B7200                0x0B
#define B9600                0x0C
#define B19200                0x0D
#define B38400                0x0E
#define B57600                0x0F
#define B115200         0x10
#define B230400         0x11
#define B460800         0x12
#define B921600         0x13

/*        MODE setting                */
#define BIT_5                0x00                        /* Word length define        */
#define BIT_6                0x01
#define BIT_7                0x02
#define BIT_8                0x03

#define STOP_1                0x00                        /* Stop bits define        */
#define STOP_2                0x04

#define P_EVEN                0x18                        /* Parity define        */
#define P_ODD                0x08
#define P_SPC                0x38
#define P_MRK                0x28
#define P_NONE                0x00

/*        MODEM CONTROL setting        */
#define C_DTR                0x01
#define C_RTS                0x02

/*        MODEM LINE STATUS        */
#define S_CTS                0x01
#define S_DSR                0x02
#define S_RI                0x04
#define S_CD                0x08

/* error code */
#define SIO_OK                0
#define SIO_BADPORT        -1        /* no such port or port not opened */
#define SIO_OUTCONTROL        -2        /* can't control the board */
#define SIO_NODATA        -4        /* no data to read or no buffer to write */
#define SIO_OPENFAIL        -5        /* no such port or port has be opened */
#define SIO_RTS_BY_HW        -6      /* RTS can't set because H/W flowctrl */
#define SIO_BADPARM        -7        /* bad parameter */
#define SIO_WIN32FAIL        -8        /* call win32 function fail, please call */
                                /* GetLastError to get the error code */
#define SIO_BOARDNOTSUPPORT -9        /* Does not support this board */
#define SIO_FAIL        -10        /* PComm function run result fail */
#define SIO_ABORTWRITE        -11        /* write has blocked, and user abort write */
#define SIO_WRITETIMEOUT    -12 /* write timeoue has happened */

/* file transfer error code */
#define SIOFT_OK        0
#define SIOFT_BADPORT        -1        /* no such port or port not open */
#define SIOFT_TIMEOUT        -2        /* protocol timeout */
#define SIOFT_ABORT        -3        /* user key abort */
#define SIOFT_FUNC        -4        /* func return abort */
#define SIOFT_FOPEN        -5        /* can not open files */
#define SIOFT_CANABORT        -6        /* Ymodem CAN signal abort */
#define SIOFT_PROTOCOL        -7        /* Protocol checking error abort */
#define SIOFT_SKIP        -8        /* Zmodem remote skip this send file */
#define SIOFT_LACKRBUF        -9        /* Zmodem Recv-Buff size must >= 2K bytes */
#define SIOFT_WIN32FAIL -10        /* OS fail */
                                /* GetLastError to get the error code */
#define SIOFT_BOARDNOTSUPPORT -11           /* Does not support board */

#ifdef __cplusplus
extern "C" {
#endif

/* basic function phototype */
int  WINAPI sio_ioctl(int port, int baud, int mode);
int  WINAPI sio_getch(int port);
int  WINAPI sio_read(int port, char *buf, int len);
int  WINAPI sio_putch(int port, int term);
int  WINAPI sio_write(int port, char *buf, int len);
int  WINAPI sio_flush(int port, int func);
long WINAPI sio_iqueue(int port);
long WINAPI sio_oqueue(int port);
int  WINAPI sio_lstatus(int port);
int  WINAPI sio_lctrl(int port, int mode);
int  WINAPI sio_cnt_irq(int port, VOID (CALLBACK *func)(int port), int count);
int  WINAPI sio_modem_irq(int port, VOID (CALLBACK *func)(int port));
int  WINAPI sio_break_irq(int port, VOID (CALLBACK *func
回复 顶

使用道具 举报

发表于 2011-2-12 13:52:17 | 显示全部楼层
不知道是否符合你的实际情况:
把转换器插到电脑上,安装上驱动,此时,硬件管理器里面就会以串口的形式显示该转换器,你在编程时,按串口操作就够了,不需要在对dll进行调用。
我的PXI上也扩展了一个,就是这么做的。
回复 顶

使用道具 举报

 楼主| 发表于 2011-2-14 13:23:57 | 显示全部楼层
设备管理器能找到端口,但labview的visa找不到。。。所以只要用这个麻烦的办法了。。。
回复 顶

使用道具 举报

发表于 2011-2-14 13:27:45 | 显示全部楼层
sddnothing 发表于 2011-2-14 13:23
设备管理器能找到端口,但labview的visa找不到。。。所以只要用这个麻烦的办法了。。。

labview的VISA中看不到串口要装上VISA就好了
回复 顶

使用道具 举报

 楼主| 发表于 2011-2-15 09:56:17 | 显示全部楼层
回复 顶

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2026-9-28 21:43 , Processed in 0.034146 second(s), 7 queries , Gzip On, File On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表