⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ser_intf.bas

📁 HP GPIB的VB和C语言库文件,参考范例.
💻 BAS
字号:

'  set_intf.bas
'  This program does the following:
'  1) gets the current configuration of the serial port
'  2) sets it to 9600 baud, no parity, 8 data bits, and
'     1 stop bit
'  3) prints the old configuration
Sub main ()
   Dim intf As Integer
   Dim baudrate As Long
   Dim parity As Long
   Dim databits As Long
   Dim stopbits As Long
   Dim parity_str As String
   Dim msg_str As String

   ' open RS-232 interface session
   intf = iopen("COM1")
   Call itimeout(intf, 10000)

   ' get baud rate, parity, data bits, and stop bits
   Call iserialstat(intf, I_SERIAL_BAUD, baudrate)
   Call iserialstat(intf, I_SERIAL_PARITY, parity)
   Call iserialstat(intf, I_SERIAL_WIDTH, databits)
   Call iserialstat(intf, I_SERIAL_STOP, stopbits)

   ' determine string to display for parity
   Select Case parity
   Case I_SERIAL_PAR_NONE
      parity_str = "NONE"
   Case I_SERIAL_PAR_ODD
      parity_str = "ODD"
   Case I_SERIAL_PAR_EVEN
      parity_str = "EVEN"
   Case I_SERIAL_PAR_MARK
      parity_str = "MARK"
   Case Else
      parity_str = "SPACE"
   End Select

   ' set to 9600,NONE,8, 1
   Call iserialctrl(intf, I_SERIAL_BAUD, 9600)
   Call iserialctrl(intf, I_SERIAL_PARITY, I_SERIAL_PAR_NONE)
   Call iserialctrl(intf, I_SERIAL_WIDTH, I_SERIAL_CHAR_8)
   Call iserialctrl(intf, I_SERIAL_STOP, I_SERIAL_STOP_1)

   ' display previous settings
   msg_str = "Old settings: " + Str$(baudrate) + "," + parity_str + "," + Str$(databits) + "," + Str$(stopbits)
   MsgBox msg_str, MB_ICON_EXCLAMATION

   ' close port
   Call iclose(intf)

'  Tell SICL to cleanup for this task
   Call siclcleanup

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -